How to set a variable to GetPlayerMoney? -
ReneG - 05.02.2012
I'm trying to make
equal to
pawn Код:
GetPlayerMoney(playerid);
No matter what pInfo[playerid]pCash] is always equivalent to Zero.
This is my code.
pawn Код:
public OnPlayerConnect(playerid)
{
pInfo[playerid][pCash] += GetPlayerMoney(playerid);
return 1;
}
What is the problem?
+rep
Re: How to set a variable to GetPlayerMoney? -
Nonameman - 05.02.2012
OnPlayerConnect() happens when a player comes online, in this case he has no money, so GetPlayerMoney() returns 0.
Re: How to set a variable to GetPlayerMoney? -
Tanush123 - 06.02.2012
Can't you just use GetPlayerMoney? Make the cash load from your dini/mysql/ or w/e you have, a example of dini,
pawn Код:
GivePlayerMoney(playerid,dini_Int(file,"Cash"));
when player disconnect just make the cash will save from whatever you have
pawn Код:
dini_IntSet(file,"Cash",GetPlayerMoney(playerid));
i think i made a mistake because i never used dini in a while
Re: How to set a variable to GetPlayerMoney? -
[ABK]Antonio - 06.02.2012
Hmm, wouldn't you want to do it the other way around...SetPlayerMoney(playerid, pInfo[playerid][pCash]);?
Re: How to set a variable to GetPlayerMoney? -
Bakr - 06.02.2012
Firstly, there really is no reason to ever need that variable if it is ALWAYS going to be equivalent to GetPlayerMoney, you could just use the function. However, since you would want it to be constantly updated, you would need to either put it under OnPlayerUpdate, or use it along with the GivePlayerMoney function.
pawn Код:
public OnPlayerUpdate(playerid)
{
pInfo[playerid][pCash] = GetPlayerMoney(playerid);
return 1;
}
Re: How to set a variable to GetPlayerMoney? -
Tanush123 - 06.02.2012
Quote:
Originally Posted by [ABK]Antonio
Hmm, wouldn't you want to do it the other way around...SetPlayerMoney(playerid, pInfo[playerid][pCash]);?
|
There is SetPlayerMoney? I am sure there is not, i only know there is
ResetPlayerMoney
GetPlayerMoney
GivePlayerMoney
Re: How to set a variable to GetPlayerMoney? -
[ABK]Antonio - 06.02.2012
Quote:
Originally Posted by Tanush123
There is SetPlayerMoney? I am sure there is not, i only know there is
ResetPlayerMoney
GetPlayerMoney
GivePlayerMoney
|
Right, wasn't thinkin of it lol
Now there is :P
pawn Код:
stock SetPlayerMoney(playerid, var)
{
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, var);
}
Re: How to set a variable to GetPlayerMoney? -
ReneG - 06.02.2012
Quote:
Originally Posted by Tanush123
Can't you just use GetPlayerMoney? Make the cash load from your dini/mysql/ or w/e you have, a example of dini,
pawn Код:
GivePlayerMoney(playerid,dini_Int(file,"Cash"));
when player disconnect just make the cash will save from whatever you have
pawn Код:
dini_IntSet(file,"Cash",GetPlayerMoney(playerid));
i think i made a mistake because i never used dini in a while
|
The reason I'm not doing that is because I haven't learned how to save/load RP stats using YSI yet. I'm just using this as a substitution until I do learn how.
Re: How to set a variable to GetPlayerMoney? -
iPLEOMAX - 06.02.2012
Save the money either on "OnPlayerDisconnect" or at some sort of time intervals..
Re: How to set a variable to GetPlayerMoney? -
Nonameman - 06.02.2012
Agree with iPLEOMAX, maybe you should save it on OnPlayerDeath().