Saving player positions
#1

Can someone please explain to me how I can save and load the positions of a player

for eg. John walks to pizza stack and logs off. He comes back later and logs back in and spawns at his last location, in this case pizza stack.

I am using this system - https://sampforum.blast.hk/showthread.php?tid=273088

The script

http://pastebin.com/aV9sqeWn
Reply
#2

GetPlayerPos and SetPlayerPos and some basic scripting and Y_Ini knowledge is all you need.

Edit: Might need GetPlayerFacingAngle and SetPlayerFacingAngle too.
Reply
#3

How would I add those things into the script

(sorry im new to this, But learning fast)
Reply
#4

I found a tutorial on making the system save player positions but it wont load the position and spawn him.

What must I do?
Reply
#5

Show us the code of the loading.
Reply
#6

Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Float( "PosX", PosX[playerid]);
    INI_Float( "PosY", PosY[playerid]);
    INI_Float( "PosZ", PosZ[playerid]);
    INI_Float( "Angle", Angle[playerid]);
    INI_Int( "Interior", Interior[playerid]);
    INI_Int( "VirtualWorld", VirtualWorld[playerid]);
    return 1;
}
Код:
public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
        PosX[playerid] = 0;
	PosY[playerid] = 0;
    	PosZ[playerid] = 0;
    	Angle[playerid] = 0;
    	Interior[playerid]  = 0;
    	VirtualWorld[playerid] = 0;
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
    }
    return 1;
}
Reply
#7

Can anyone help please.

Really need this
Reply
#8

You need to save his position to a file OnPlayerDisconnect, and load from that when he re-connects.
Simple.
Reply
#9

It does save the last position to a file with all the other data.

The problem is that its not loading the positions from the file
Reply
#10

Can you show us your new codes with the position loading thingy?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)