Guest User

/rob

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