Reseting all player variables?
#1

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.
Reply
#2

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

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..
Reply
#4

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];
Reply
#5

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;
Reply
#6

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

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.
Reply
#8

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.
Reply
#9

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

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)