Variable problem
#1

Hi,

I have a problem with a global variable.I have this:
pawn Код:
enum cars
{
    iNo,
    //others
};
new CInfo[MAX_VEHICLES][cars]

//and some command that should change iNo
if(IsPlayerConnected(playerid))
{
    new vehid = GetPlayerVehicleID(playerid);
    CInfo[vehid][iNo] = 1;
}
The problem is that after a player re-connects, the variable is set back to 0.(I think this happens after a player connects)
Reply
#2

So...? What should it do otherwise?
Reply
#3

It should remain the same after a player re-connects.For example if it's set to 1 by someone, after reconnect should also be 1 for the player and for other players too.But after it has been set to 1, if a player reconnects it's back to 0.
Reply
#4

Well, how are you saving those variables?
Reply
#5

Using dini, but that's not important.It should remain the same because the server is not restarting.It should only reset on server restart.
Reply
#6

And you have not reset the var somewhere?
Reply
#7

Quote:
Originally Posted by Yvax
Посмотреть сообщение
Using dini, but that's not important.It should remain the same because the server is not restarting.It should only reset on server restart.
Why?

If a player ("Bob") disconnects, and then a new player ("Billy") connects, you want Billy to have the same vehicle as Bob?
Reply
#8

Quote:
Originally Posted by funky1234
Посмотреть сообщение
Why?

If a player ("Bob") disconnects, and then a new player ("Billy") connects, you want Billy to have the same vehicle as Bob?
Not the same vehicle, just that variable.And if "Bob" changes the variable to 1, "Billy" should have the same number after he or Bob reconnects.
Reply
#9

Are you sure the player was in a car, when you wrote the command and are you checking if a player is in an any vehicle ? The code should work fine, if it doesn't, then something must be wrong somewhere else.
Reply
#10

Quote:
Originally Posted by Yvax
Посмотреть сообщение
Not the same vehicle, just that variable.And if "Bob" changes the variable to 1, "Billy" should have the same number after he or Bob reconnects.
I don't see why.. but okay.

Check OnPlayerDisconnect and OnPlayerConnect for that variable (specifically being set to "0").

Edit:
Quote:
Originally Posted by Unte99
Посмотреть сообщение
Are you sure the player was in a car, when you wrote the command and are you checking if a player is in an any vehicle ? The code should work fine, if it doesn't, then something must be wrong somewhere else.
That, isn't the issue. Re-read the original post!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)