Raised This Month: $14 Target: $400

Put a comma in a number

Post New Thread Reply   
Thread Tools Display Modes
Author Message
Junior Member
Join Date: Jul 2017
Old 07-17-2017 , 14:56   Put a comma in a number
Reply With Quote #1

Hello everybody, How are you?

I would like to know how I make the plugin below read a number greater than or equal to 1000, but produces it with a comma separating thousands (1,000).


I already tried to contact the developer but he is no longer on the forum.

Last edited by papel; 07-17-2017 at 14:57. Reason: Wrong writing
papel is offline
AlliedModders Donor
Join Date: Sep 2009
Location: C:\Users\Default\
Old 07-17-2017 , 19:48   Re: Put a comma in a number
Reply With Quote #2

PHP Code:
stock int AddCommas(int iNumchar[] szOutputint iLen)
char szTmp[17];
int iOutputPosiNumPosiNumLen;
iNumLen IntToString(iNumszTmpsizeof(szTmp));
    if (
iNumLen <= 3)
iOutputPos += strcopy(szOutput[iOutputPos], iLenszTmp);
        while ((
iNumPos iNumLen) && (iOutputPos iLen)) 
szOutput[iOutputPos++] = szTmp[iNumPos++];
            if ((
iNumLen iNumPos) && !((iNumLen iNumPos) % 3)) 
szOutput[iOutputPos++] = ',';
szOutput[iOutputPos] = EOS;

Usage: AddCommas(number, buffer, sizeof(buffer));
PrintToChat(client, "Number: %d, Commas: %s", number, buffer);

Don't know if this is what you're looking for, i guessed by the title.
Massive Infection:: Piu-Games

Last edited by Desktop; 07-17-2017 at 19:51.
Desktop is offline
Junior Member
Join Date: Jul 2017
Old 07-18-2017 , 06:56   Re: Put a comma in a number
Reply With Quote #3

Fantastic. Thanks a lot for the help.
papel is offline

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -4. The time now is 13:57.

Powered by vBulletin®
Copyright ©2000 - 2023, vBulletin Solutions, Inc.
Theme made by Freecode