SA-MP Forums Archive
Saving Player Pos 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 Pos OnGameModeExit (/showthread.php?tid=252479)



Saving Player Pos OnGameModeExit - austin070 - 01.05.2011

I've been trying to find a way to do what the title says. However, I haven't found a way to do it yet. I know it's possible using OnPlayerUpdate, but that's a bit laggy and I don't like to do it. I've tried making a loop under OnGameModeExit and I've also tried saving position when GMX is called. None of it has worked. Anyone have an idea of what I could do?


Re: Saving Player Pos OnGameModeExit - Ubuntu - 01.05.2011

Ok, OnPlayerDisconnect: ''GetPlayerPos(playerid);'' This is what you need to put before the player goes offline. Once this is done you want to set his position to his old one.

It's all about logic bro.


Re: Saving Player Pos OnGameModeExit - Tommy_Mandaz - 01.05.2011

Yep something like this:
pawn Код:
new Float:savex, Float:savey, Float:savez;
GetPlayerPos(playerid, savex,savey,savez);
Then just save the savex, savey, savez to the player's file.
And Ubuntu is right you save their pos with onplayerdisconnect.


Re: Saving Player Pos OnGameModeExit - austin070 - 01.05.2011

I forgot to mention that I do have it under OnPlayerDisconnect. When I restart the server, it doesn't save the position, it sets it to 0,0,0 and sets my pos to 0,0,0 when the server is done restarting.


Re: Saving Player Pos OnGameModeExit - aircombat - 01.05.2011

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
    format(file,sizeof(file),"%s.ini",Name);
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid,X,Y,Z);
    dini_FloatSet(file,"PosX",X);
    dini_FloatSet(file,"PosY",Y);
    dini_FloatSet(file,"PosZ",Z);
    return 1;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
    new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
    format(file,sizeof(file),"%s.ini",Name);
    SetPlayerPos(playerid,dini_Int(file,"PosX"),dini_Int(file,"PosY"),dini_Int(file,"PosZ"));
    return 1;
}



Re: Saving Player Pos OnGameModeExit - austin070 - 01.05.2011

Quote:
Originally Posted by aircombat
Посмотреть сообщение
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
    format(file,sizeof(file),"%s.ini",Name);
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid,X,Y,Z);
    dini_FloatSet(file,"PosX",X);
    dini_FloatSet(file,"PosY",Y);
    dini_FloatSet(file,"PosZ",Z);
    return 1;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
    new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
    format(file,sizeof(file),"%s.ini",Name);
    SetPlayerPos(playerid,dini_Int(file,"PosX"),dini_Int(file,"PosY"),dini_Int(file,"PosZ"));
    return 1;
}
Pretty much exactly what I have.
pawn Код:
new file[128];
    format(file,sizeof(file),USER_FILE,GetPName(playerid));
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    dini_FloatSet(file, "LastX", X);
    dini_FloatSet(file, "LastY", Y);
    dini_FloatSet(file, "LastZ", Z);
pawn Код:
new file[128];
    format(file, sizeof(file), USER_FILE, GetPName(playerid));
    if(dead[playerid] == 0) {
        if(fexist(file)) {
            SetPlayerInterior(playerid, dini_Int(file, "LastInt"));
            SetPlayerPos(playerid, dini_Float(file, "LastX"), dini_Float(file, "LastY"), dini_Float(file, "LastZ"));
        }else {
            SetPlayerPos(playerid,1694.6157,1451.5208,10.7632);
        }
    }else {
        SetPlayerPos(playerid,1607.1754,1819.4937,10.8280);
        SetPlayerFacingAngle(playerid, 0.7049);
        SetCameraBehindPlayer(playerid);
    }