Advertisement
Guest User

Coins System

a guest
Jun 21st, 2011
1,247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.76 KB | None | 0 0
  1. #if defined Coins SYStem
  2. ______________________________________________________________________________
  3. | |]SPEED[|'s Productions Present:D |
  4. | xxSPEEDYxx's Coins System - Gold Coins, Silver Coins, Bronze Coins |
  5. | v1.0 |
  6. |v1.0 [initial relase] |
  7. | --> Foloseste /coinshelp pentru a vedea comenzile cu coins |
  8. | |
  9. |!!!Va rog nu stergeti creditele!!! |
  10. |_____________________________________________________________________________|
  11. #endif
  12.  
  13. #include < a_samp >
  14. #include < dini >
  15. #include < zcmd >
  16. #include < sscanf >
  17.  
  18. #define PlayerFile "Coins/%s.ini"
  19.  
  20. #define MyCoins (12000)
  21. #define CH (12001)
  22.  
  23. #define BOX (DIALOG_STYLE_MSGBOX)
  24.  
  25. #define RED (0xE60000AA)
  26. #define GREEN (0x8CE46CAA)
  27. #define YELLOW (0xFFFF00AA)
  28. #define BLUE (0x0000BBAA)
  29.  
  30. #pragma tabsize 0
  31.  
  32. enum PLAYER_COINS
  33. {
  34. GoldCoins,
  35. SilverCoins,
  36. BronzeCoins
  37. };
  38. new giveplayerid, amount1, amount2, amount3;
  39. new PlayerInfo[MAX_PLAYERS][PLAYER_COINS];
  40. new sstring[ 256 ];
  41. new Global_Name[MAX_PLAYER_NAME];
  42.  
  43. public OnPlayerConnect(playerid)
  44. {
  45. new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
  46. if(!dini_Exists(file)) {
  47. dini_Create(file);
  48. dini_IntSet(file,"GoldCoins:", PlayerInfo[playerid][GoldCoins]);
  49. dini_IntSet(file,"SilverCoins:", PlayerInfo[playerid][SilverCoins]);
  50. dini_IntSet(file,"BronzeCoins:", PlayerInfo[playerid][BronzeCoins]);
  51. }
  52. PlayerInfo[playerid][GoldCoins] = dini_Int(file,"GoldCoins:");
  53. PlayerInfo[playerid][SilverCoins] = dini_Int(file,"SilverCoins:");
  54. PlayerInfo[playerid][BronzeCoins] = dini_Int(file,"BronzeCoins:");
  55. return 1;
  56. }
  57.  
  58. public OnPlayerDisconnect(playerid, reason)
  59. {
  60. new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
  61. dini_IntSet(file,"GoldCoins:", PlayerInfo[playerid][GoldCoins]);
  62. dini_IntSet(file,"SilverCoins:", PlayerInfo[playerid][SilverCoins]);
  63. dini_IntSet(file,"BronzeCoins:", PlayerInfo[playerid][BronzeCoins]);
  64. return 1;
  65. }
  66.  
  67. CMD:coinshelp(playerid, params[])
  68. {
  69. new str[ 256 ];
  70. strcat(str,"Use /givegcoins for give gold coins to a player!");
  71. strcat(str,"Use /givescoins for give silver coins to a player!");
  72. strcat(str,"Use /givebcoins for give bronze coins to a player!");
  73. strcat(str,"Use /setgcoins (only for admins) for set gold coins to a player.");
  74. strcat(str,"Use /setscoins (only for admins) for set silver coins to a player.");
  75. strcat(str,"Use /setbcoins (only for admins) for set bronze coins to a player.");
  76. strcat(str,"Use /mycoins for see your amount of: Gold,Silver,Bronze coins.");
  77. strcat(str,"Use /coinshelp for see the coins commands!");
  78. ShowPlayerDialog(playerid, CH, BOX, "xxSPEEDYxx's Coins SYstem",str,"Quit","");
  79. return 1;
  80. }
  81. CMD:givegcoins(playerid, params[])
  82. {
  83. if(sscanf(params, "ud", giveplayerid, amount1)) return SendClientMessage(playerid, RED, "USAGE: /givegcoins [playerid] [Gold Coins]");
  84. if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED, "ERROR: That player is not connected!");
  85. if(giveplayerid == playerid) return SendClientMessage(playerid, RED, "ERROR: You cant send yourself coins!");
  86. if(amount1 > PlayerInfo[playerid][GoldCoins]) return SendClientMessage(playerid, RED, "ERROR: You dont have that amount of gold coins!");
  87.  
  88. new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(giveplayerid, Global_Name, sizeof(Global_Name));GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
  89. format(sstring, sizeof(sstring), "You have succesfully sent %d gold coins to %s(%d)!", amount1, Global_Name, playerid);
  90. SendClientMessage(playerid, YELLOW, sstring);
  91. format(sstring, sizeof(sstring), "%s(%d) has given to you %d amount of gold coins!", Name, playerid, amount1);
  92. SendClientMessage(giveplayerid, YELLOW, sstring);
  93. PlayerInfo[giveplayerid][GoldCoins] += amount1;
  94. PlayerInfo[playerid][GoldCoins] -= amount1;
  95. dini_IntSet(file,"GoldCoins:", PlayerInfo[giveplayerid][GoldCoins]);
  96. dini_IntSet(file,"GoldCoins:", PlayerInfo[playerid][GoldCoins]);
  97. return 1;
  98. }
  99. CMD:givescoins(playerid, params[])
  100. {
  101. if(sscanf(params, "ud", giveplayerid, amount2)) return SendClientMessage(playerid, RED, "USAGE: /givescoins [playerid] [Silver Coins]");
  102. if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED, "ERROR: That player is not connected!");
  103. if(giveplayerid == playerid) return SendClientMessage(playerid, RED, "ERROR: You cant send yourself coins!");
  104. if(amount2 > PlayerInfo[playerid][SilverCoins]) return SendClientMessage(playerid, RED, "ERROR: You dont have that amount of silver coins!");
  105.  
  106. new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(giveplayerid, Global_Name, sizeof(Global_Name));GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
  107. format(sstring, sizeof(sstring), "You have succesfully sent %d gold coins to %s(%d)!", amount2, Global_Name, playerid);
  108. SendClientMessage(playerid, YELLOW, sstring);
  109. format(sstring, sizeof(sstring), "%s(%d) has given to you %d amount of gold coins!", Name, playerid, amount2);
  110. SendClientMessage(giveplayerid, YELLOW, sstring);
  111. PlayerInfo[giveplayerid][SilverCoins] += amount2;
  112. PlayerInfo[playerid][SilverCoins] -= amount2;
  113. dini_IntSet(file,"SilverCoins:", PlayerInfo[giveplayerid][SilverCoins]);
  114. dini_IntSet(file,"SilverCoins:", PlayerInfo[playerid][SilverCoins]);
  115. return 1;
  116. }
  117. CMD:givebcoins(playerid, params[])
  118. {
  119. if(sscanf(params, "ud", giveplayerid, amount3)) return SendClientMessage(playerid, RED, "USAGE: /giveboins [playerid] [Bronze Coins]");
  120. if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED, "ERROR: That player is not connected!");
  121. if(giveplayerid == playerid) return SendClientMessage(playerid, RED, "ERROR: You cant send yourself coins!");
  122. if(amount2 > PlayerInfo[playerid][GoldCoins]) return SendClientMessage(playerid, RED, "ERROR: You dont have that amount of gold coins!");
  123.  
  124. new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(giveplayerid, Global_Name, sizeof(Global_Name));GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
  125. format(sstring, sizeof(sstring), "You have succesfully sent %d bronze coins to %s(%d)!", amount3, Global_Name, playerid);
  126. SendClientMessage(playerid, YELLOW, sstring);
  127. format(sstring, sizeof(sstring), "%s(%d) has given to you %d amount of bronze coins!", Name, playerid, amount3);
  128. SendClientMessage(giveplayerid, YELLOW, sstring);
  129. PlayerInfo[giveplayerid][BronzeCoins] += amount3;
  130. PlayerInfo[playerid][BronzeCoins] -= amount3;
  131. dini_IntSet(file,"BronzeCoins:", PlayerInfo[giveplayerid][BronzeCoins]);
  132. dini_IntSet(file,"BronzeCoins:", PlayerInfo[playerid][BronzeCoins]);
  133. return 1;
  134. }
  135. CMD:mycoins(playerid, params[])
  136. {
  137. format(sstring, sizeof(sstring), "\tHi, %s i will show you your amount of coins!\n\nYou Have: %d Gold Coins!\nYou Have: %d Silver Coins!\nYou Have: %d Bronze Coins!", Global_Name, PlayerInfo[playerid][GoldCoins], PlayerInfo[playerid][SilverCoins], PlayerInfo[playerid][BronzeCoins]);
  138. ShowPlayerDialog(playerid, MyCoins, BOX,"Info Coins",sstring,"Quit","");
  139. return 1;
  140. }
  141. CMD:setgcoins(playerid, params[])
  142. {
  143. if(IsPlayerAdmin(playerid) == 0) return SendClientMessage(playerid, RED, "ERROR: Only admins can use that command!");
  144. if(sscanf(params, "ud", giveplayerid, amount1)) return SendClientMessage(playerid, RED, "USAGE: /givecoins [playerid] [Gold Coins]");
  145. if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED, "ERROR: That player is not connected!");
  146.  
  147. new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(giveplayerid, Global_Name, sizeof(Global_Name));GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
  148. format(sstring, sizeof(sstring), "You have succesfully setted %s gold coins to %d!", Global_Name, amount1);
  149. SendClientMessage(playerid, BLUE, sstring);
  150. format(sstring, sizeof(sstring), "Admin %s has setted your gold coins to %d!", Name, amount1);
  151. SendClientMessage(giveplayerid, BLUE, sstring);
  152. PlayerInfo[giveplayerid][GoldCoins] = amount1;
  153. dini_IntSet(file,"GoldCoins:", PlayerInfo[giveplayerid][GoldCoins]);
  154. return 1;
  155. }
  156. CMD:setscoins(playerid, params[])
  157. {
  158. if(IsPlayerAdmin(playerid) == 0) return SendClientMessage(playerid, RED, "ERROR: Only admins can use that command!");
  159. if(sscanf(params, "ud", giveplayerid, amount1)) return SendClientMessage(playerid, RED, "USAGE: /givecoins [playerid] [Silver Coins]");
  160. if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED, "ERROR: That player is not connected!");
  161.  
  162. new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(giveplayerid, Global_Name, sizeof(Global_Name));GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
  163. format(sstring, sizeof(sstring), "You have succesfully setted %s silver coins to %d!", Global_Name, amount2);
  164. SendClientMessage(playerid, BLUE, sstring);
  165. format(sstring, sizeof(sstring), "Admin %s has setted your silver coins to %d!", Name, amount2);
  166. SendClientMessage(giveplayerid, BLUE, sstring);
  167. PlayerInfo[giveplayerid][SilverCoins] = amount2;
  168. dini_IntSet(file,"SilverCoins:", PlayerInfo[giveplayerid][SilverCoins]);
  169. return 1;
  170. }
  171. CMD:setbcoins(playerid, params[])
  172. {
  173. if(IsPlayerAdmin(playerid) == 0) return SendClientMessage(playerid, RED, "ERROR: Only admins can use that command!");
  174. if(sscanf(params, "ud", giveplayerid, amount1)) return SendClientMessage(playerid, RED, "USAGE: /givecoins [playerid] [Bronze Coins]");
  175. if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED, "ERROR: That player is not connected!");
  176.  
  177. new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(giveplayerid, Global_Name, sizeof(Global_Name));GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
  178. format(sstring, sizeof(sstring), "You have succesfully setted %s coins to %d!", Global_Name, amount3);
  179. SendClientMessage(playerid, BLUE, sstring);
  180. format(sstring, sizeof(sstring), "Admin %s has setted your bronze coins to %d!", Name, amount3);
  181. SendClientMessage(giveplayerid, BLUE, sstring);
  182. PlayerInfo[giveplayerid][GoldCoins] = amount3;
  183. dini_IntSet(file,"BronzeCoins:", PlayerInfo[giveplayerid][BronzeCoins]);
  184. return 1;
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement