variable reset? +rep!
#1

hi,

if you have variables in your script e.g. like:

pawn Code:
new Money[MAX_PLAYERS];
Where would you reset them?
On OnPlayerConnect or under OnPlayerDisconnect?
Does it make any difference at all?
pawn Code:
Money[playerid]=0;

thank you.
Reply
#2

Quote:
Originally Posted by PawnoQ
View Post
hi,

if you have variables in your script e.g. like:

pawn Code:
new Money[MAX_PLAYERS];
Where would you reset them?
On OnPlayerConnect or under OnPlayerDisconnect?
Does it make any difference at all?
pawn Code:
Money[playerid]=0;

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.
Reply
#3

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?
Reply
#4

OnPlayerConnect Callback reset the variables.
Reply
#5

Well, what type of gamemode is this for?
Reply
#6

TDM, does that matter?

But OnPlayerDisconnect also should work, right?
Reply
#7

pawn Code:
new Money[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
    Money[playerid] = 0;
    return 1;
}
Everytime someone connects their money var will be reset.
Reply
#8

i know that but my question actually was if the reset also works properly under OnPlayerDisconnect?
Or what efficiency differences there would be?
Reply
#9

Whether you put it under OnPlayerDisconnect or OnPlayerConnect, both will work %100. Niether of them have more efficiency than the other.
Reply
#10

if its so then thx +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)