AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   ... (https://forums.alliedmods.net/showthread.php?t=336110)

Cristian505 01-28-2022 11:37

...
 
...

Supremache 01-28-2022 11:44

Re: Request info
 
Change this szOutput[ iOutputPos++ ] = ',' to anything you want
Ex:
szOutput[ iOutputPos++ ] = ',' = 1,000,000
szOutput[ iOutputPos++ ] = '.' = 1.000.000
szOutput[ iOutputPos++ ] = ' ' = 1 000 000
etc

PHP Code:

// Credits to Bugsy
AddCommasiNum szOutput[ ] , iLen )
{
    new 
szTmp15 ] , iOutputPos iNumPos iNumLen;
    
    if ( 
iNum )
    {
        
szOutputiOutputPos++ ] = '-';
        
iNum absiNum );
    }
    
    
iNumLen num_to_striNum szTmp charsmaxszTmp ) );

    if ( 
iNumLen <= )
    {
        
iOutputPos += copyszOutputiOutputPos ] , iLen szTmp );
    }
    else
    {
        while ( ( 
iNumPos iNumLen ) && ( iOutputPos iLen ) ) 
        {
            
szOutputiOutputPos++ ] = szTmpiNumPos++ ];
        
            if( ( 
iNumLen iNumPos ) && !( ( iNumLen iNumPos ) % ) ) 
            
szOutputiOutputPos++ ] = ',';
        }
        
        
szOutputiOutputPos ] = EOS;
    }
    
    return 
iOutputPos;



Natsheh 01-29-2022 11:29

Re: Request info
 
PHP Code:

stock Seperate_Digital_Categories(const charSeperator=' ', const szString[], szValue[], len)
{
    new 
iStrLen strlen(szString), index = -1iCounts;

    while( ++
index iStrLen )
    {
        if(!
isdigit(szStringindex ]))
        {
            continue;
        }

        
iCounts++;
    }

    if(!
iCounts)
    {
        return 
false;
    }

    const 
CATEGORY_SIZE 3;

    new 
iSkip = (iCounts CATEGORY_SIZE), iCategory CATEGORY_SIZE iSkip;

    
index = -1;
    
iCounts 0;

    while( ++
index iStrLen )
    {
        if(!
isdigit(szStringindex ]))
        {
            continue;
        }

        if(++
iCounts)
        {
            if(
iCounts len)
            {
                
szValueiCounts-] = szStringindex ];
                break;
            }

            
szValueiCounts-] = szStringindex ];

            if((++
iCategory CATEGORY_SIZE) == 0)
            {
                
iCounts++;
                
szValueiCounts-] = charSeperator;
            }
        }
    }

    return 
true;


Tested works fine ! :)

Output:-

Code:

test_cmd "Hello 500 and 999 + 464567"
OUTPUT: 500 999 464 567

TEST CODE :-
Spoiler


All times are GMT -4. The time now is 06:11.

Powered by vBulletin®
Copyright ©2000 - 2022, vBulletin Solutions, Inc.