tokens.pwn 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Token System
  11. Next Generation Gaming, LLC
  12. (created by Next Generation Gaming Development Team)
  13. * Copyright (c) 2016, Next Generation Gaming, LLC
  14. *
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without modification,
  18. * are not permitted in any case.
  19. *
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  25. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. CMD:tokenhelp(playerid, params[])
  34. {
  35. SendClientMessageEx(playerid, COLOR_GREEN,"_______________________________________");
  36. SendClientMessageEx(playerid, COLOR_WHITE,"*** TOKEN HELP ***");
  37. SendClientMessageEx(playerid, COLOR_GRAD3,"VIP tokens can be traded for weapons at the VIP Locker.");
  38. SendClientMessageEx(playerid, COLOR_GRAD3,"VIP tokens can be won at events or gifts.");
  39. SendClientMessageEx(playerid, COLOR_GRAD3,"Weapons cost 1-5 tokens each, from melee weapons to high-powered firearms.");
  40. SendClientMessageEx(playerid, COLOR_GRAD3,"If you wish to give other VIPs your tokens, use /givetokens.");
  41. return 1;
  42. }
  43. CMD:random(playerid, params[]) {
  44. if(PlayerInfo[playerid][pAdmin] >= 1337) {
  45. new
  46. iHours,
  47. iBroadcast;
  48. if(sscanf(params, "dd", iHours, iBroadcast)) {
  49. return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /random [hours] [broadcast]");
  50. }
  51. new
  52. arr_Winners[MAX_PLAYERS],
  53. iWinCount;
  54. foreach(new i: Player)
  55. {
  56. if(SeeSpecialTokens(i, iHours)) arr_Winners[iWinCount++] = i;
  57. }
  58. if(iWinCount > 0) {
  59. new
  60. iWinrar = arr_Winners[random(iWinCount)],
  61. szMessage[48 + MAX_PLAYER_NAME];
  62. if(iBroadcast == 1) {
  63. format(szMessage, sizeof(szMessage), "%s was just randomly selected! Congratulations!", GetPlayerNameEx(iWinrar));
  64. SendClientMessageToAllEx(COLOR_WHITE, szMessage);
  65. }
  66. else {
  67. format(szMessage, sizeof(szMessage), "%s (ID %d) was randomly selected.", GetPlayerNameEx(iWinrar), iWinrar);
  68. ABroadCast(COLOR_YELLOW, szMessage, 1338);
  69. }
  70. }
  71. else SendClientMessageEx(playerid, COLOR_WHITE, "Nobody online can win!");
  72. }
  73. return 1;
  74. }
  75. CMD:vrandom(playerid, params[]) {
  76. if(PlayerInfo[playerid][pAdmin] >= 1337) {
  77. new
  78. iHours,
  79. iBroadcast;
  80. if(sscanf(params, "dd", iHours, iBroadcast)) {
  81. return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /vrandom [hours] [broadcast]");
  82. }
  83. new
  84. arr_Winners[MAX_PLAYERS],
  85. iWinCount;
  86. foreach(new i: Player)
  87. {
  88. if(SeeSpecialTokens(i, iHours) && PlayerInfo[i][pDonateRank] > 0) arr_Winners[iWinCount++] = i;
  89. }
  90. if(iWinCount > 0) {
  91. new
  92. iWinrar = arr_Winners[random(iWinCount)],
  93. szMessage[48 + MAX_PLAYER_NAME];
  94. if(iBroadcast == 1) {
  95. format(szMessage, sizeof(szMessage), "%s was just randomly selected! Congratulations!", GetPlayerNameEx(iWinrar));
  96. SendClientMessageToAllEx(COLOR_WHITE, szMessage);
  97. }
  98. else {
  99. format(szMessage, sizeof(szMessage), "%s (ID %d) was randomly selected.", GetPlayerNameEx(iWinrar), iWinrar);
  100. ABroadCast(COLOR_YELLOW, szMessage, 1338);
  101. }
  102. }
  103. else SendClientMessageEx(playerid, COLOR_WHITE, "Nobody online can win!");
  104. }
  105. return 1;
  106. }
  107. CMD:givetokens(playerid, params[])
  108. {
  109. if(PlayerInfo[playerid][pDonateRank] > 0)
  110. {
  111. new string[128], giveplayerid, amount;
  112. if(sscanf(params, "ud", giveplayerid, amount)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /givetokens [player] [amount]");
  113. if(IsPlayerConnected(giveplayerid))
  114. {
  115. if(PlayerInfo[giveplayerid][pDonateRank] > 0)
  116. {
  117. if(PlayerInfo[playerid][pTokens] >= amount)
  118. {
  119. if(amount < 1)
  120. {
  121. SendClientMessageEx(playerid, COLOR_GRAD1, "You can not give that amount!");
  122. return 1;
  123. }
  124. if(giveplayerid == playerid)
  125. {
  126. SendClientMessageEx(playerid, COLOR_GRAD1, "You can not give tokens to yourself!");
  127. return 1;
  128. }
  129. if (!ProxDetectorS(5.0, playerid, giveplayerid))
  130. {
  131. SendClientMessageEx(playerid, COLOR_GREY, "That person isn't near you.");
  132. return 1;
  133. }
  134. PlayerInfo[playerid][pTokens] -= amount;
  135. PlayerInfo[giveplayerid][pTokens] += amount;
  136. format(string, sizeof(string), "You have received %d Tokens from %s.", amount, GetPlayerNameEx(playerid));
  137. SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
  138. format(string, sizeof(string), "You have given %s %d Tokens.", GetPlayerNameEx(giveplayerid), amount);
  139. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
  140. format(string, sizeof(string), "* %s has given %s some Tokens.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
  141. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  142. }
  143. else
  144. {
  145. SendClientMessageEx(playerid, COLOR_GRAD1, "You do not have that many tokens!");
  146. }
  147. }
  148. else
  149. {
  150. SendClientMessageEx(playerid, COLOR_GRAD1, "That person is not a VIP!");
  151. }
  152. }
  153. }
  154. else
  155. {
  156. SendClientMessageEx(playerid, COLOR_GRAD1, "You are not a VIP!");
  157. }
  158. return 1;
  159. }
  160. CMD:settoken(playerid, params[])
  161. {
  162. if (PlayerInfo[playerid][pAdmin] >= 1337)
  163. {
  164. new string[128], giveplayerid, amount;
  165. if(sscanf(params, "ud", giveplayerid, amount)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /settoken [player] [amount]");
  166. if(IsPlayerConnected(giveplayerid))
  167. {
  168. PlayerInfo[giveplayerid][pTokens] = amount;
  169. format(string, sizeof(string), "You have set %s's tokens to %d !",GetPlayerNameEx(giveplayerid),amount);
  170. SendClientMessageEx(playerid, COLOR_WHITE, string);
  171. format(string, sizeof(string), "VIP: Admin %s has set your tokens to %d.",GetPlayerNameEx(playerid),amount);
  172. SendClientMessageEx(giveplayerid, COLOR_YELLOW, string);
  173. format(string, sizeof(string), "%s has set %s's(%d) tokens to %d.",GetPlayerNameEx(playerid),GetPlayerNameEx(giveplayerid), GetPlayerSQLId(giveplayerid), amount);
  174. Log("logs/stats.log", string);
  175. }
  176. }
  177. else
  178. {
  179. SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  180. }
  181. return 1;
  182. }
  183. CMD:givetoken(playerid, params[])
  184. {
  185. if (PlayerInfo[playerid][pAdmin] >= 1337)
  186. {
  187. new string[128], giveplayerid, amount;
  188. if(sscanf(params, "ud", giveplayerid, amount)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /givetoken [player] [amount]");
  189. if(IsPlayerConnected(giveplayerid))
  190. {
  191. PlayerInfo[giveplayerid][pTokens] += amount;
  192. format(string, sizeof(string), "You have given %s %d tokens !",GetPlayerNameEx(giveplayerid),amount);
  193. SendClientMessageEx(playerid, COLOR_WHITE, string);
  194. format(string, sizeof(string), "VIP: Admin %s has given you %d tokens.",GetPlayerNameEx(playerid),amount);
  195. SendClientMessageEx(giveplayerid, COLOR_YELLOW, string);
  196. format(string, sizeof(string), "%s has given %s(%d) %d tokens.",GetPlayerNameEx(playerid),GetPlayerNameEx(giveplayerid), GetPlayerSQLId(giveplayerid), amount);
  197. Log("logs/stats.log", string);
  198. }
  199. }
  200. else
  201. {
  202. SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  203. }
  204. return 1;
  205. }