SA-MP Forums Archive
Money Bug - 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)
+--- Thread: Money Bug (/showthread.php?tid=352574)



Money Bug - Dark Crow - 20.06.2012

The problem is when a player recieves money from a job or an Admin when the player buys something he goes into minus. Example The player has 20000$ he buys something and goes -20000$ anyone know a way to fix this?


Re: Money Bug - Mimic - 20.06.2012

Can you show us the code please. Make sure if you are using:

pawn Код:
GivePlayerMoney(playerid, 20000);
That you are not doing this.

pawn Код:
GivePlayerMoney(playerid, -20000);
That will take away all of the player's money.


Re: Money Bug - iggy1 - 20.06.2012

You need to check if the player has got enough money before taking it.

pawn Код:
if( GetPlayerMoney(playerid) >= 1000 )
{
    GivePlayerMoney(playerid, -1000);//player has 1000 or more so you can take it without going negative
}
else
{
    //player cannot afford $1000
}



Re: Money Bug - Dark Crow - 20.06.2012

I am using the right one. the first one. I think the GM has a server side money system and thats the problem heres some code

Код:
#define ResetMoneyBar ResetPlayerMoney
#define UpdateMoneyBar GivePlayerMoney
Код:
//STOCKS
new Cash[MAX_PLAYERS];
stock GivePlayerCash(playerid, money)
{
    Cash[playerid] += money;
    ResetMoneyBar(playerid);//Resets Money in the original bar
    UpdateMoneyBar(playerid,Cash[playerid]);//Puts money in the original bar
    return Cash[playerid];
}
stock SetPlayerCash(playerid, money)
{
    Cash[playerid] = money;
    ResetMoneyBar(playerid);//Resets Money in the original bar
    UpdateMoneyBar(playerid,Cash[playerid]);//Puts money in the original bar
    return Cash[playerid];
}
stock ResetPlayerCash(playerid)
{
    Cash[playerid] = 0;
    ResetMoneyBar(playerid);//Resets Money in the original bar
    UpdateMoneyBar(playerid,Cash[playerid]);//Puts money in the original bar
    return Cash[playerid];
}
stock GetPlayerCash(playerid)
{
    return Cash[playerid];
}
I know its because of something like this because everything else is ok