Saving player position - 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)
+--- Thread: Saving player position (
/showthread.php?tid=349672)
Saving player position -
Subwoofer - 09.06.2012
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?
AW: Saving player position -
JhnzRep - 09.06.2012
pawn Код:
new Float:X, Float:Y, Float:Z
GetPlayerPos(playerid, X, Y, Z);
Then you put that into your register enum info and shit.
Re: Saving player position -
ricardo178 - 09.06.2012
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..