Saving player position OnGameModeExit?
#1

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

Make a loop or use OnPlayerDisconnect
Reply
#3

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.
Reply
#4

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;
}
Reply
#5

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.
Reply
#6

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

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.
Reply
#8

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.
Reply
#9

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


Forum Jump:


Users browsing this thread: 1 Guest(s)