Thread: Scripting Forum
View Single Post
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-19-2011 , 14:29   Re: Scripting Forum
Reply With Quote #28

Here's a new version with a few string handling functions changed around to use the ones that deal with bytes rather than cells (which are 4 bytes each).

PHP Code:
stock AddCommasiNumString:szOutput[] , iLen )
{
    new 
String:szTmp15 ] , iOutputPos iNumPos iNumLen;
    
    if ( 
iNum )
    {
        
szOutputiOutputPos++ ] = '-';
        
iNum = ~iNum 1// Two's complement conversion
    
}
    
    
IntToStringiNumszTmpsizeof(szTmp));
    
iNumLen strlen(szTmp);
    
    if ( 
iNumLen <= )
    {
        
iOutputPos += StrCatszOutput iLen szTmp );
    }
    else
    {
        while ( ( 
iNumPos iNumLen ) && ( iOutputPos iLen ) )
        {
            
szOutputiOutputPos++ ] = szTmpiNumPos++ ];
            
            if ( ( 
iNumLen iNumPos ) && !( (iNumLen iNumPos ) % ) )
            {
                
szOutputiOutputPos++ ] = ',';
            }
        }
        
        
szOutputiOutputPos ] = '\0';
    }
    
    return 
iOutputPos;

__________________
Not currently working on SourceMod plugin development.
Powerlord is offline