Saving after GMX and Crash
#1

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

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

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;
}
Reply
#4

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

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

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

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;
}
Reply
#8

Jesus This is a Old Topic...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)