Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CMD:rob(playerid, params[])
- {
- new pID, string[128];
- new Float:x, Float:y, Float:z; //Position & Float Variables.
- new Name[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME]; //Name Variables.
- new pMoney, RobAmount; //Money Variables.
- if(sscanf(params, "u", pID)) return SendClientMessage(playerid, -1, "USAGE: /rob (Username/ID)"); //On execution without specified params.
- if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, -1, "ERROR: That player is not connected to the server."); //Checks if pID is connected to the server.
- if(pID == playerid) return SendClientMessage(playerid, -1, "You cannot rob yourself.");
- GetPlayerName(playerid, Name, sizeof(Name)); //Get Playerid's Name.
- GetPlayerName(pID, pName, sizeof(pName)); //Get pID's Name.
- GetPlayerPos(pID, x, y, z); //Get pID's Position.
- pMoney = GetPlayerMoney(pID); //Get pID's Money.
- if(!IsPlayerInRangeOfPoint(playerid, 10.0, x, y, z)) //Checks if playerid is not in range of pID (radius = 10.0).
- {
- format(string, sizeof(string), "%s is not close enough to rob.", pName);
- return SendClientMessage(playerid, -1, string);
- }
- if(pMoney <= 0) //Checks if pID's money is 0 or less.
- {
- format(string, sizeof(string), "%s has no money to rob.", pName);
- return SendClientMessage(playerid, -1, string);
- }
- 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 :)
- switch(random(8))
- {
- case 1: RobAmount = pMoney/2; //Divide pID's money by 2.
- case 2: RobAmount = pMoney/3; //Divide pID's money by 3.
- case 3: RobAmount = pMoney/4; //Divide pID's money by 4.
- case 4: RobAmount = pMoney/5; //Divide pID's money by 5.
- case 5: RobAmount = pMoney/8; //Divide pID's money by 8.
- case 6: RobAmount = pMoney/10; //Divide pID's money by 10.
- case 7: RobAmount = pMoney/20; //Divide pID's money by 20.
- case 8: RobAmount = pMoney/50; //Divide pID's money by 50.
- }
- GivePlayerMoney(playerid, RobAmount);
- GivePlayerMoney(pID, -RobAmount);
- format(string, sizeof(string), "You stole $%d from %s.", RobAmount, pName);
- SendClientMessage(pID, -1, string);
- format(string, sizeof(string), "%s stole $%d from you.", Name, RobAmount);
- SendClientMessage(playerid, -1, string);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement