30.12.2010, 18:22
I'm having a weired problem.
Like i want it to give random money of the robbed person.
Imagine the robbed person has 250$ and i want to robber just to get random money from 250.
or imagine the robbed person has 500 i want the robber to have random money from 500 like 450 235
but its giving the robber alot of cash
Like i want it to give random money of the robbed person.
Imagine the robbed person has 250$ and i want to robber just to get random money from 250.
or imagine the robbed person has 500 i want the robber to have random money from 500 like 450 235
but its giving the robber alot of cash
pawn Код:
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;
}