Making savepos/loadpos (save when disconnect)
#1

i'm making a server. i want to know how to script save position on playerdisconnect and load it onplayerspawn
just like other RP.
Reply
#2

Make a folder "Positions" inside the your_server/scriptfiles/
Of course without the ""
How to save them by using Dini.
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new pName[24], PlayerFile[50];
    new Float:PX, Float:PY, Float:PZ;
   
    GetPlayerName(playerid, pName, sizeof(pName));
    format(PlayerFile, sizeof(PlayerFile), "Positions/%s.ini", pName);
   
    GetPlayerPos(playerid, PX, PY, PZ);
   
    PlayerInfo[playerid][PlayerX] = PX;
    PlayerInfo[playerid][PlayerY] = PY;
    PlayerInfo[playerid][PlayerZ] = PZ;
   
    dini_FloatSet(PlayerFile, "PlayerX", PlayerInfo[playerid][PlayerX]);
    dini_FloatSet(PlayerFile, "PlayerY", PlayerInfo[playerid][PlayerY]);
    dini_FloatSet(PlayerFile, "PlayerZ", PlayerInfo[playerid][PlayerZ]);
    dini_IntSet(PlayerFile, "Spawn", 2);
   
    return 1;
}
Reply
#3

thanks now the problem is how can i set it in OnPlayerspawn i try it before in my older RP Scripts and it spawns me in default location of my RP Server spawnpoint
Reply
#4

I am not sure. I am not at my pc and I can't test it before post soemthing.
pawn Код:
public OnPlayerSpawn(playerid)
{
    new pName[24], PlayerFile[50];

    GetPlayerName(playerid, pName, sizeof(pName));
    format(PlayerFile, sizeof(PlayerFile), "Positions/%s.ini", pName);

    PlayerInfo[playerid][PlayerX] = dini_Float(PlayerFile, "PlayerX");
    PlayerInfo[playerid][PlayerY] = dini_Float(PlayerFile, "PlayerY");
    PlayerInfo[playerid][PlayerZ] = dini_Float(PlayerFile, "PlayerZ");

    return SetPlayerPos(playerid, dini_Float(PlayerFile, "PlayerX"), dini_Float(PlayerFile, "PlayerY"), dini_Float(PlayerFile, "PlayerZ"));
}
Reply
#5

thanks but i made my own code onplayerspawn how ever thank you very much
Reply
#6

Quote:
Originally Posted by TheLonelyMoo
Посмотреть сообщение
thanks but i made my own code onplayerspawn how ever thank you very much
Okay! Good Luck and your Welcome!
Reply
#7

nice
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)