Saving player position
#1

Like the title says, i want server to save player position when he leaves the server, like when i leave the server and come back then i spawn there, where i left the server. Any ideas?
Reply
#2

pawn Код:
new Float:X, Float:Y, Float:Z
GetPlayerPos(playerid, X, Y, Z);
Then you put that into your register enum info and shit.
Reply
#3

You have to:

Create 3 floats in player file on registering, with the start point position.
Make it save that positions under OnPlayerDisconnect.
Make it load them on login.
Make player spawn in them under OnPlayerSpawn, using SetPlayerPos..

An example from my game-mode.

pawn Код:
On the player enum.

LastX,
LaxtY,
LastZ,
LastInt,
LastVw,

On ym registering system.

dini_FloatSet(file, "LastX", -2112.3652);
dini_FloatSet(file, "LastY", -2488.1548);
dini_FloatSet(file, "LastZ", 30.6250);
dini_IntSet(file, "LastInt", 0);
dini_IntSet(file, "LastVw", 0);

This is after checking player file, under OnPlayerSpawn, as i take it directly from the file....

SetPlayerVirtualWorld(playerid, dini_Int(file, "LastVw"));
SetPlayerInterior(playerid, dini_Int(file, "LastInt"));
SetPlayerPos(playerid, dini_Int(file, "LastX"), dini_Int(file, "LastY"), dini_Int(file, "LastZ"));

And under OnPlayerDisconnect:

new Float:px, Float:py, Float:pz, lint, lvw;
GetPlayerPos(playerid, px, py, pz);
lint = GetPlayerInterior(playerid);
lvw = GetPlayerVirtualWorld(playerid);

dini_FloatSet(file, "LastX", Float:px);
dini_FloatSet(file, "LastY", Float:py);
dini_FloatSet(file, "LastZ", Float:pz);
dini_IntSet(file, "LastInt", lint);
dini_IntSet(file, "LastVw", lvw);
Warning: Copy pasting my code wont work at all..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)