Advertisement
Guest User

Untitled

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