Really weird problem (y_ini saving)
#1

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

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

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

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

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)