Position Saving - GMX
#1

Hi,

I've searched and searched but I can never find a reason to why it doesn't save my position on crash or gmx.

I managed to make my player save position when he quits, so when he joins he's in the same position as when he quit.

However, if I did /rcon gmx, or closed down the server via windows it doesn't work. It just doesn't save positions what so ever.

I've tried mutiple different ways, I've tried making my own rcon command which calls a stock I made to loop through all players and then save the data, that didn't work.

I tried saving the positions and data OnGameModeExit, but that didn't work.

Im lost for ways, could anyone please help?
Reply
#2

When you use GMX all gamemode variables get reset, use a filterscript to manage it if you really must.
EDIT:
I think I read it wrong, do you save this externally?
Reply
#3

PAWN TIPS:

Create a timer for GMX,
Save The Position
Send a RCON Command that will restart the server

Done.

something like this

pawn Код:
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
Enum[playerid][PosX] = x;
Enum[playerid][PosY] = y;
Enum[playerid][PosZ] = z;
INI_WriteFloat(file, "PosX", Enum[playerid][PosX]);
INI_WriteFloat(file, "PosY", Enum[playerid][PosY]);
INI_WriteFloat(file, "PosZ", Enum[playerid][PosZ]);
SendRconCommand("gmx");
don't copy it, its example only

Do this tip on your restart command
Reply
#4

I dont quite understand what you mean save it externally?

I save all my data from inside my gamemode.
Reply
#5

Quote:
Originally Posted by iRemix
Посмотреть сообщение
I dont quite understand what you mean save it externally?

I save all my data from inside my gamemode.
Then you can either save it externally(Via MySQL, INI, plaintext etc.) or run it from a filterscript, the latter will not work with a full shutdown.
Reply
#6

Quote:
Originally Posted by Reklez
Посмотреть сообщение
PAWN TIPS:

Create a timer for GMX,
Save The Position
Send a RCON Command that will restart the server

Done.

something like this

pawn Код:
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
Enum[playerid][PosX] = x;
Enum[playerid][PosY] = y;
Enum[playerid][PosZ] = z;
INI_WriteFloat(file, "PosX", Enum[playerid][PosX]);
INI_WriteFloat(file, "PosY", Enum[playerid][PosY]);
INI_WriteFloat(file, "PosZ", Enum[playerid][PosZ]);
SendRconCommand("gmx");
don't copy it, its example only

Do this tip on your restart command
That can work on gmx but if the player or the server get crash will not work
You can add a timer to save player data on every X minutes.
Reply
#7

This is exactly what I did to avoid that. Don't copy/paste. Just an example.
pawn Код:
CMD:gmx(playerid,params[])
{
    new gtimer,string[128];
    if(!IsPlayerAdmin(playerid) && pInfo[playerid][pAdmin] < 1337)
    {
        SendClientMessage(playerid,COLOR_LIGHTGRAY,"You are not authorized to use that command.");
        return 1;
    }
    if(sscanf(params,"i",gtimer))
    {
        SendClientMessage(playerid,COLOR_LIGHTGRAY,"USAGE: /gmx [seconds]");
        return 1;
    }
    if(gtimer == 1)
    {
        format(string,128,"The server will restart in %d second.",gtimer);
        SendClientMessageToAll(COLOR_LIGHTBLUE,string);
        SetTimer("gmxTimer",gtimer * 1000,false);
        return 1;
    }
    else
    {
        format(string,128,"The server will restart in %d seconds.",gtimer);
        SendClientMessageToAll(COLOR_LIGHTBLUE,string);
        SetTimer("gmxTimer",gtimer * 1000,false);
        return 1;
    }
}
public gmxTimer(playerid)
{
    foreach(Player,i)
    {
        SaveAccount(i);
    }
    SaveServer();
    TogglePlayerSpectating(playerid,1);
    GameTextForPlayer(playerid,"restart your game.",3000,4);
    SendRconCommand("gmx");
    Kick(playerid);
    return 1;
}
Kick the player to make sure their stats aren't lost? Not sure, but it works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)