Convert $10000 into $10,000 - 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: Convert $10000 into $10,000 (
/showthread.php?tid=402316)
Convert $10000 into $10,000 -
dr.lozer - 26.12.2012
How to convert like this??
$10000 into $10,000
any function please??
saw on many server like this style
Re: Convert $10000 into $10,000 -
ReneG - 26.12.2012
From the sa-mp wiki, there are plenty of other ones in the useful functions thread. Search
pawn Код:
stock addCommas(number)
{
new
tStr[13]; // Up to 9,999,999,999,999
format(tStr,sizeof(tStr),"%d",number);
if(strlen(tStr) < 4)
return tStr;
new
//rNumber = floatround((number+(number/3)),floatround_floor),
iPos = strlen(tStr),
iCount = 1;
while(iPos > 0) {
if(iCount == 4) {
iCount = 0;
strins(tStr,",",iPos,1);
iPos ++;
}
iCount ++;
iPos --;
}
return tStr;
}
Re: Convert $10000 into $10,000 -
dr.lozer - 26.12.2012
Quote:
Originally Posted by VincentDunn
From the sa-mp wiki, there are plenty of other ones in the useful functions thread. Search
pawn Код:
stock addCommas(number) { new tStr[13]; // Up to 9,999,999,999,999 format(tStr,sizeof(tStr),"%d",number); if(strlen(tStr) < 4) return tStr; new //rNumber = floatround((number+(number/3)),floatround_floor), iPos = strlen(tStr), iCount = 1; while(iPos > 0) { if(iCount == 4) { iCount = 0; strins(tStr,",",iPos,1); iPos ++; } iCount ++; iPos --; } return tStr; }
|
Thanks!
Re: Convert $10000 into $10,000 -
Lorenc_ - 26.12.2012
Search "ConvertPrice" in the Useful Functions Topic. You will find an optimized version by RyDeR` which I HIGHLY recommend.