SA-MP Forums Archive
Problem with my variable - 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: Problem with my variable (/showthread.php?tid=326188)



Problem with my variable - jcvag44800 - 16.03.2012

Hi guys.

I have a problem with my variable.
Here is my code:

Код:
   GetPlayerPos(playerid,x,y,z);
   pos1 = GetPlayerPos(playerid,x,y,z);
   format(string,sizeof string,"Ancienne position: %f | Position actuel: %f",GetPlayerPos(playerid,x,y,z),GetPlayerPos(playerid, x2,y2,z2));
   SendClientMessageToAll(0xFFFFFFAA,string);
And it shows me:

Ancienne position: 0.0000 | Position actuel: 0.0000

How to solve this problem?

Cordially;


Re: Problem with my variable - Babul - 16.03.2012

you need to format each float (x,y and z) on its own - GetPlayerPos() doesnt return anything..
pawn Код:
GetPlayerPos(playerid,x,y,z);
    format(string,sizeof string,"Ancienne position: %4.1f %4.1f %4.1f",x,y,z);
    SendClientMessageToAll(0xFFFFFFAA,string);
what are the x2 y2 and z2 variables meant for? a second player? or is it an "old" position you want to show?
anyways, this piece of code should work...
oh i was so free to format the float numbers like 1200.6 450.5 -2300.0 - it looks better, i bet nobody needs a precision more than 0.1 units (10 cm), you can change the %4.1f to "%4.2f" or "%4.4f" in case you need more precision


Re: Problem with my variable - Jonny5 - 16.03.2012

x,y,z store the cords NOT pos1
something like this provided you have declared all vars correctly
pawn Код:
format(string,sizeof string,"Ancienne position: %f,%f,%f | Position actuel: %f,%f,%f",x,y,z,x2,y2,z2);



Re : Problem with my variable - jcvag44800 - 17.03.2012

Thanks =)