Thread: [Solved] Add XP/skill to players name
View Single Post
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-19-2019 , 10:11   Re: Can't figure this out :)
Reply With Quote #21

May want to consider something simpler, like a HUD on the left or right side of the screen that shows all players and their skills. This would be easy to implement, and you can do things like show only alive players, show only team-mates, etc.

Also, my above code did not account for setting skill if the name already had the skill in it, I assumed you were handling this somehow. I know your problem is solved but you can use this as a backup if needed. I also added the ability to easily customize how the skill is displayed, see szSkillPrefix[] and szSkillSuffix[]. This is what encloses the skill at the end of the players name.
PHP Code:
public SetSkillInNameid szOutput[] , maxchars )
{
    new 
iNameLen szSkill10 ] , iSkillLen iSetPos Float:fSkill iBracketStart iBracketEnd iBracketSize;
    new const 
szSkillPrefix[] = " [ ";
    new const 
szSkillSuffix[] = " ]";
    
    
iNameLen get_user_nameid szOutput maxchars );
    
iBracketStart strfindszOutput szSkillPrefix );
    
iBracketEnd strfindszOutput szSkillSuffix , .pos=iBracketStart charsmaxszSkillPrefix ) );
    
iBracketSize charsmaxszSkillPrefix ) + charsmaxszSkillSuffix );
    
    if ( ( 
iBracketStart > -) && ( iBracketEnd > -) && ( ( iBracketEnd charsmaxszSkillSuffix ) ) == iNameLen ) )
        
iNameLen iBracketStart;
    
    
get_user_skillid fSkill );
    
iSkillLen formatexszSkill charsmaxszSkill ) , "%0.2f" fSkill );
    
iSetPos = ( ( iNameLen iSkillLen iBracketSize ) > maxchars  ) ? maxchars - ( iSkillLen iBracketSize ) : iNameLen;
    
    return 
formatexszOutputiSetPos ] , maxchars iSetPos "%s%s%s" szSkillPrefix szSkill szSkillSuffix );

__________________

Last edited by Bugsy; 01-19-2019 at 11:35.
Bugsy is offline