SA-MP Forums Archive
Reset Variables - 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: Reset Variables (/showthread.php?tid=629206)



Reset Variables - Nin9r - 22.02.2017

Hello ! I don't know when / how, but for a part of players some variables are reseted. Sometimes, the job / skin / radioID and others variables get a wrong value (random). For example, i have 9 jobs on my server (max pJob] = 9). Sometime, a player has pJob] > 9 ( random: pJob] = 82, 101,110 ) but i dont know why. I used ctrl+f and find ' pJob] = ' on the entire GM and i didn't find anything like that. Also, pSkinID] gets another value. Sometime in ONPLAYERSPAWN the skin are changed without /buyskin or something. There I use just
Код HTML:
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkinID]);
RadioID gets a value when a player is listening a RADIO from /radio. I use it for counting how many listeners are for each radio station. After few time, the RadioID is random or set on 0.

This problem appears for many variables. I tried to fix it but i have no idea anymore.

For what reason? Any ideas?

PS: This is not happen when a few players are connected (max 10-15).
I am not using #define MAX_PLAYERS 100 because if I put it all the queries(savedata) will be damaged.


Re: Reset Variables - Cypress - 22.02.2017

Quote:
Originally Posted by Nin9r
Посмотреть сообщение
Hello ! I don't know when / how, but for a part of players some variables are reseted. Sometimes, the job / skin / radioID and others variables get a wrong value (random). For example, i have 9 jobs on my server (max pJob] = 9). Sometime, a player has pJob] > 9 ( random: pJob] = 82, 101,110 ) but i dont know why. I used ctrl+f and find ' pJob] = ' on the entire GM and i didn't find anything like that. Also, pSkinID] gets another value. Sometime in ONPLAYERSPAWN the skin are changed without /buyskin or something. There I use just
Код HTML:
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkinID]);
RadioID gets a value when a player is listening a RADIO from /radio. I use it for counting how many listeners are for each radio station. After few time, the RadioID is random or set on 0.

This problem appears for many variables. I tried to fix it but i have no idea anymore.

For what reason? Any ideas?

PS: This is not happen when a few players are connected (max 10-15).
I am not using #define MAX_PLAYERS 100 because if I put it all the queries(savedata) will be damaged.
Why would the queries be damaged if you redefine the server's MAX_PLAYERS. It shouldn't affect anything. Also are you resetting the player variables on connection?


Re: Reset Variables - Nin9r - 22.02.2017

I don't reset pskinID or pjob on onplayerconnect.

If i define MAX_PLAYERS, some data won't be saved and TEXTDRAWS won't show for all the players. It is weird.

Give me an example of redefine to try again it.


Re: Reset Variables - Yousha - 22.02.2017

Just some suggestion:

I think its better to RESET player's data in OnPlayerDisconnect...
Make a function and put ALL players data and vars in, then reset them all.

Also I would like suggest you to use SetPVarInt SetPVarString SetPVarFloat to save player's Temporary data... then you dont need worry about Reseting them


Re: Reset Variables - Mic_H - 22.02.2017

Use Crashdetect and check if the script is crashing at some point.. It could happen due to that..

This could happen when there is a copy-paste mistake/fail.
  1. Instead of Resetting variable for TargetID, you would be resetting for PlayerID..
  2. Wrong Variable being checked/set.
  3. Script crashing at some point(Crash Detect)
Confirm the above and reply pls. Post the code if you want a better approach


Re: Reset Variables - Nin9r - 25.02.2017

I changed it with SetPVarInt and it has no effect. It is still resetting.

PS: I checked and i didn't changed playerid with targetid or something else. ( there is no copy/paste script )

This is weird, no?

So, I use SetPVarInt(playerid, "JobID", 0); just in /quitjob and the job is still dissapearing sometime. I have no idea why it could be happen.