07.09.2009, 02:04
hi
from what i understand you whant to update your player cash when they get it??
if so, one way would be to create yourself a new callback like OnPlayerMoneyChange(playerid, OldMoney, NewMoney)
one way to do that is to use the evil OnPlayerUpdate callback
ie:
At top of script:
In public OnPlayerUpdate(playerid):
if you dont have onplayerupdate simply ad it.
Any where in script or at the end:
I hope you already know how to save your data
also you probably dont need to know exactly when the money changed so you might not need to use onplayerupdate. if you decide to use this you might wanna read this https://sampwiki.blast.hk/wiki/OnPlayerUpdate
from what i understand you whant to update your player cash when they get it??
if so, one way would be to create yourself a new callback like OnPlayerMoneyChange(playerid, OldMoney, NewMoney)
one way to do that is to use the evil OnPlayerUpdate callback
ie:
At top of script:
pawn Код:
new ActiveMoney[MAX_PLAYERS];// reset this to zero at onplayerexit...
pawn Код:
public OnPlayerUpdate(playerid)
{
new CurMoney = GetPlayerMoney(playerid);
if(CurMoney != ActiveMoney[playerid]) OnPlayerMoneyChange(playerid, ActiveMoney[playerid], CurMoney);
return 1;
}
Any where in script or at the end:
pawn Код:
forward OnPlayerMoneyChange(playerid, OldMoney, NewMoney);
public OnPlayerMoneyChange(playerid, OldMoney, NewMoney)
{
// this is your new callback, its called every time a player change money.
//the current player money is NewMoney...
//the money he had before is OldMoney...
printf("player: %i as change money from: %i to: %i",playerid, OldMoney, NewMoney);
//we print the info, just for shit and giggle...
ActiveMoney[playerid] = NewMoney;// we save our current active money...
//you can save your data here using NewMoney or ActiveMoney[playerid]
return 1;
}
also you probably dont need to know exactly when the money changed so you might not need to use onplayerupdate. if you decide to use this you might wanna read this https://sampwiki.blast.hk/wiki/OnPlayerUpdate