How can formatnumber?
#1

how to format a number

like this 2000 = 2,000
Reply
#2

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

invalid download link
Reply
#4

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 )) ;
Reply
#5

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

Код:
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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)