Money problem
#1

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;
}
Reply
#2

You are randomizing the money the player already has.
Reply
#3

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.
Reply
#4

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.
Reply
#5

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 :/.
Reply
#6

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)