SA-MP Forums Archive
Saving spawn 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)
+--- Thread: Saving spawn pos (/showthread.php?tid=299728)



Saving spawn pos - Vic1990 - 27.11.2011

Okay so I have my enum all that etc.. Everything works fine compiles and everything. But how do I have it so it saves my position when I log off and puts it into my .ini file? I have
Код:
    INI_WriteInt(File,"PosX",PlayerInfo[playerid][pPosX]);
    INI_WriteInt(File,"PosY",PlayerInfo[playerid][pPosY]);
    INI_WriteInt(File,"PosZ",PlayerInfo[playerid][pPosZ]);
    INI_WriteInt(File,"RotX",PlayerInfo[playerid][pRotX]);
    INI_WriteInt(File,"RotY",PlayerInfo[playerid][pRotY]);
    INI_WriteInt(File,"RotZ",PlayerInfo[playerid][pRotZ]);
in my OnPlayerDisconnect callback but how do I get it so it reads my position and rotation of where I am and puts it into those categories? Sorry if I making it hard to understand but could you please help?


Re: Saving spawn pos - Joshb93 - 27.11.2011

pawn Код:
new Float:PosX, Float:PosY, Float:PosZ;
GetPlayerPos(playerid, PosX, PosY, PosZ);
If this is what your looking for, here ya go, if not, PM me


Re: Saving spawn pos - Vic1990 - 27.11.2011

It is what I am looking for just, I want to connect it to my enum for my .ini file so it reads it..


Re: Saving spawn pos - Joshb93 - 27.11.2011

I will also help you with this on TV


Re: Saving spawn pos - SmiT - 27.11.2011

pawn Код:
new
    Float: P[ 3 ]
;
GetPlayerPos( playerid, P[ 0 ], P[ 1 ], P[ 2 ] );

INI_WriteInt( File,"PosX", P[ 0 ] );
INI_WriteInt( File,"PosX", P[ 1 ] );
INI_WriteInt( File,"PosX", P[ 2 ] );



Re: Saving spawn pos - Vic1990 - 27.11.2011

Quote:
Originally Posted by SmiT
Посмотреть сообщение
pawn Код:
new
    Float: P[ 3 ]
;
GetPlayerPos( playerid, P[ 0 ], P[ 1 ], P[ 2 ] );

INI_WriteInt( File,"PosX", P[ 0 ] );
INI_WriteInt( File,"PosX", P[ 1 ] );
INI_WriteInt( File,"PosX", P[ 2 ] );
Код:
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(500) : warning 213: tag mismatch
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(501) : warning 213: tag mismatch
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(502) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
500 INI_WriteInt( File,"PosX", P[ 0 ] );
501 INI_WriteInt( File,"PosX", P[ 1 ] );
502 INI_WriteInt( File,"PosX", P[ 2 ] );


Re: Saving spawn pos - SmiT - 27.11.2011

My bad, it should be "INI_WriteFloat" -

pawn Код:
INI_WriteFloat( File,"PosX", P[ 0 ] );
INI_WriteFloat( File,"PosX", P[ 1 ] );
INI_WriteFloat( File,"PosX", P[ 2 ] );



Re: Saving spawn pos - Ash. - 27.11.2011

Quote:
Originally Posted by SmiT
Посмотреть сообщение
My bad, it should be "INI_WriteFloat" -

pawn Код:
INI_WriteFloat( File,"PosX", P[ 0 ] );
INI_WriteFloat( File,"PosX", P[ 1 ] );
INI_WriteFloat( File,"PosX", P[ 2 ] );
That code writes to "PosX" for all 3 co-ordinates?

You'll also need:
pawn Код:
new Float:rot;
GetPlayerFacingAngle(playerid, rot);
INI_WriteFloat(File, "PosRot", rot);
for the player's rotation/facing angle.

or, an addition to SmiT's code: (with fixed tag names)
pawn Код:
new
    Float: P[4]
;
GetPlayerPos(playerid, P[0], P[1], P[2]);
GetPlayerFacingAngle(playerid, P[3]);

INI_WriteFloat(File,"PosX", P[0]);
INI_WriteFloat(File,"PosY", P[1]);
INI_WriteFloat(File,"PosZ", P[2]);
INI_WriteFloat(FIle, "PosRot", P[3]



Re: Saving spawn pos - Vic1990 - 27.11.2011

THANKYOU!


Re: Saving spawn pos - Ash. - 27.11.2011

No problem