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 AddCommas( iNum , szOutput[] , iLen )
{
new szTmp[ 17 ] , iOutputPos , iNumPos , iNumLen;
//if ( iNum < 0 )
//{
// szOutput[ iOutputPos++ ] = '-';
// iNum = abs( iNum );
//}
iNumLen = num_to_str( iNum , szTmp , charsmax( szTmp ) );
if ( iNumLen <= 3 )
{
iOutputPos += copy( szOutput[ iOutputPos ] , iLen , szTmp );
}
else
{
while ( ( iNumPos < iNumLen ) && ( iOutputPos < iLen ) )
{
szOutput[ iOutputPos++ ] = szTmp[ iNumPos++ ];
if( ( iNumLen - iNumPos ) && !( ( iNumLen - iNumPos ) % 3 ) )
szOutput[ iOutputPos++ ] = ',';
}
szOutput[ iOutputPos ] = 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 count, i, str[29], str2[35], len
num_to_str(number, str, charsmax(str))
len = strlen(str)
for (i = 0; i < len; i++)
{
if (i != 0 && ((len - i) %3 == 0))
{
add(str2, charsmax(str2), ".", 1)
count++
add(str2[i+count], 1, str[i], 1)
}
else
add(str2[i+count], 1, str[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.