function - 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: function (
/showthread.php?tid=316208)
function -
_ReloadeD_ - 05.02.2012
how I can convert a number to string?
for example I have the number 1569789, I want convert this number to string and the string will be: "1,569,789".
And so on, if I have the number 1000 then the string will be "1,000".
thanks for all helpers.
Re: function -
Mosslah - 05.02.2012
I'm not entirely sure how to do it, but you could perhaps try:
Valstr. Again, I have no idea, but I think that may help you? Sorry if it doesn't.
Re: function -
Cameltoe - 05.02.2012
pawn Код:
stock number_format(amount)
{
new
money[16],
negativ = 0;
if(amount < 0) negativ = 1;
format(money, sizeof(money), "%i", amount);
new
lenght = strlen(money);
while((lenght -= 3) > negativ) strins(money, ".", lenght);
return money;
}
// This would print 1.500
main()
{
prinft("%s", number_format(1500));
}
Re: function -
_ReloadeD_ - 07.02.2012
thanks