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?