SA-MP Forums Archive
Money problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Money problem (/showthread.php?tid=204870)



Money problem - Tessar - 30.12.2010

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
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;
}



Re: Money problem - Infamous - 30.12.2010

You are randomizing the money the player already has.


Re: Money problem - Tessar - 30.12.2010

Quote:
Originally Posted by Infamous
Посмотреть сообщение
You are randomizing the money the player already has.
i want to random the money the the robbed player has, so that random money will go to the robber.


Re: Money problem - Infamous - 30.12.2010

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.


Re: Money problem - Tessar - 30.12.2010

Quote:
Originally Posted by Infamous
Посмотреть сообщение
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.
But that doesn't make it real :/.


Re: Money problem - MadeMan - 30.12.2010

pawn Код:
if(GetPlayerMoney(id) > 0) robbedcash = random(GetPlayerMoney(id));
else robbedcash = 0;



Re: Money problem - Tessar - 31.12.2010

Thank you all for helping me. I manged to fix this.