View Single Post
Author Message
mehelp
Junior Member
Join Date: Jul 2011
Old 07-20-2011 , 23:36   Displaying stats issue (adding comma separator)
Reply With Quote #1

using l4d2 Custom Player Stats plugin by muukis, was trying to adopt displaying stats to what I'd prefer. got 2 issues to ask about
1.got problem adding comma separator between digits to player's points number.
stats are shown on infected death this way:
Name (1222) got points for killing infected
PHP Code:
GetClientName(iNamesizeof(Name));
CPrintToChat(i"{blue}%s \x01(%i) got points for killing Infected"Name, (ClientPoints[i] + CurrentPoints[i])); 
What I'd want it to look like:
Name (1,222) got poitns for killing infected - with comma after first digit

Powerlord made "port of the AddCommas function to SourceMod.
SourceMod only has a float absolute value function."

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;

tried to call it:
PHP Code:
new String:szPoints[15];
GetClientName(iNamesizeof(Name));
AddCommas((ClientPoints[i] + CurrentPoints[i]), szPointssizeof(szPoints));
CPrintToChat(i"{blue}%s \x01(%s) got points for killing Infected"NameszPoints); 
didn't work. been desperately trying to add this bloody comma for days with no effect, need help

2. another thing about displaying stats - dealing with special infected, for exapmple:
"Name(1,111) got points for (1)Boomer" , VictimName (Boomer) is shown with number in front of it, if there's few of them currently spawned on the map; like when you look at players list thru adminmenu - it says:
1. Hunter
2. (1)Hunter,
when there's couple of infected of the same type. but when you killed (1)Boomer, you can assume there's more nearby, which should be a surprise I suppose. is it possible to remove characters in front of infected name?

Last edited by mehelp; 07-20-2011 at 23:48.
mehelp is offline