GMX not saving stats
#1

Hey guys, so I've a problem on GMXing my server.
So I made the command:

EDIT: Also, it spawns me into Blue Berry and spawns me under ground 2m down I guess? And then it kills me and then yeah, spawns me back onto the ground BUT still on Blue Berry?

pawn Код:
CMD:gmx(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1337 || IsPlayerAdmin(playerid))
    {
        SetTimer("GameModeInitExitFunc", 29000, 0);
        SendClientMessageToAll(COLOR_LIGHTRED, "SERVER: A GMX has been intiaited by a admin, the GMX will occur in 30 seconds!");
        SendClientMessageToAll(COLOR_GRAD2, "  You have been frozen by the GMX system !");
        foreach(Player, i)
        {
            GMX[i] = 1;
            TogglePlayerControllable(i, 0);
            SaveAccountInfo(i);
        }
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command !");
    }
    return 1;
}
Forwarded the timer.
pawn Код:
forward GameModeInitExitFunc();
public GameModeInitExitFunc()
{
    new string[128];
    format(string, sizeof(string), "Server Restarting...");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            DisablePlayerCheckpoint(i);
            GameTextForPlayer(i, string, 4000, 5);
            SetPlayerInterior(i, 0);
            SetPlayerVirtualWorld(i, 0);
            SetPlayerCameraPos(i,1460.0, -1324.0, 287.2);
            SetPlayerCameraLookAt(i,1374.5, -1291.1, 239.0);
            gPlayerLogged[i] = 0;
        }
    }
    SetTimer("GameModeExitFunc", 4000, 0);
    return 1;
}
Forwarded the other timer:
pawn Код:
forward GameModeExitFunc();
public GameModeExitFunc()
{
    GameModeExit();
}
And here's my SaveAccountInfo
pawn Код:
forward SaveAccountInfo(playerid);
public SaveAccountInfo(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    new Float:X, Float:Y, Float:Z;
    new Float:facingangle;
    new Float:health, Float:armour;
    new skin = GetPlayerSkin(playerid);
    GetPlayerHealth(playerid, health);
    GetPlayerArmour(playerid, armour);
    GetPlayerFacingAngle(playerid, facingangle);
    GetPlayerPos(playerid, X, Y, Z);
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Level",GetPlayerScore(playerid));
    INI_WriteInt(File,"Int",GetPlayerInterior(playerid));
    INI_WriteInt(File,"Skin",skin);
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Number",PlayerInfo[playerid][pNumber]);
    INI_WriteInt(File,"ADMute",PlayerInfo[playerid][pADMute]);
    INI_WriteInt(File,"BankAccount",PlayerInfo[playerid][pBankAccount]);
    INI_WriteInt(File,"Accountdata",PlayerInfo[playerid][pAccountdata]);
    INI_WriteInt(File,"SecKey",PlayerInfo[playerid][pSecKey]);
    INI_WriteInt(File,"Helper",PlayerInfo[playerid][pHelper]);
    INI_WriteInt(File,"Stealthed",PlayerInfo[playerid][pStealthed]);
    INI_WriteInt(File,"DonateRank",PlayerInfo[playerid][pDonateRank]);
    INI_WriteInt(File,"NewbieMuted",PlayerInfo[playerid][pNewbieMuted]);
    INI_WriteFloat(File, "FacingAngle", facingangle);
    INI_WriteFloat(File, "Health", health);
    INI_WriteFloat(File, "Armour", armour);
    INI_WriteFloat(File, "LastX", X);
    INI_WriteFloat(File, "LastY", Y);
    INI_WriteFloat(File, "LastZ", Z);
    INI_Close(File);
    return 1;
}
But somehow, IT SAVES the STATS perfectly, working good when the Player Disconnects using /q or ESC all that. But somehow not the GMX command.
I used the same function as in OnPlayerDisconnect? SaveAccountInfo(playerid);
I'd like a possible and working solution, thanks!
Reply
#2

i dont see a timer or anything in the /gmx command or any of the other times where it calls the public SaveAccountInfo(playerid) callback..., so it never gets called, meaning it wont save the players stats
Reply
#3

Quote:
Originally Posted by niels44
Посмотреть сообщение
i dont see a timer or anything in the /gmx command or any of the other times where it calls the public SaveAccountInfo(playerid) callback..., so it never gets called, meaning it wont save the players stats
Hmmm, lemme test it. I'll respond back later. Thanks
EDIT: It's acutally here, it says on my command, look up.
pawn Код:
CMD:gmx(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1337 || IsPlayerAdmin(playerid))
    {
        SetTimer("GameModeInitExitFunc", 29000, 0);
        SendClientMessageToAll(COLOR_LIGHTRED, "SERVER: A GMX has been intiaited by a admin, the GMX will occur in 30 seconds!");
        SendClientMessageToAll(COLOR_GRAD2, "  You have been frozen by the GMX system !");
        foreach(Player, i)
        {
            GMX[i] = 1;
            TogglePlayerControllable(i, 0);
            >>>> SaveAccountInfo(i);
        }
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command !");
    }
    return 1;
}
Reply
#4

Bump, really need this. Been waiting (:
Reply
#5

I'm a bit confused on what you are trying to accomplish with this code. You call the GameModeInitExit function which sets information for the player which isn't necessary. All player data will be reset upon the GMX as it is basically the same as the player disconnecting and re-connecting to the server. That means, it is also unnecessary to call the SaveAccountInfo inside the command, as OnPlayerDisconnect will be called when the players leave due to the GMX, which may fix your issue.

I would also like to address a few things in the code:
  • Is there a reason you switch between using foreach and a regular for loop?
  • GameModeInitExit function creates and manipulates a string that is unnecessary. Simply pass the "Server Restarting..." text into the GameTextForAll call.
  • You can remove the loop completely from the GameModeInitExit function as those settings are reset when the player re-connects after the GMX anyway
There are a few other things, but since I do not have the whole game mode script, I'm going to assume they are implemented, specifically in that way, for a reason.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)