View Single Post
Croxeye
Member
Join Date: Jul 2015
Old 02-04-2016 , 17:01   Re: Show player rank while spectating
Reply With Quote #3

Try this, not tested.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <csstats>
#include <fakemeta>

#define PLUGIN "Spec Rank"
#define VERSION "1.0"
#define AUTHOR "Croxeye"

new g_SpecInfo

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)

    
set_task(1.0"SpecInfo"___"b")

    
g_SpecInfo CreateHudSyncObj()
}

public 
SpecInfo()
{
    new 
players[32], num 
    get_players
(playersnum"ch")
    
    new 
idtargetszTargetName[32]
    
    
target pev(idpev_iuser2)
    
    
set_hudmessage(085255, -1.00.7506.01.0)
    
    for(new 
inumi++)
    {
        
id players[i]
        
        if(!
is_user_alive(id))
        {
            
            if(!
target)
                continue
                
            if(
is_user_alive(target))
            {
                return 
PLUGIN_HANDLED;
            }
            
            
get_user_name(targetszTargetNamecharsmax(szTargetName))
            new 
stats[8], body[8]
            new 
rank_pos get_user_stats(targetstatsbody)
            new 
rank_max get_statsnum()
            
            
ShowSyncHudMsg(idg_SpecInfo"Spectating: %s ® Rank: %d of %d"szTargetNamerank_posrank_max)
        }
    }
    return 
PLUGIN_HANDLED;

Or just change this:

PHP Code:
len format(buffercharsmax(buffer), "%L",LANG_PLAYER,"RANK"); 
to this:

PHP Code:
len format(buffercharsmax(buffer), "%L %d",LANG_PLAYER,"RANK"rank_pos); 
and you need to define rank_pos

PHP Code:
new stats[8], body[8]
new 
rank_pos get_user_stats(idstatsbody

Last edited by Croxeye; 02-04-2016 at 17:12.
Croxeye is offline