Raised This Month: $ Target: $400
 0% 

Show player rank while spectating


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-22-2016 , 12:24   Re: Show player rank while spectating
Reply With Quote #6

I'm not sure how much this will affect server performance, you may see impacts if your csstats.dat file is large. I couldn't test this because I have only bots to work with and they are not ranked in my test configuration.

I used ConnorMcLeod's Spectator Hud Information as a base and made some modifications.
PHP Code:
//Used ConnorMcLeods plugin as base: https://forums.alliedmods.net/showthread.php?p=1469706

#include <amxmodx>
#include <engine>
#include <csx>

new const Version[] = "0.1";

const 
FirstPersonView 4;
const 
Float:fRefreshInterval 0.25;

new 
g_HUDSyncObj;

public 
plugin_init() 
{
    
register_plugin"Spec Rank Info" Version "bugsy" );
    
    new 
iEntity create_entity"info_target" );
    
entity_set_stringiEntity EV_SZ_classname "SpecHUDEntity" );
    
register_think"SpecHUDEntity" "SpecHUDThink" );
    
entity_set_floatiEntity EV_FL_nextthink get_gametime() + fRefreshInterval );
    
    
g_HUDSyncObj CreateHudSyncObj();
}

public 
SpecHUDThinkiEntity )
{
    new 
iAlivePlayers32 ] , iDeadPlayers32 ] , iAliveNum iDeadNum iAlivePlayer iDeadPlayer;
    new 
iRank iStats] , iBodyHits] , szName32 ] , bool:bRetrievedData;
    
    
entity_set_floatiEntity EV_FL_nextthink get_gametime() + fRefreshInterval );
    
    
get_playersiAlivePlayers iAliveNum "a" );
    
    if( !
iAliveNum )
        return
    
    
get_playersiDeadPlayers iDeadNum "bch" );
    
    if( !
iDeadNum )
        return    
    
    for ( new 
iAlive iAlive iAliveNum iAlive++ )
    {
        
iAlivePlayer iAlivePlayersiAlive ];
        
        
bRetrievedData false;
        
        for( new 
iDead iDead iDeadNum iDead++ )
        {
            
iDeadPlayer iDeadPlayersiDead ];
            
            if ( 
entity_get_intiDeadPlayer EV_INT_iuser2 ) == iAlivePlayer && entity_get_intiDeadPlayer EV_INT_iuser1 ) == FirstPersonView )
            {
                if ( 
bRetrievedData == false )
                {
                    
get_user_nameiAlivePlayer szName charsmaxszName ) );
                    
iRank get_user_statsiAlivePlayer iStats iBodyHits );
                    
bRetrievedData true;
                }
                
                
ClearSyncHudiDeadPlayer g_HUDSyncObj );
                
set_hudmessage255 255 255 , -1.0 0.25 , .holdtime=0.5 , .channel=-);
                
ShowSyncHudMsgiDeadPlayer g_HUDSyncObj "%s^nRank: %d^nKills: %d^nDeaths: %d" szName iRank iStats] , iStats] );
            }
        }
    }

__________________

Last edited by Bugsy; 10-22-2016 at 22:46.
Bugsy is offline
 



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 09:29.


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