Save all account in /gmx?
#1

Hi all..

I wanted to know how to save all .ini files of player accounts without needing the player connected.

How can I do that?..
Thanks
Reply
#2

HELP
Reply
#3

There's no reason to save files of players that aren't even connected and playing. Simply use a loop, open their file, save their variables, close it, and THEN restart the server. I use a 2 second timer after I save their files to actually send the rcon command to restart.

pawn Код:
CMD:gmx(playerid, params[])
{
    new
            plStr[64],
            plName[MAX_PLAYER_NAME];

    for(new i; i < MAX_PLAYERS; i ++)
    {
        if(pl_Logged[playerid] != 1) // change this to your logged in variable
            return 0;

        GetPlayerName(i, plName, MAX_PLAYER_NAME);
        format(plStr, sizeof(plStr), "Accounts/%s.ini", plName);

        new
            INI: File = INI_Open(plStr);
           
        INI_SetTag(File, "..."); // set file tag
       
        INI_WriteInt(File, "....", ..); // set their variables
       
        INI_Close(File); // close their file
    }
   
    SetTimer("RestartServ", 2000, false);
}

forward RestartServ();
public RestartServ()
{
    SendRconCommand("gmx");
    return 1;
}
This example is using YINI & YCMD.
Reply
#4

That's working, but one variable always restarts when I restart/start the server...
It's the name of a caracther in a characters system...
pawn Код:
//When it saves
strcpy(PlayerInfo[playerid][pNomePersonaggio1], inputtext, 64);
            OnPlayerSave(playerid);
//OnPlayerConnect
PlayerInfo[playerid][pNomePersonaggio1] = PlayerInfo[playerid][pNomePersonaggio1];
    PlayerInfo[playerid][pNomePersonaggio2] = PlayerInfo[playerid][pNomePersonaggio2];
    PlayerInfo[playerid][pNomePersonaggio3] = PlayerInfo[playerid][pNomePersonaggio3];
//OnPlayerRegister
format(var, 32, "NomePersonaggio1=%s\n",PlayerInfo[playerid][pNomePersonaggio1]);fwrite(hFile, var);
//OnPlayerSave
    format(var, 32, "NomePersonaggio1=%s\n",PlayerInfo[playerid][pNomePersonaggio1]);fwrite(hFile, var);
Why this variable restart everytime I restart the GM?
Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)