variable reset? +rep! -
PawnoQ - 03.03.2012
hi,
if you have variables in your script e.g. like:
Where would you reset them?
On OnPlayerConnect or under OnPlayerDisconnect?
Does it make any difference at all?
thank you.
Re: variable reset? +rep! -
Walsh - 03.03.2012
Quote:
Originally Posted by PawnoQ
hi,
if you have variables in your script e.g. like:
Where would you reset them?
On OnPlayerConnect or under OnPlayerDisconnect?
Does it make any difference at all?
thank you.
|
You could put it under OnPlayerDisconnect or OnPlayerSpawn. Both will work, however if you are trying to make Money equal GetPlayerMoney(playerid) do it under OnPlayerSpawn as when a player connects he has zero dollars.
Re: variable reset? +rep! -
PawnoQ - 03.03.2012
when playerid 0 joins and makes some money lets say 200$.
Then he leaves.
After another player connects he would get the playerid 0 and therefor also the money[playerid] variable of that playerid including 200$.
Thats why i want to reset them.
Under OnPlayerSpawn wouldnt be such a smart decission i guess
But it doesnt really make a difference if i place it under OnPlayerConnect or OnPlayerDisconnect right?
Re: variable reset? +rep! -
Konstantinos - 03.03.2012
OnPlayerConnect Callback reset the variables.
Re: variable reset? +rep! -
Walsh - 03.03.2012
Well, what type of gamemode is this for?
Re: variable reset? +rep! -
PawnoQ - 03.03.2012
TDM, does that matter?
But OnPlayerDisconnect also should work, right?
Re: variable reset? +rep! -
Walsh - 03.03.2012
pawn Code:
new Money[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
Money[playerid] = 0;
return 1;
}
Everytime someone connects their money var will be reset.
Re: variable reset? +rep! -
PawnoQ - 03.03.2012
i know that but my question actually was if the reset also works properly under OnPlayerDisconnect?
Or what efficiency differences there would be?
Re: variable reset? +rep! -
Walsh - 03.03.2012
Whether you put it under OnPlayerDisconnect or OnPlayerConnect, both will work %100. Niether of them have more efficiency than the other.
Re: variable reset? +rep! -
PawnoQ - 03.03.2012
if its so then thx

+rep