SA-MP Forums Archive
How can formatnumber? - 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: How can formatnumber? (/showthread.php?tid=662073)



How can formatnumber? - rockys - 23.12.2018

how to format a number

like this 2000 = 2,000


Re: How can formatnumber? - SyS - 23.12.2018

https://sampforum.blast.hk/showthread.php?tid=184328


Re: How can formatnumber? - rockys - 23.12.2018

Quote:
Originally Posted by SyS
Посмотреть сообщение
invalid download link


Re: How can formatnumber? - Dignity - 23.12.2018

pawn Код:
IntegerWithDelimiter(integer, delimiter[] = ",") {
    new string[16];

    format(string, sizeof string, "%i", integer);

    for (new i = strlen(string) - 3, j = ((integer < 0) ? 1 : 0); i > j; i -= 3) {

        strins(string, delimiter, i, sizeof string);
    }

    return string;
}
Usage:

pawn Код:
format(string, sizeof ( string ), "$ %s", IntegerWithDelimiter (1000000 )) ;



Re: How can formatnumber? - DAKYSKYE - 23.12.2018

Use pawn-humanize. https://sampforum.blast.hk/showthread.php?tid=657062


Re: How can formatnumber? - TheToretto - 23.12.2018

Код:
convertNumber(value)
{
    // http://forum.sa-mp.com/showthread.ph...781#post843781
    new string[24];
    format(string, sizeof(string), "%d", value);
    for(new i = (strlen(string) - 3); i > (value < 0 ? 1 : 0) ; i -= 3)
    {
        strins(string[i], ",", 0);
    }
    return string;
}