10.07.2015, 14:51
Well, im doing little bit different. Im using kinda same method that everyone else use.
If i want to add or remove or give player cash then i use only one thing.
pawn Code:
/* Money defines */
#define GivePlayerCash(%0,%1) SetPVarInt(%0,"Money",GetPlayerCash(%0)+%1),GivePlayerMoney(%0,%1)
#define ResetPlayerCash(%0) SetPVarInt(%0,"Money",0), ResetPlayerMoney(%0)
#define GetPlayerCash(%0) GetPVarInt(%0,"Money")
public OnPlayerUpdate(playerid) {
if(GetPlayerCash(playerid) < GetPlayerMoney(playerid)) {
foreach(Player, i) {
new const old_money = GetPlayerCash(playerid);
ResetPlayerCash(playerid), GivePlayerCash(playerid, old_money);
}
}
return 1;
}
pawn Code:
if player spawn:GivePlayerCash(playerid, playerVariables[playerid][pCash]);
If he buy something: GivePlayerCash(playerid,-500);
If he get money: GivePlayerCash(playerid, 500);