10.07.2015, 14:03
PHP Code:
GiveMoney(playerid, amount)
{
pInfo[playerid][pMoney] += amount;
GivePlayerMoney(playerid, amount);
return 1;
}
GiveMoney(playerid, amount)
{
pInfo[playerid][pMoney] += amount;
GivePlayerMoney(playerid, amount);
return 1;
}
/* 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;
}
if player spawn:GivePlayerCash(playerid, playerVariables[playerid][pCash]);
If he buy something: GivePlayerCash(playerid,-500);
If he get money: GivePlayerCash(playerid, 500);