Raised This Month: $ Target: $400
 0% 

How to add a comma to a HUD message?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 02-05-2022 , 10:31   How to add a comma to a HUD message?
Reply With Quote #1

Hello. Can someone explain to me how to add a comma to the HUD Info message for health?

Here is an example of a HUD message:

Health: 5000 | Class: Zombie | Ammo: 30 | Armor: 0

Here is how the HUD message should look like:

Health: 5,000 | Class: Zombie | Ammo: 30 | Armor: 0

As you can see, the second HUD message has a comma where the stats of Health is – it’s “5,000”, instead of “5000”.

So, can someone explain to me how to add a comma?

I added the following code at the end of the source code of ZP:

PHP Code:
public AddCommasiNum szOutput[] , iLen )
{
    new 
szTmp17 ] , iOutputPos iNumPos iNumLen;
    
    
//if ( iNum < 0 )
    //{
    //    szOutput[ iOutputPos++ ] = '-';
    //    iNum = abs( iNum );
    //}
    
    
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;

However, it didn’t work, and there is still no comma.

Then, I added this to the code responsible for showing the HUD Info message:

PHP Code:
add_point(g_ammopacks[id
After that, I added the following code at the bottom of the source code of ZP:

PHP Code:
stock add_point(number)

    new 
countistr[29], str2[35], len
    num_to_str
(numberstrcharsmax(str))
    
len strlen(str)
    
    for (
0leni++)
    {
        if (
!= && ((len i) %== 0))
        {
            
add(str2charsmax(str2), "."1)
            
count++
            
add(str2[i+count], 1str[i], 1)
        }
        else
            
add(str2[i+count], 1str[i], 1)
    }

    return 
str2;

But, again, it didn’t work.

Maybe, I’m doing it the wrong way, or the codes are wrong?

The second code is about adding a point, not a comma. I prefer my HUD to have a comma, instead of a point, but if no one knows how to add exactly a comma, I will be ok with adding a point.

Thanks.

Last edited by GlobalPlague; 02-05-2022 at 10:32.
GlobalPlague is offline
 



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 11:44.


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