20.06.2012, 11:24
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?
GivePlayerMoney(playerid, 20000);
GivePlayerMoney(playerid, -20000);
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
}
#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]; }