How to save stuff on GameModExit?
#1

How to save stuff on GameModExit?
Reply
#2

You cannot do that but you can save info when OnPlayerDisconnect.
Reply
#3

I made this code on PlayerDisconnect so that it checks if the player has completed registration if not then it deletes the user file of the player and he has to register again.
pawn Код:
if(GetPVarInt(playerid,"Regan")==0)
    {
        new name[MAX_PLAYER_NAME],strPath[128];
        GetPlayerName(playerid,name,sizeof(name));
        format(strPath,sizeof(strPath), "/users/%s.txt",name);
        fremove(strPath);
    }
I Have set SetPVarInt(playerid,"Regan",1) on OnPlayerConnect so if the player disonnect before login his user.txt wont get deleted.

I Have set SetPVarInt(playerid,"Regan",0) on the start of the registration and SetPVarInt(playerid,"Regan",1) when the player finishes it.

Now when I reset my server over /gmx my user.txt in scriptfiles gets deleted.
Reply
#4

Quote:
Originally Posted by Edward156
Посмотреть сообщение
You cannot do that but you can save info when OnPlayerDisconnect.
Bullsh*t.

You can save stuff, just not playerdata (UNTESTED, NEVER TRIED THIS)

But its perfectly fine with House systems, Vehicle Systems and stuff like that.
Reply
#5

You can save anything in OnGameModeExit as long as you have it saved in a var. Doesn't matter if it's player data or not, data is data. PVars may not work because players are disconnected when the mode exits (deleting PVars).

I'm guessing they are disconnected before OnGameModeExit is called, since it's the last thing called, i may be wrong.
Reply
#6

So how can i solve my problem then?
Should I just remove the code and risk many angry players that crashed while registering and cant' get their nickname back or what,how do you guys remove the player file if he didn't register corectly?
Reply
#7

Quote:
Originally Posted by MarinacMrcina
Посмотреть сообщение
So how can i solve my problem then?
Should I just remove the code and risk many angry players that crashed while registering and cant' get their nickname back or what,how do you guys remove the player file if he didn't register corectly?
What do you mean if they didn't register correctly? Just don't allow that to happen. Only register their account once they have registered a password, then it wont matter if they crash or not. And save player data once per 2-5 minutes.

EDIT: Use normal vars not PVars.
Reply
#8

I got a dialog registering system.After the player types his password it saves it,after he types his count,character age etc. it saves.

If the player would crash between 2 dialogs then his character wont have age and will be able to buy alcohol in the 24/7s
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)