Guest User

rob

a guest
Jul 7th, 2012
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.40 KB | None | 0 0
  1. #include a_samp
  2. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  3. //*****EDIT BELOW THIS LINE:*****
  4. //------------------------------------------------------------------------------------------------------------------------------------------------------------
  5. #define DISTANCE_BETWEEN_PLAYERS 5 //The minimum distance between players to be able to rob |
  6. #define COLOR_ROB 0x00FFFFFF //The color of the text send to the players when made a successfull rob |
  7. #define COLOR_FAIL 0x00FFFFFF //Color of the text displayed to the players when a rob has failed |
  8. #define COLOR_ERROR 0xFF0000FF //Color of the text when there is an error |
  9. #define ROB_TIME 7000 //Time between rob commands to prevent spam (in milliseconds) |
  10. //*****NO NEED TO EDIT BELOW THIS LINE:***** |
  11. //------------------------------------------------------------------------------------------------------------------------------------------------------------
  12.  
  13. new robtime[MAX_PLAYERS];
  14. new ID;
  15.  
  16.  
  17. stock Float:GetDistanceBetweenPlayers(p1,p2){
  18. new Float:x1,Float:y1,Float:z1,Float:x3,Float:y3,Float:z3;
  19. if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2)){
  20. return -1.00;
  21. }
  22. GetPlayerPos(p1,x1,y1,z1);
  23. GetPlayerPos(p2,x3,y3,z3);
  24. return floatsqroot(floatpower(floatabs(floatsub(x3,x1)),2)+floatpower(floatabs(floatsub(y3,y1)),2)+floatpower(floatabs(floatsub(z3,z1)),2));
  25. }
  26.  
  27. forward robtimer(id);
  28.  
  29. dcmd_rob(playerid, params[])
  30. {
  31. new pname[MAX_PLAYER_NAME];
  32. GetPlayerName(playerid, pname, sizeof(pname));
  33. if(!strlen(params))
  34. {
  35. SendClientMessage(playerid, COLOR_ERROR, "Correct usage: /rob [ID]");
  36. }
  37. else
  38. {
  39. ID = strval(params);
  40. if(robtime[playerid] == 0)
  41. {
  42. if(ID != playerid)
  43. {
  44. if(IsPlayerConnected(ID))
  45. {
  46. new oname[MAX_PLAYER_NAME];
  47. GetPlayerName(ID, oname, sizeof(oname));
  48. if(GetDistanceBetweenPlayers(playerid, ID) <= DISTANCE_BETWEEN_PLAYERS)
  49. {
  50. if(!GetPlayerVehicleID(ID) || GetPlayerVehicleID(ID) == GetPlayerVehicleID(ID))
  51. {
  52. if(GetPlayerMoney(ID) > 0)
  53. {
  54. new rob = random(11);
  55. if(rob == 1 || rob == 2 || rob == 10 || rob == 11)
  56. {
  57. new string[256];
  58. format(string, sizeof(string), "%s (%i) noticed you trying to rob him. Attempt failed!",oname, ID);
  59. SendClientMessage(playerid, COLOR_ROB, string);
  60. format(string, sizeof(string), "~w~%s Noticed you trying to rob him.~n~Attempt failed!.",oname, ID);
  61. GameTextForPlayer(playerid, string, 5000, 4);
  62. GetPlayerName(playerid,pname,sizeof(pname));
  63. format(string, sizeof(string), "You noticed %s (%i) trying to rob you. His attempt has failed!", pname, playerid);
  64. SendClientMessage(ID, COLOR_ROB, string);
  65. format(string, sizeof(string), "~w~You noticed %s trying to rob you.~n~His attempt has failed!", pname, playerid);
  66. GameTextForPlayer(ID, string, 5000, 4);
  67. }
  68. else if(rob == 3)
  69. {
  70. new pcash = GetPlayerMoney(ID);
  71. new robcash = random(pcash);
  72. GivePlayerMoney(ID, -robcash);
  73. GivePlayerMoney(playerid, robcash);
  74. GetPlayerName(playerid, pname, sizeof(pname));
  75. new string[256];
  76. format(string, sizeof(string), "You have robbed $%i from %s (%i).", robcash, oname, ID);
  77. SendClientMessage(playerid, COLOR_ROB, string);
  78. format(string, sizeof(string), "~w~Robbed $%i from %s.", robcash, oname);
  79. GameTextForPlayer(playerid, string, 5000, 4);
  80. format(string, sizeof(string), "%s (%i) has robbed $%i from you.", pname, playerid, robcash);
  81. SendClientMessage(ID, COLOR_ROB, string);
  82. format(string, sizeof(string), "~w~%s has robbed $%i from you.", pname, robcash);
  83. GameTextForPlayer(ID, string, 5000, 4);
  84. }
  85. else if(rob == 4 || rob == 5 || rob == 8)
  86. {
  87. new pcash = GetPlayerMoney(ID);
  88. new robcash = random(pcash);
  89. new robcash2 = robcash-random(robcash);
  90. GivePlayerMoney(ID, -robcash2);
  91. GivePlayerMoney(playerid, robcash2);
  92. new string[256];
  93. GetPlayerName(playerid, pname, sizeof(pname));
  94. format(string, sizeof(string), "You have robbed $%i from %s (%i).", robcash2, oname, ID);
  95. SendClientMessage(playerid, COLOR_ROB, string);
  96. format(string, sizeof(string), "~w~Robbed $%i from %s.", robcash2, oname);
  97. GameTextForPlayer(playerid, string, 5000, 4);
  98. format(string, sizeof(string), "%s (%i) has robbed $%i from you.", pname, playerid, robcash2);
  99. SendClientMessage(ID, COLOR_ROB, string);
  100. format(string, sizeof(string), "~w~%s has robbed $%i from you.", pname, robcash2);
  101. GameTextForPlayer(ID, string, 5000, 4);
  102. }
  103. else if(rob == 6 || rob == 7)
  104. {
  105. new pcash = GetPlayerMoney(ID);
  106. new robcash = random(pcash);
  107. new robcash2 = robcash-random(robcash);
  108. new robcash3 = robcash2-random(robcash2);
  109. GivePlayerMoney(ID, -robcash3);
  110. GivePlayerMoney(playerid, robcash3);
  111. new string[256];
  112. GetPlayerName(playerid, pname, sizeof(pname));
  113. format(string, sizeof(string), "You have robbed $%i from %s (%i).", robcash3, oname, ID);
  114. SendClientMessage(playerid, COLOR_ROB, string);
  115. format(string, sizeof(string), "%s (%i) has robbed $%i from you.", pname, playerid, robcash3);
  116. SendClientMessage(ID, COLOR_ROB, string);
  117. format(string, sizeof(string), "~w~Robbed $%i from %s.", robcash3, oname);
  118. GameTextForPlayer(playerid, string, 5000, 4);
  119. format(string, sizeof(string), "~w~%s has robbed $%i from you.", pname, robcash3);
  120. GameTextForPlayer(ID, string, 5000, 4);
  121. }
  122. else
  123. {
  124. SetPlayerHealth(playerid, -69);
  125. new string[256];
  126. GetPlayerName(playerid, pname, sizeof(pname));
  127. format(string, sizeof(string), "Your hand has stuck to %s (%i)'s pocket. ", oname, ID);
  128. SendClientMessage(playerid, COLOR_FAIL, string);
  129. SendClientMessage(playerid, COLOR_FAIL, "He noticed it and ripped your arms off.");
  130. format(string, sizeof(string), "%s (%i)'s hand has stuck to your pocket while trying to rob you.", pname, playerid);
  131. SendClientMessage(ID, COLOR_FAIL, string);
  132. SendClientMessage(ID, COLOR_FAIL, "You noticed it and ripped his arms off.");
  133. format(string, sizeof(string), "*** %s (%i) has bled to death.", pname, playerid);
  134. SendClientMessageToAll(0x880000FF, string);
  135. format(string, sizeof(string), "~w~%s has ripped your arms off.", oname, ID);
  136. GameTextForPlayer(playerid, string, 5000, 4);
  137. format(string, sizeof(string), "~w~Ripped %s's arms off.", oname, ID);
  138. GameTextForPlayer(ID, string, 5000, 4);
  139. }
  140. robtime[playerid] = 1;
  141. SetTimerEx("robtimer", ROB_TIME, false, "i", playerid);
  142. }
  143. else
  144. {
  145. new string[256];
  146. format(string, sizeof(string), "%s (%i) has no money to rob!", oname, ID);
  147. SendClientMessage(playerid, COLOR_ERROR, string);
  148. }
  149. }
  150. else
  151. {
  152. new string[256];
  153. format(string, sizeof(string), "%s (%i) has to be in the same vehicle as you to be able to rob!", oname, ID);
  154. SendClientMessage(playerid, COLOR_ERROR, string);
  155. }
  156. }
  157. else
  158. {
  159. new string[256];
  160. format(string, sizeof(string), "%s (%i) is not close enough to rob.", oname, ID);
  161. SendClientMessage(playerid, COLOR_ERROR, string);
  162. }
  163. }
  164. else
  165. {
  166. SendClientMessage(playerid, COLOR_ERROR, "That player is not connected!");
  167. }
  168. }
  169. else
  170. {
  171. SendClientMessage(playerid, COLOR_ERROR, "You cannot rob yourself!");
  172. }
  173. }
  174. else
  175. {
  176. SendClientMessage(playerid, COLOR_ERROR, "Please wait before robbing someone again.");
  177. }
  178. }
  179. return 1;
  180. }
  181.  
  182. public OnPlayerCommandText(playerid, cmdtext[])
  183. {
  184. dcmd(rob, 3, cmdtext);
  185. return 0;
  186. }
  187. public robtimer(id)
  188. {
  189. robtime[id] = 0;
  190. }
Advertisement
Add Comment
Please, Sign In to add comment