How to separate numbers by comma?
#1

Hi, if possible, I wish someone would create a function to do so:

pawn Код:
Comma(value);
Where the value would be a number. This function Comma(value) return the string value with the commas.

For example:

pawn Код:
new money, str[110];
money = 1500;
format(str, sizeof(str), "You have %s", Comma(money));
SendClientMessage(playerid, cor, str);
The result would be:

You have 1,500

I appreciate the help.
Reply
#2

Slice has already created this.
Reply
#3

Quote:
Originally Posted by jameskmonger
Посмотреть сообщение
Slice has already created this.
You can send me the link of this topic then?

@edit: I find it, thank you James, any moderator, please close this topic.
Reply
#4

I made you a function, hopefully this is what you want

pawn Код:
stock Comma(numbers) //by Gamer931215
{
    new temp[24],counter = -1;
    valstr(temp,numbers);
    for(new i = strlen(temp);i > 0; i--)
    {
        counter++;
        if(counter == 3)
        {
            strins(temp,",",i);
            counter = 0;
        }
    }
    return temp;
}
Edit: oh did slice ? well anyways this should work as well
Reply
#5

You're welcome, enjoy.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)