dcmd_rob(playerid,params[])
{
new string[128], string2[128], string3[128], string4[128],robbedcash, robbedname[MAX_PLAYER_NAME], robbername[MAX_PLAYER_NAME],id,Float: x,Float: y,Float: z;
if(team[playerid] == COP) return SCM(playerid,red,"Error: Cops can't rob");
if(sscanf(params,"u",id)) return SCM(playerid,orange,"USAGE: /rob [playerid]");
GetPlayerPos(id,x,y,z);
GetPlayerName(playerid, robbername, sizeof(robbername));
GetPlayerName(id, robbedname, sizeof(robbedname));
format(string4,sizeof(string4),"Error: You arn't near %s",robbedname);
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,red,"Error: That id isn't connected");
if(!IsPlayerInRangeOfPoint(playerid,6.0,x,y,z)) return SendClientMessage(playerid,red,string4);
if(IsPlayerInAnyVehicle(playerid)) return SCM(playerid,red,"Error: You are in a vehicle");
if(IsPlayerInAnyVehicle(id)) return SCM(playerid,red,"Error: That player is in a vehicle");
robbedcash = random(GetPlayerMoney(id));
format(string, sizeof(string), "You have robbed $%d from %s[ID:%d]", robbedcash, robbedname, id);
SendClientMessage(playerid, yellow, string);
format(string2, sizeof(string2), "%s[ID:%d] has robbed %d$ from you!", robbername, playerid, robbedcash);
SendClientMessage(id, red, string2);
format(string3, sizeof(string3), "[RADIO]%s has robbed %d$ from %s.", robbername, robbedcash,robbedname);
SendRadioMessageToCops(string3);
GivePlayerMoney(playerid, robbedcash);
GivePlayerMoney(id, -robbedcash);
GivePlayerScore(playerid, 1);
return 1;
}
Why don't you set a total amount say 50k and then check it back to whether the player has enough cash to supply that amount. If not then return a smaller value.
|
if(GetPlayerMoney(id) > 0) robbedcash = random(GetPlayerMoney(id));
else robbedcash = 0;