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



gmx saving problem - grand.Theft.Otto - 11.07.2012

As most of you probably know, sometimes gmx doesn't save properly in your userfile or resets all integers to 0. That's my problem, I'm trying to make skins save when you disconnect. It saves when you /q or close the server completely then connect again. It doesn't work when you /rcon gmx, what it does is sets the skin to default skin id 0 (CJ).

I've already tried making my own /gmx command and saving the skin before the server restarts, but it still gives me CJ's skin on connect.

I have other things that save when I gmx, like: drugs, bank account balance, life insurance, fight styles, etc... but some things don't save for some reason like the skin when I do gmx.

Does anyone know a solution ?


Re: gmx saving problem - coole210 - 11.07.2012

You can save account info when it changes, or every few minutes in a timer.


Re: gmx saving problem - ReneG - 11.07.2012

Make your own gmx command that saves data, then gmx's via SendRconCommand.


Re: gmx saving problem - coole210 - 11.07.2012

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
Make your own gmx command that saves data, then gmx's via SendRconCommand.
Quote:
Originally Posted by grand.Theft.Otto
Посмотреть сообщение
I've already tried making my own /gmx command and saving the skin before the server restarts, but it still gives me CJ's skin on connect.
4char


Re: gmx saving problem - ReneG - 11.07.2012

^^Because he's doing it wrong, and has shown no code.


Re: gmx saving problem - coole210 - 11.07.2012

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
^^Because he's doing it wrong, and has shown no code.
I agree with this. I've made my own GMX command to save before restart and it has worked fine, maybe try again or look at other scripts.


Re: gmx saving problem - grand.Theft.Otto - 11.07.2012

I made this gmx command so it loops through everyone and gets their skin. When I type /gmx, it sets off a timer for 10 seconds, between the 10 seconds I only made it so it will save the skin:

pawn Код:
dcmd_gmx(playerid,params[])
{
    if(PlayerInfo[playerid][Level] >= 5 || IsPlayerAdmin(playerid))
    {
        new string[128];

        restartgm = SetTimer("RestartGM",10000,0);
        SendClientMessageToAll(COLOR_PINK,"***SERVER RESTART:  (ADMIN RESTART)  Server Restarting In 10 Seconds.");
        format(string,128,"Admin Server Restart (/gmx Refresh)"); print(string);

        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && PlayerInfo[i][LoggedIn] == 1)
            {
                new skinid = GetPlayerSkin(i);
                dUserSetINT(PlayerName2(i)).("savedskin",skinid);
                PlayerInfo[i][SavedSkin] = skinid;
            }
        }
        return 1;
    } else return SendClientMessage(playerid,red,"Invalid Command. Type   /cmds   For A List Of All Available Server Commands.");
}
Then when 10 seconds is up, this separate timer callback restarts the server:

pawn Код:
forward RestartGM();
public RestartGM()
{
    SendRconCommand("gmx");
    return 1;
}



Re: gmx saving problem - coole210 - 11.07.2012

Set the timer after the loop, not before.


Re: gmx saving problem - grand.Theft.Otto - 11.07.2012

Well I changed it to this but it still doesn't work:

pawn Код:
dcmd_gmx(playerid,params[])
{
    if(PlayerInfo[playerid][Level] >= 5 || IsPlayerAdmin(playerid))
    {
        new string[128];

        SendClientMessageToAll(COLOR_PINK,"***SERVER RESTART:  (ADMIN RESTART)  Server Restarting In 10 Seconds.");
        format(string,128,"Admin Server Restart (/gmx Refresh)"); print(string);

        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && PlayerInfo[i][LoggedIn] == 1)
            {
                new skinid = GetPlayerSkin(i);
                dUserSetINT(PlayerName2(i)).("savedskin",skinid);
                PlayerInfo[i][SavedSkin] = skinid;
            }
        }
        restartgm = SetTimer("RestartGM",10000,0);
        return 1;
    } else return SendClientMessage(playerid,red,"Invalid Command. Type   /cmds   For A List Of All Available Server Commands.");
}
Did I do it right ?


Re: gmx saving problem - ReneG - 11.07.2012

Kick the players in the loop, they would have to restart their game, avoiding problems.