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



Currency format? - Jack_Leslie - 07.09.2011

How do you display a string as proper currency format? I found an old include that wasn't supported anymore, and I couldn't find anything else. So what I mean is, if you read from a players file and it's "20000", how do you display it as "20,000" or "20,000.00" (currency format)?


Re: Currency format? - PrawkC - 07.09.2011

Theres a few recent includes for this, but you'd use a textdraw to add the decimal


Re: Currency format? - Pghpunkid - 07.09.2011

There could be an easier way, but i think you could use a classy way of calculating using modulus (%) and division for the ones, tens and hundreds by doing value % 1000, thousands, ten thousands and hundred thousands by floor rounding the result of value / 1000, and so on. Then just use format for each break, and calculate cents.. not sure how you would like that done but thats how I would do it. Could take a little bit of tweaking initially but yeah.


Re: Currency format? - Jack_Leslie - 07.09.2011

Quote:
Originally Posted by PrawkC
Посмотреть сообщение
Theres a few recent includes for this, but you'd use a textdraw to add the decimal
Do you have the links to them? Only ones I can find are ones that give you ability to have cents, which isn't what I'm looking for, I'm looking for something to output a string as a currency format.


Re: Currency format? - RyDeR` - 07.09.2011

https://sampforum.blast.hk/showthread.php?tid=38965&p=843781


Re: Currency format? - Jack_Leslie - 07.09.2011

Quote:
Originally Posted by RyDeR`
Посмотреть сообщение
Thankyou! Just what I was looking for!


Re: Currency format? - Scenario - 08.09.2011

Grim_ released something a couple months ago. It should be beneficial to you.