SA-MP Forums Archive
[Help] Float number alignment - 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: [Help] Float number alignment (/showthread.php?tid=197454)



[Help] Float number alignment - Proxyded - 09.12.2010

pawn Код:
format( myString, sizeof( myString ), " X = %04.02f~n~ Y = %04.02f~n~ Z = %04.02f~n~ A = %03.02f", c_x, c_y, c_z, c_a );
(It's gonna be used on a TextDraw, thats why I'm using ~n~ instead of \n)

I want it to show like:

Quote:

X = 0960.01
Y = 1000.50
Z = 0007.08
A = 050.80

I managed to do it with Integers, but how can I do it with Float points?

Thanks in advance.

EDIT#_____________________________________________ ______________

I am sorry, I should have explained a little more specific of what I wanted.

Imagine a digital clock:

Quote:

08:36 h
04:05 h

If you notice, it always shows a zero even if the hours/minutes value is below 10.
Quote:

X = 0960.01
Y = 1000.50
Z = 0007.08
A = 050.80

( the Angle never goes up from 360 so, I just want it to show 3 algoritms.

That's why I mentioned that I managed to do it with integers, if you do:
pawn Код:
printf( "%03d", 12 );
It will print:
Quote:

012




Re: [Help] Float number alignment - willsuckformoney - 09.12.2010

Your supposed to do it like this.

pawn Код:
new Float:X,Float:Y,Float:Z, myString[128]; GetPlayerPos(playerid,X,Y,Z);
format(myString,sizeof(myString),"X = %0.1f, Y = %0.1f, Z = %0.1f",X,Y,Z);
SendClientMessage(playerid,COLOR,myString);
print(myString);



Re: [Help] Float number alignment - The_Gangstas - 09.12.2010

lol..
pawn Код:
format( myString, sizeof( myString ), "X = %0.2f~n~Y = %0.2f~n~Z = %0.2ff~n~A = %3.2f", c_x, c_y, c_z, c_a);
that should do it?


Re: [Help] Float number alignment - Proxyded - 09.12.2010

warped this post to the first one


Re: [Help] Float number alignment - Proxyded - 11.12.2010

bump . . . .


Re: [Help] Float number alignment - Slice - 12.12.2010

http://pastebin.com/arZgz2Ah