Guest User

Untitled

a guest
Feb 10th, 2012
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. //Uhmazin GiveCash Money Script
  2.  
  3. #include <a_samp>
  4. #include <core>
  5. #include <float>
  6. #define COLOR_GREY 0xAFAFAFAA
  7. #define COLOR_GREEN 0x33AA33AA
  8. #define COLOR_RED 0xAA3333AA
  9. #define COLOR_YELLOW 0xFFFF00AA
  10. #define COLOR_WHITE 0xFFFFFFAA
  11. #define PocketMoney 1000 // Amount player recieves on spawn.
  12. #define INACTIVE_PLAYER_ID 255
  13. #define GIVECASH_DELAY 1000 // Time in ms between /givecash commands.
  14. #if defined FILTERSCRIPT
  15. #define NUMVALUES 4
  16. forward Givecashdelaytimer(playerid);
  17. forward SetupPlayerForClassSelection(playerid);
  18. forward SendPlayerFormattedText(playerid, const str[], define);
  19. forward public SendAllFormattedText(playerid, const str[], define);
  20.  
  21. public OnFilterScriptInir()
  22. {
  23. print("\n--------------------------------------");
  24. print("Uhmazin Givecash Filterscript!!");
  25.  
  26. return 1;
  27. }
  28.  
  29. public OnFilterScriptExit()
  30. {
  31. return 1;
  32. }
  33.  
  34. #else
  35.  
  36. main()
  37. {
  38. }
  39.  
  40. #endif
  41.  
  42. public OnGameModeInit()
  43. {
  44. return 1;
  45. }
  46.  
  47. public OnGameModeExit()
  48. {
  49. return 1;
  50. }
  51.  
  52. public OnPlayerRequestClass(playerid, classid)
  53. {
  54. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  55. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  56. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  57. return 1;
  58. }
  59.  
  60. public OnPlayerConnect(playerid)
  61. {
  62. return 1;
  63. }
  64.  
  65. public OnPlayerDisconnect(playerid, reason)
  66. {
  67. return 1;
  68. }
  69. public OnPlayerCommandText(playerid, cmdtext[])
  70. {
  71. new string[256];
  72. new playermoney;
  73. new sendername[MAX_PLAYER_NAME];
  74. new giveplayer[MAX_PLAYER_NAME];
  75. new cmd[256];
  76. new giveplayerid, moneys, idx;
  77.  
  78. cmd = strtok(cmdtext, idx);
  79.  
  80. if(strcmp(cmd, "/gc", true) == 0) {
  81. new tmp[256];
  82. tmp = strtok(cmdtext, idx);
  83.  
  84. if(!strlen(tmp)) {
  85. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gc [playerid] [amount]");
  86. return 1;
  87. }
  88. giveplayerid = strval(tmp);
  89.  
  90. tmp = strtok(cmdtext, idx);
  91. if(!strlen(tmp)) {
  92. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gc [playerid] [amount]");
  93. return 1;
  94. }
  95. moneys = strval(tmp);
  96.  
  97. //printf("givecash_command: %d %d",giveplayerid,moneys);
  98.  
  99.  
  100. if (IsPlayerConnected(giveplayerid)) {
  101. GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
  102. GetPlayerName(playerid, sendername, sizeof(sendername));
  103. playermoney = GetPlayerMoney(playerid);
  104. if (moneys > 0 && playermoney >= moneys) {
  105. GivePlayerMoney(playerid, (0 - moneys));
  106. GivePlayerMoney(giveplayerid, moneys);
  107. format(string, sizeof(string), "You have sent %s(player: %d), $%d.", giveplayer,giveplayerid, moneys);
  108. SendClientMessage(playerid, COLOR_YELLOW, string);
  109. format(string, sizeof(string), "You have recieved $%d from %s(player: %d).", moneys, sendername, playerid);
  110. SendClientMessage(giveplayerid, COLOR_YELLOW, string);
  111. printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
  112. }
  113. else {
  114. SendClientMessage(playerid, COLOR_YELLOW, "Not Enough Cash!.");
  115. }
  116. }
  117. else {
  118. format(string, sizeof(string), "%d is not an active player.", giveplayerid);
  119. SendClientMessage(playerid, COLOR_YELLOW, string);
  120. }
  121. return 1;
  122. }
  123.  
  124.  
  125. return 0;
  126. }
  127. strtok(const string[], &index)
  128. {
  129. new length = strlen(string);
  130. while ((index < length) && (string[index] <= ' '))
  131. {
  132. index++;
  133. }
  134.  
  135. new offset = index;
  136. new result[20];
  137. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  138. {
  139. result[index - offset] = string[index];
  140. index++;
  141. }
  142. result[index - offset] = EOS;
  143. return result;
  144. }
Advertisement
Add Comment
Please, Sign In to add comment