SA-MP Forums Archive
Saving after GMX and Crash - 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: Saving after GMX and Crash (/showthread.php?tid=244864)



Saving after GMX and Crash - Ihsan-Cingisiz - 28.03.2011

Hello,

I'm using dini to save the player variables and load it.
I save it when the player disconnects. I made also a
/gmx command for admins, that debugs this code:
SendRconCommand("gmx"); << After I do this, all the
skins are setting to ID: 0, the CJ skin and some other
variables are messing up too, like my position save file.

Now I tried everything to save the files when I type /gmx,
but that didn't work also. I saw in another server, they did
/gmx and you saw on the screen "Blabla has logged out." and
when the gamemode has been successfully restarted, all the
variables are saved and they can start playing from the place
where they were and with the same skin and variables. Does
anyone have a tip, or how to do it? Can someone help me with
this irritating bug(I call it bug, because I don't exactly know how to call ).

And I want to make that the variables also save when the players
crashes, so all the players nearby will get this message:
"Blabla has left the server. (Crashed)". Does anyone have any idea/tip
how to do this?

Thanks!


Re: Saving after GMX and Crash - Ihsan-Cingisiz - 28.03.2011

Quote:
Originally Posted by Magazinez
Посмотреть сообщение
Make Load and Save stocks call the stocks under connects and disconnects..
When the GMX gets applied, does it use the OnPlayerDisconnect function?


Re: Saving after GMX and Crash - Tee - 28.03.2011

Even better.

pawn Код:
new FileSave[20]
When the player logins in

pawn Код:
FileSave[playerid] = SetTimerEx("Save",1000,true,"i",playerid)
pawn Код:
forward Save(playerid)
public Save(playerid)
{
     //Then put the dini stuff in here
     return 1;
}

public OnPlayerDisconnect(playerid)
{
     KillTimer(FileSave[playerid);
     return 1;
}
Here is the 1st 14 lines of mine

pawn Код:
public Save(playerid)
{
    if(Logged[playerid] == 1 && Spawned[playerid] == 1 && IsSpecing[playerid] == 0 && !IsPlayerNPC(playerid))
    {
        GetPlayerName(playerid, Name, sizeof(Name));
        format(file, sizeof(file), USER_FILES, Name);
        if(dini_Exists(file))
        {
            dini_IntSet(file, "Cash", GetPlayerMoney(playerid));
            dini_IntSet(file, "Score", GetPlayerScore(playerid));
        }
    }
    return 1;
}



Re: Saving after GMX and Crash - Ihsan-Cingisiz - 29.03.2011

Quote:
Originally Posted by Tee
Посмотреть сообщение
Even better.

pawn Код:
new FileSave[20]
When the player logins in

pawn Код:
FileSave[playerid] = SetTimerEx("Save",1000,true,"i",playerid)
pawn Код:
forward Save(playerid)
public Save(playerid)
{
     //Then put the dini stuff in here
     return 1;
}

public OnPlayerDisconnect(playerid)
{
     KillTimer(FileSave[playerid);
     return 1;
}
Here is the 1st 14 lines of mine

pawn Код:
public Save(playerid)
{
    if(Logged[playerid] == 1 && Spawned[playerid] == 1 && IsSpecing[playerid] == 0 && !IsPlayerNPC(playerid))
    {
        GetPlayerName(playerid, Name, sizeof(Name));
        format(file, sizeof(file), USER_FILES, Name);
        if(dini_Exists(file))
        {
            dini_IntSet(file, "Cash", GetPlayerMoney(playerid));
            dini_IntSet(file, "Score", GetPlayerScore(playerid));
        }
    }
    return 1;
}
Thanks but when i do /gmx the skins are setting to 0 again..
Please help and i need the crash sav etoo, thanks.


Re: Saving after GMX and Crash - iggy1 - 29.03.2011

Quote:
Originally Posted by Tee
Посмотреть сообщение
Even better.

pawn Код:
new FileSave[20]
When the player logins in

pawn Код:
FileSave[playerid] = SetTimerEx("Save",1000,true,"i",playerid)
pawn Код:
forward Save(playerid)
public Save(playerid)
{
     //Then put the dini stuff in here
     return 1;
}

public OnPlayerDisconnect(playerid)
{
     KillTimer(FileSave[playerid);
     return 1;
}
Here is the 1st 14 lines of mine

pawn Код:
public Save(playerid)
{
    if(Logged[playerid] == 1 && Spawned[playerid] == 1 && IsSpecing[playerid] == 0 && !IsPlayerNPC(playerid))
    {
        GetPlayerName(playerid, Name, sizeof(Name));
        format(file, sizeof(file), USER_FILES, Name);
        if(dini_Exists(file))
        {
            dini_IntSet(file, "Cash", GetPlayerMoney(playerid));
            dini_IntSet(file, "Score", GetPlayerScore(playerid));
        }
    }
    return 1;
}
I wouldn't advise using that code. Unless you increase the time on the timer. There is no reason i can think of to save every players stats every second. Its very inefficient, especially with dini. Once a minute or even two would be good IMO.

Put this in your timer too,
pawn Код:
dini_IntSet(file, "skin", GetPlayerSkin(playerid));



Re: Saving after GMX and Crash - Ihsan-Cingisiz - 29.03.2011

Quote:
Originally Posted by iggy1
Посмотреть сообщение
I wouldn't advise using that code. Unless you increase the time on the timer. There is no reason i can think of to save every players stats every second. Its very inefficient, especially with dini. Once a minute or even two would be good IMO.

Put this in your timer too,
pawn Код:
dini_IntSet(file, "skin", GetPlayerSkin(playerid));
BUt will this help with gmx?
I tried to save the stats when you do /gmx but the problems
appears again... :S Who can help me?!!


Re : Saving after GMX and Crash - timaoux - 17.10.2011

with GMX OnGameModeExit is called so do..

pawn Код:
public OnGameModeExit()
{
    for(new i=0;i<MAX_PLAYERS; i++)
    {
        if(i != INVALID_PLAYER_ID)
        {
              //your code here for save the player stats(use i as playerid)
        }
    }
    return 1;
}



Re: Saving after GMX and Crash - Buzzbomb - 17.10.2011

Jesus This is a Old Topic...