Variable problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Variable problem (
/showthread.php?tid=297974)
Variable problem -
Yvax - 18.11.2011
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)
Re: Variable problem -
Ash. - 18.11.2011
So...? What should it do otherwise?
Re: Variable problem -
Yvax - 18.11.2011
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.
Re: Variable problem -
SmiT - 18.11.2011
Well, how are you saving those variables?
Re: Variable problem -
Yvax - 18.11.2011
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.
Re: Variable problem -
LeNy - 18.11.2011
And you have not reset the var somewhere?
Re: Variable problem -
Ash. - 18.11.2011
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?
Re: Variable problem -
Yvax - 19.11.2011
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.
Re: Variable problem -
Unte99 - 19.11.2011
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.
Re: Variable problem -
Ash. - 19.11.2011
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!