SA-MP Forums Archive
Formatting number - I will +rep - 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: Formatting number - I will +rep (/showthread.php?tid=524980)



Formatting number - I will +rep - friezakinght - 09.07.2014

Hi guys, how can I make that when I have 50000 cash it actually shows 50.000? Please help me I will +rep


Re: Formatting number - I will +rep - rockhopper - 09.07.2014

FIRSTLY We do NOT WORK ON REP!!!!!!!!

What do you mean by this :- how can I make that when I have 50000 cash it actually shows 50.000? ? ? ?


Re: Formatting number - I will +rep - Stanford - 09.07.2014

I hope I helped:

pawn Код:
new cashtring[32];
            new cash= pData[id][pCash];
            new j = valstr(cashstring,cash);
            while(j >= 4) { j -= 3; strins(cashstring,",",j); }
I hope I helped, any feedback would be appreciated!.


Re: Formatting number - I will +rep - friezakinght - 09.07.2014

Doesn't work, it's still 50000, any other code?


Re: Formatting number - I will +rep - Dziugsas - 09.07.2014

Use it as a float instead of integer


Re: Formatting number - I will +rep - Djole1337 - 09.07.2014

pawn Код:
// I've no idea who made it.
stock FormatNumber(number) {
    new szString[13];
 
    format(szString,sizeof(szString), "%d", number);
 
    if (strlen(szString) < 4)
        return szString;
 
    new iPos = strlen(szString), iCount = 1;
 
    while (iPos) {
        if(iCount == 4) {
            iCount = 0;
            strins(szString,",",iPos,1);
            iPos ++;
        }

        iCount ++;
        iPos --;
    }
    return szString;
}



Re: Formatting number - I will +rep - friezakinght - 09.07.2014

EDIT: Doesn't work, it says 50$ instead of 25,000$