Saving and loading the players pos? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Saving and loading the players pos? (
/showthread.php?tid=261746)
Saving and loading the players pos? -
DjAdy - 14.06.2011
How i save the position of a player when he logs off and then load it when he logs back in and spawns,
I tought of some floats like
new Float

,
Float:y,
Float:z;
Or something like it and putting them to get the xyz pos of him and saving it in a file , but i don't know how to exactly do it and i totaly suck at saving variables i don't even know how to save it to a file it's fcreate or something?
If someone can help me it'll be apreciated , thanks in advance.
Re: Saving and loading the players pos? -
xalith - 14.06.2011
pawn Код:
enum _PINFO
{ Float:pLastX,
Float:pLastY,
Float:pLastZ
}
new PVar[MAX_PLAYERS][_PINFO];
Under OnPlayerDisconnect add
pawn Код:
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
plastX = x;
plastY = y;
plastZ = z;
and save them to the players file.
under OnPlayerSpawn
pawn Код:
//some sort of check if the player has been on the server before
SetPlayerPos(playerid,plastX,plastY,plastZ);
hope that helped