Raised This Month: $ Target: $400
 0% 

How can i make ocixcrom level plugin to show 5,000/10,000Xp in hud?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
StickBarosanu
Junior Member
Join Date: Aug 2020
Old 12-20-2021 , 14:50   How can i make ocixcrom level plugin to show 5,000/10,000Xp in hud?
Reply With Quote #1

Hi! I want to make the xp hud to look like 5,000/10,000xp instead of 5000/10000xp. I'm using ocixcrom level system plugin

I want to make this:https://i.imgur.com/pEyajk0_d.webp?m...fidelity=grand


To look like this one:https://i.imgur.com/XeBntCb.jpg

Thank you!!

Last edited by StickBarosanu; 12-20-2021 at 14:52.
StickBarosanu is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-20-2021 , 15:04   Re: How can i make ocixcrom level plugin to show 5,000/10,000Xp in hud?
Reply With Quote #2

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
AddCommasiNum szOutput[] , iLen )
{
    new 
szTmp15 ] , iOutputPos iNumPos iNumLen;
    
    if ( 
iNum )
    {
        
szOutputiOutputPos++ ] = '-';
        
iNum absiNum );
    }
    
    
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;

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.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 02-15-2022 , 10:43   Re: How can i make ocixcrom level plugin to show 5,000/10,000Xp in hud?
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
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
AddCommasiNum szOutput[] , iLen )
{
    new 
szTmp15 ] , iOutputPos iNumPos iNumLen;
    
    if ( 
iNum )
    {
        
szOutputiOutputPos++ ] = '-';
        
iNum absiNum );
    }
    
    
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;

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.
GlobalPlague is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-15-2022 , 13:37   Re: How can i make ocixcrom level plugin to show 5,000/10,000Xp in hud?
Reply With Quote #4

Impossible. Post the full code with your changes.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 02-16-2022 , 17:42   Re: How can i make ocixcrom level plugin to show 5,000/10,000Xp in hud?
Reply With Quote #5

Quote:
Originally Posted by OciXCrom View Post
Impossible. Post the full code with your changes.
Wait... it was my mistake.

I forgot i edited your plugin a little bit.

The AddCommas function works only for the original HUD message of your plugin, but doesn't work for the edited HUD message.

My ZM server doesn't use the original HUD message. Instead, i disabled it:

Code:
HUDINFO_ENABLED = 1
===>

Code:
HUDINFO_ENABLED = 0
I had to enable the original HUD, so i can see the comma, and realize the AddCommas function actually works perfectly.

See this screenshot: https://pasteboard.co/X1vmEk3HoSoa.jpg

As you can see in the image above, the AddCommas function works only for the original HUD, but not for the edited HUD - the HUD added in the ZP HUD info message.

I would like the original HUD to be disabled, so only the edited HUD to remain. In other words, i want the comma to be added to the HUD rank message that is part of the ZP HUD info message.

Do you understand what I'm talking about? My English is bad, but i will try explaining better, if you don't understand me.

Last edited by GlobalPlague; 02-16-2022 at 17:43.
GlobalPlague is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 02-16-2022 , 17:57   Re: How can i make ocixcrom level plugin to show 5,000/10,000Xp in hud?
Reply With Quote #6

This function should work in any plugin with any code but make sure you are Use it correctly.

PHP Code:
if (id != ID_SHOWHUD)
{
    
// Show name, health, class, and ammo packs and armor
    
set_dhudmessage(00138HUD_SPECT_XHUD_SPECT_Y16.01.10.00.0)
    
show_dhudmessage(ID_SHOWHUD"%L %s^nHP: %d - %L %s - %L %d - %L %d"ID_SHOWHUD"SPECTATING"g_playername[id],
    
pev(idpev_health), ID_SHOWHUD"CLASS_CLASS", class, ID_SHOWHUD"AMMO_PACKS1"g_ammopacks[id], ID_SHOWHUD"ARMOR"pev(idpev_armorvalue))
}
else
{
    new 
szXPCommas16 ], szNextXPCommas16 ], szAPCommas16 ];
    
AddCommasmysystem_get_user_xpid ), szXPCommascharsmaxszXPCommas ) );
    
AddCommasmysystem_get_user_next_xp(id), szNextXPCommascharsmaxszNextXPCommas ) );
    
AddCommasg_ammopacks[id], szAPCommascharsmaxszAPCommas ) );
    
    
set_dhudmessage(redgreenblueHUD_STATS_XHUD_STATS_Y06.01.10.00.0)
    
show_dhudmessage(ID_SHOWHUD"%L: %d - %L %s - %L %d - %L %d^nXP: %s/%s | Level: %d/%d: %s"id"ZOMBIE_ATTRIB1"pev(ID_SHOWHUDpev_health), ID_SHOWHUD"CLASS_CLASS",
    class, 
ID_SHOWHUD"AMMO_PACKS1"g_ammopacks[ID_SHOWHUD], ID_SHOWHUD"ARMOR"pev(ID_SHOWHUDpev_armorvalue), szXPCommasszNextXPCommasmysystem_get_user_level(id), mysystem_get_max_levels(), ranknameszAPCommas )

__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 02-16-2022 , 19:35   Re: How can i make ocixcrom level plugin to show 5,000/10,000Xp in hud?
Reply With Quote #7

Quote:
Originally Posted by Supremache View Post
This function should work in any plugin with any code but make sure you are Use it correctly.

PHP Code:
if (id != ID_SHOWHUD)
{
    
// Show name, health, class, and ammo packs and armor
    
set_dhudmessage(00138HUD_SPECT_XHUD_SPECT_Y16.01.10.00.0)
    
show_dhudmessage(ID_SHOWHUD"%L %s^nHP: %d - %L %s - %L %d - %L %d"ID_SHOWHUD"SPECTATING"g_playername[id],
    
pev(idpev_health), ID_SHOWHUD"CLASS_CLASS", class, ID_SHOWHUD"AMMO_PACKS1"g_ammopacks[id], ID_SHOWHUD"ARMOR"pev(idpev_armorvalue))
}
else
{
    new 
szXPCommas16 ], szNextXPCommas16 ], szAPCommas16 ];
    
AddCommasmysystem_get_user_xpid ), szXPCommascharsmaxszXPCommas ) );
    
AddCommasmysystem_get_user_next_xp(id), szNextXPCommascharsmaxszNextXPCommas ) );
    
AddCommasg_ammopacks[id], szAPCommascharsmaxszAPCommas ) );
    
    
set_dhudmessage(redgreenblueHUD_STATS_XHUD_STATS_Y06.01.10.00.0)
    
show_dhudmessage(ID_SHOWHUD"%L: %d - %L %s - %L %d - %L %d^nXP: %s/%s | Level: %d/%d: %s"id"ZOMBIE_ATTRIB1"pev(ID_SHOWHUDpev_health), ID_SHOWHUD"CLASS_CLASS",
    class, 
ID_SHOWHUD"AMMO_PACKS1"g_ammopacks[ID_SHOWHUD], ID_SHOWHUD"ARMOR"pev(ID_SHOWHUDpev_armorvalue), szXPCommasszNextXPCommasmysystem_get_user_level(id), mysystem_get_max_levels(), ranknameszAPCommas )

So, firstly, i have to add Bugsy's AddCommas code at the bottom of the main ZPA source code, and then use the code you gave me. Did i understand you correctly?
GlobalPlague is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 02-16-2022 , 20:58   Re: How can i make ocixcrom level plugin to show 5,000/10,000Xp in hud?
Reply With Quote #8

Quote:
Originally Posted by GlobalPlague View Post
So, firstly, i have to add Bugsy's AddCommas code at the bottom of the main ZPA source code, and then use the code you gave me. Did i understand you correctly?
Yes, but i want you learn how to use it!!
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-17-2022 , 14:20   Re: How can i make ocixcrom level plugin to show 5,000/10,000Xp in hud?
Reply With Quote #9

If you're using a different plugin for the HUD, of course you need to add the AddCommas function there.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Reply



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:42.


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