SA-MP Forums Archive
Integers - 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: Integers (/showthread.php?tid=524125)



Integers - kamiliuxliuxliux - 05.07.2014

Hey, how can I replace my integer '6' with '06' in strings?


Re: Integers - BroZeus - 05.07.2014

like this
pawn Код:
new integer = 6,string[10];
format(string, sizeof(string), "0%i", integer);



Re: Integers - kamiliuxliuxliux - 05.07.2014

Something like that. But for example about seconds? If integer is one (5 or 7), your example is right, but if there are two integers (26 or 45), then integer would be 026 or 045.


Re: Integers - BroZeus - 05.07.2014

like this then
pawn Код:
if(integer>=0 && integer < 10)format(string, sizeof(string), "0%i", integer);
else format(string, sizeof(string), "%i", integer);



Re: Integers - Vince - 05.07.2014



pawn Код:
%02d



Re: Integers - kamiliuxliuxliux - 05.07.2014

Thanks for both of you.