SA-MP Forums Archive
GMX Doesn't save, After /o Server shuts down - 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 Doesn't save, After /o Server shuts down (/showthread.php?tid=442196)



GMX Doesn't save, After /o Server shuts down - Facerafter - 06.06.2013

Using the /gmx is doesn't save the user files. I checked with print on the Save function. It shows the msg but it doesn't save.
GMX CMD:
pawn Код:
CMD:gmx(playerid, params[])
{
    new string[128];
    if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not authorized to use this command!");
    format(string, sizeof(string), "AdmCmd: %s has announced a GMX, Server will restart in a few seconds.", RPName(playerid));
    SendClientMessageToAll(COLOR_TOMATO, string);
    SaveFactions();
    SaveAccounts();
    SetTimer("GMX", 20000, false);
    return 1;
}
GMX public
pawn Код:
forward GMX();
public GMX()
{
    SendRconCommand("gmx");
}
pawn Код:
function SaveAccountStats(playerid)
{
    if(Logged[playerid] == 1)
    {
    new
        INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");

    PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
    PlayerInfo[playerid][pCash] = GetPlayerCash(playerid);
    new
        Float:x,
        Float:y,
        Float:z
    ;
    GetPlayerPos(playerid,x,y,z);
    PlayerInfo[playerid][pPos_x] = x;
    PlayerInfo[playerid][pPos_y] = y;
    PlayerInfo[playerid][pPos_z] = z;

    INI_WriteInt(File,"Cash",PlayerInfo[playerid][pCash]);
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Sex",PlayerInfo[playerid][pSex]);
    INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
    INI_WriteFloat(File,"Pos_x",PlayerInfo[playerid][pPos_x]);
    INI_WriteFloat(File,"Pos_y",PlayerInfo[playerid][pPos_y]);
    INI_WriteFloat(File,"Pos_z",PlayerInfo[playerid][pPos_z]);
    INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
    INI_WriteInt(File,"Member",PlayerInfo[playerid][pMember]);
    INI_WriteInt(File,"Cookie",PlayerInfo[playerid][pCookie]);
    INI_WriteInt(File,"Accent",PlayerInfo[playerid][pAccent]);
    INI_WriteInt(File,"Leader",PlayerInfo[playerid][pLeader]);
    INI_WriteInt(File,"Rank",PlayerInfo[playerid][pRank]);
    INI_WriteInt(File,"Division",PlayerInfo[playerid][pDiv]);
    INI_WriteInt(File,"DivLeader",PlayerInfo[playerid][pDivLeader]);
    INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBan]);

    INI_Close(File);
    }
    return 1;
}
SaveAccounts is a loop for SaveAccountStats(playerid)


And here the /o
pawn Код:
CMD:ooc(playerid, params[])
{
    new string[128],rank[20];
    if((noooc) && PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_WHITE, "ERROR: OOC Chat is disabled!");
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: (/o)oc [ooc chat]");
    switch(PlayerInfo[playerid][pAdmin])
    {
        case 0: rank = "Player";
        case 1: rank = "Server MOD";
        case 2: rank = "Junior Admin";
        case 3: rank = "General Admin";
        case 4: rank = "Senior Admin";
        case 5: rank = "Head Admin";
        case 6: rank = "Server Manager";
        case 1337: rank = "Server Owner";
        default: rank = "Player";
    }
    format(string, sizeof(string), "((%s %s: %s ))", rank, RPName(playerid), params);
    OOCOff(0xCCFFFF00, string);
    OOCLog(string);
    printf("%s: %s", RPName(playerid),string);
    return 1;
}
pawn Код:
function OOCOff(color,const string[])
{
    foreach (Player,i)
    {
        if(!gOoc{i})
        {
            SendClientMessage(i, color, string);
        }
    }
}
It shows the usage. But after filling something it shutdowns the server.exe without any messages on the server.log


Re: GMX Doesn't save, After /o Server shuts down - Apenmeeuw - 06.06.2013

I suggest you to Kick all the players from the server when you're restarting it, because that's the best secure way to make sure that the stats are being saved.

pawn Код:
foreach(Player, i)
{
if(IsPlayerConnected(i))
{
Kick(i);
}
}
put that in your /gmx cmd. I also recommend you to make /savestats so the player can save all his statistics in-game.


Re: GMX Doesn't save, After /o Server shuts down - reckst4r - 06.06.2013

pawn Код:
CMD:gmx(playerid, params[])
{
    new string[128];
    if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not authorized to use this command!");
    format(string, sizeof(string), "AdmCmd: %s has announced a GMX, Server will restart in a few seconds.", RPName(playerid));
    SendClientMessageToAll(COLOR_TOMATO, string);
    SaveFactions();
    SaveAccounts();
    SaveAccountStats();
    SetTimer("GMX", 20000, false);
    return 1;
}
Try that


Re: GMX Doesn't save, After /o Server shuts down - Facerafter - 06.06.2013

@Reckst4r,
Its SaveAccountStats(playerid)
And also the SaveAccounts() is a loop for SaveAccountStats()
pawn Код:
function SaveAccounts()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            SaveAccountStats(i);
        }
    }
}
@Apenmeeuw thanks for the tips. Going to try it now.
Thanks, Stats are saving now.

But now i still got the /o problem.


Re: GMX Doesn't save, After /o Server shuts down - reckst4r - 06.06.2013

Ah, I see. Sorry, my mind is a bit foggy as I just woke up.


Re: GMX Doesn't save, After /o Server shuts down - Facerafter - 06.06.2013

ALL FIXED!