Saving Player Pos OnGameModeExit
#1

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?
Reply
#2

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

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

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

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

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);
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)