SA-MP Forums Archive
Saving player position OnGameModeExit? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Saving player position OnGameModeExit? (/showthread.php?tid=235619)



Saving player position OnGameModeExit? - austin070 - 06.03.2011

The title says it all. Is it possible? And if so, how could I do it? I use dini for file writing.


Re: Saving player position OnGameModeExit? - Lorrden - 06.03.2011

Make a loop or use OnPlayerDisconnect


Re: Saving player position OnGameModeExit? - austin070 - 06.03.2011

I tried making a loop, but it didn't work. I have it in OnPlayerDisconnect also, but when people are on the server and it restarts, they spawn in the middle of nowhere. That's why I also need it in OnGameModeExit.


Re: Saving player position OnGameModeExit? - Lorrden - 06.03.2011

pawn Код:
OnGameModeExit()
{
    for(new p = 0; p < MAX_PLAYERS; p ++)
    {
        if(IsPlayerConnected(p)
        {
            //You're save things here (remember to use p instead of playerid
        }
    }
    return true;
}



Re: Saving player position OnGameModeExit? - austin070 - 06.03.2011

pawn Код:
for(new p = 0; p < MAX_PLAYERS; p ++)
    {
        if(IsPlayerConnected(p))
        {
            new file[256];
            new name[MAX_PLAYER_NAME];
            GetPlayerName(p, name, sizeof(name));
            format(file, sizeof(file), USER_FILE, name);
            new Float:x, Float:y, Float:z;
            GetPlayerPos(p, x, y, z);
            dini_FloatSet(file, "XPos", x);
            dini_FloatSet(file, "YPos", y);
            dini_FloatSet(file, "ZPos", z);
            dini_IntSet(file, "Interior", GetPlayerInterior(p));
        }
        return 1;
    }
This doesn't work.


Re: Saving player position OnGameModeExit? - Lorrden - 06.03.2011

In what way?
Are you sure there's nothing wrong with You're file system?


Re: Saving player position OnGameModeExit? - austin070 - 06.03.2011

It doesn't set the XPos, YPos, and ZPos of the player's file. And I'm pretty sure there's nothing wrong with my file system because this works with OnPlayerDisconnect.


Re: Saving player position OnGameModeExit? - Antonio [G-RP] - 06.03.2011

I'm sure you're doing this on restart? I suggest you make it so it it kicks the player (calls OnPlayerDisconnect) before the server restarts.


Re: Saving player position OnGameModeExit? - 1337connor - 06.03.2011

Get their pos and store it OnPlayerUpdate, then your usual SavePlayer will work perfectly.