 |
|
Senior Member
Join Date: Feb 2016
Location: Pluto
|

02-15-2022
, 10:43
Re: How can i make ocixcrom level plugin to show 5,000/10,000Xp in hud?
|
#3
|
Quote:
Originally Posted by OciXCrom
This would require messing with the main code (crx_ranksystem.sma).
Add this function somewhere in the code (e.g. in the bottom):
PHP Code:
// Credits to Bugsy
AddCommas( iNum , szOutput[] , iLen )
{
new szTmp[ 15 ] , 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;
}
Then find the "update_hudinfo" function (line 1442).
You'll see this piece of code:
Code:
if(has_argument(szMessage, ARG_CURRENT_XP))
{
num_to_str(g_ePlayerData[id][XP], szPlaceHolder, charsmax(szPlaceHolder))
replace_string(szMessage, charsmax(szMessage), ARG_CURRENT_XP, szPlaceHolder)
}
This is how the XP is displayed - it converts the number into a string.
Simply change "num_to_str" to "AddCommas" and it should add commas to the number.
Do the same to the other portions of the code below this one - for ARG_NEXT_XP and ARG_XP_NEEDED.
|
This method doesn't work. I did exactly what you recommended, the .sma file got compiled without any errors or warnings, but there is still no comma.
|
|
|
|