SA-MP Forums Archive
Reseting all player 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: Reseting all player variables? (/showthread.php?tid=608192)



Reseting all player variables? - andrejc999 - 28.05.2016

So guys I'm currently working on a RP Gamemode and I want to know is it posible to reset all of player variables without doing it manualy for each variable? Is there a function/command that does that?The problem is if a player disconnects and a new player connects that new player will get the same variables as the player that disconnected, I think so...

Thanks in advice.


Re: Reseting all player variables? - Darkwood17 - 28.05.2016

I found that: http://forum.sa-mp.com/showpost.php?...16&postcount=6
Add this under OnPlayerDisconnect().


Re: Reseting all player variables? - Stinged - 28.05.2016

This only works with enums:
Код:
enum e_Player
{
    a,
    b
    // etc..
};
new Player[MAX_PLAYERS][e_Player];

// To reset everything in the enum:
new n[e_Player];
Player[playerid] = n;
EDIT: Too late..


Re: Reseting all player variables? - andrejc999 - 28.05.2016

Oh ok thanks... So it's not possible to clear normal variables without doing it manualy?
By normal I mean like

new something[MAX_PLAYERS];


Re: Reseting all player variables? - Darkwood17 - 28.05.2016

Quote:
Originally Posted by andrejc999
Посмотреть сообщение
Oh ok thanks... So it's not possible to clear normal variables without doing it manualy?
By normal I mean like

new something[MAX_PLAYERS];
You can try chaining the variable assignments:
Код:
new a, b, c;
a = b = c = 0;



Re: Reseting all player variables? - andrejc999 - 28.05.2016

Am, I'm not sure how that works I mean I understood you but I didn't know that's how variables work?


Re: Reseting all player variables? - PrO.GameR - 28.05.2016

quickest way?
new cleanslot[pPlayerEnum];
PlayerI[playerid]=cleanslot;

Where pPlayerEnum is your enum name and PlayerI is your variable array.
This will only work if you don't use 1D arrays for each variable but 1 big 2D/3D array for all or most of your variables.


Re: Reseting all player variables? - Darkwood17 - 28.05.2016

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
quickest way?
new cleanslot[pPlayerEnum];
PlayerI[playerid]=cleanslot;

Where pPlayerEnum is your enum name and PlayerI is your variable array.
This will only work if you don't use 1D arrays for each variable but 1 big 2D/3D array for all or most of your variables.
The same thing that I and Stinged already posted.
He's trying to clear multiple variables at once, not enum.

Quote:
Originally Posted by andrejc999
Посмотреть сообщение
Am, I'm not sure how that works I mean I understood you but I didn't know that's how variables work?
Quote:
Originally Posted by andrejc999
Посмотреть сообщение
Oh I see so it's hardcore to clear them all? I mean like I have some that are mixed like letter+number+letter+idk...
You can clear the variables like this:
Код:
letter = number = 0;
This mean that both letter and number will be set to 0. This work both for strings (letter) and integers (number).
It's the same as doing:
Код:
letter = 0;
number = 0;
Quote:
Originally Posted by andrejc999
Посмотреть сообщение
Is there a plugin that does the job for us?
Plugin is not needed for this.


Re: Reseting all player variables? - andrejc999 - 28.05.2016

I still don't understand how can I go through all of them...


Re: Reseting all player variables? - Darkwood17 - 28.05.2016

Quote:
Originally Posted by andrejc999
Посмотреть сообщение
I still don't understand how can I go through all of them...
You can't.
I just gave you a better way to reset multiple variables.
Isn't that what you wanted?