SA-MP Forums Archive
Position Saving - GMX - 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: Position Saving - GMX (/showthread.php?tid=330736)



Position Saving - GMX - iRemix - 02.04.2012

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?


Re: Position Saving - GMX - blank. - 02.04.2012

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?


Re: Position Saving - GMX - Reklez - 02.04.2012

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


Re: Position Saving - GMX - iRemix - 02.04.2012

I dont quite understand what you mean save it externally?

I save all my data from inside my gamemode.


Re: Position Saving - GMX - blank. - 02.04.2012

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.


Re: Position Saving - GMX - TzAkS. - 02.04.2012

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.


Re: Position Saving - GMX - ReneG - 02.04.2012

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.