Advertisement
Guest User

Untitled

a guest
Sep 9th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. CMD:rob(playerid, params[])
  2. {
  3. new pID, string[128];
  4. new Float:x, Float:y, Float:z; //Position & Float Variables.
  5. new Name[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME]; //Name Variables.
  6. new pMoney, RobAmount; //Money Variables.
  7.  
  8. if(sscanf(params, "u", pID)) return SendClientMessage(playerid, -1, "USAGE: /rob (Username/ID)"); //On execution without specified params.
  9. if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, -1, "ERROR: That player is not connected to the server."); //Checks if pID is connected to the server.
  10. if(pID == playerid) return SendClientMessage(playerid, -1, "You cannot rob yourself.");
  11.  
  12. GetPlayerName(playerid, Name, sizeof(Name)); //Get Playerid's Name.
  13. GetPlayerName(pID, pName, sizeof(pName)); //Get pID's Name.
  14.  
  15. GetPlayerPos(pID, x, y, z); //Get pID's Position.
  16.  
  17. pMoney = GetPlayerMoney(pID); //Get pID's Money.
  18.  
  19. if(!IsPlayerInRangeOfPoint(playerid, 10.0, x, y, z)) //Checks if playerid is not in range of pID (radius = 10.0).
  20. {
  21. format(string, sizeof(string), "%s is not close enough to rob.", pName);
  22. return SendClientMessage(playerid, -1, string);
  23. }
  24.  
  25. if(pMoney <= 0) //Checks if pID's money is 0 or less.
  26. {
  27. format(string, sizeof(string), "%s has no money to rob.", pName);
  28. return SendClientMessage(playerid, -1, string);
  29. }
  30.  
  31. if(pMoney > 100000) pMoney = 100000; //Checks if pID's money is more than $100,000 it is gonna set pMoney variable to $100,000 for safety purposes :)
  32.  
  33. switch(random(8))
  34. {
  35. case 1: RobAmount = pMoney/2; //Divide pID's money by 2.
  36. case 2: RobAmount = pMoney/3; //Divide pID's money by 3.
  37. case 3: RobAmount = pMoney/4; //Divide pID's money by 4.
  38. case 4: RobAmount = pMoney/5; //Divide pID's money by 5.
  39. case 5: RobAmount = pMoney/8; //Divide pID's money by 8.
  40. case 6: RobAmount = pMoney/10; //Divide pID's money by 10.
  41. case 7: RobAmount = pMoney/20; //Divide pID's money by 20.
  42. case 8: RobAmount = pMoney/50; //Divide pID's money by 50.
  43. }
  44.  
  45. GivePlayerMoney(playerid, RobAmount);
  46. GivePlayerMoney(pID, -RobAmount);
  47.  
  48. format(string, sizeof(string), "You stole $%d from %s.", RobAmount, pName);
  49. SendClientMessage(pID, -1, string);
  50. format(string, sizeof(string), "%s stole $%d from you.", Name, RobAmount);
  51. SendClientMessage(playerid, -1, string);
  52. return 1;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement