SA-MP Forums Archive
Really weird problem (y_ini saving) - 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: Really weird problem (y_ini saving) (/showthread.php?tid=604189)



Really weird problem (y_ini saving) - nerovani - 01.04.2016

So I got a really, really weird problem here.

This is the case:
When the server restarts, it saves the player's position, level, all the other data EXCEPT Admin and Mod.
But when a player disconnects, it saves EVERYTHING.

This is the script:

Код:
public OnPlayerDisconnect(playerid, reason)
{
        if(IsLogged[playerid] != 1) return 1;
	SaveUser(playerid);
        return 1;
}

public OnGameModeExit( )
{
    for( new i = 0; i < MAX_PLAYERS; i++)
	{
		if (IsLogged[i] != 0) SaveUser(i);
	}
    return 1;
}

stock SaveUser(playerid)
{
GetPlayerPos(playerid,PlayerInfo[playerid][pLastX],PlayerInfo[playerid][pLastY],PlayerInfo[playerid][pLastZ]);
GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pLastA]);
new INI:File = INI_Open(UserPath(playerid));
INI_WriteFloat(File,"LastX", PlayerInfo[playerid][pLastX]);
INI_WriteFloat(File,"LastY", PlayerInfo[playerid][pLastY]);
INI_WriteFloat(File,"LastZ", PlayerInfo[playerid][pLastZ]);
INI_WriteFloat(File,"LastA", PlayerInfo[playerid][pLastA]);
INI_WriteInt(File,"VirtualW",GetPlayerVirtualWorld(playerid));
INI_WriteInt(File,"Interior",GetPlayerInterior(playerid));
new Float:health;
GetPlayerHealth(playerid,health);
INI_WriteFloat(File,"Health",health);
new Float:armour;
GetPlayerArmour(playerid, armour);
INI_WriteFloat(File,"Armor",armour);
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Mod",PlayerInfo[playerid][pMod]);
INI_WriteInt(File,"Level",GetPlayerScore(playerid));
INI_WriteInt(File,"Hours",PlayerInfo[playerid][pHours]);
INI_WriteInt(File,"Minutes",PlayerInfo[playerid][pMinutes]);
INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
INI_WriteInt(File,"Gender",PlayerInfo[playerid][pGender]);
INI_WriteInt(File,"Money",GetPlayerMoney(playerid));
INI_Close(File);
}
Can somebody help me or atleast suggest something?


Re: Really weird problem (y_ini saving) - DTV - 01.04.2016

Change the code under OnGameModeExit() so that it only kicks the players rather than saving their account.
pawn Код:
public OnGameModeExit( )
{
    for( new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsLogged[i] != 0) Kick(i);
    }
    return 1;
}
Getting kicked will still trigger OnPlayerDisconnect as it's a form of disconnecting from the server. Not too sure if it will help, but just something I noticed that isn't needed.


Re: Really weird problem (y_ini saving) - nerovani - 01.04.2016

I tried that, but then the player has to exit SA:MP and open it back up to enter the server.


Re: Really weird problem (y_ini saving) - DTV - 01.04.2016

It's better that they exit SA-MP as keeping them connected through a restart can cause issues like the one you're experiencing here.


Re: Really weird problem (y_ini saving) - nerovani - 01.04.2016

Yes, but I want to resolve this issue instead of avoiding it.


Re: Really weird problem (y_ini saving) - DTV - 01.04.2016

There isn't a way that you can fix players not losing stats/data during a restart as far as I know, it's just a bug that SA-MP has.


Re: Really weird problem (y_ini saving) - nerovani - 01.04.2016

As I said in the beginning, all the other data is saved except the Admin level and Mod level.


Re: Really weird problem (y_ini saving) - nerovani - 02.04.2016

I fixed it.
I just had to change the name of which the variable saves in the file.