Raised This Month: $ Target: $400
 0% 

[REQ] Hud Msg for alive players


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 05-02-2023 , 16:36   Re: [REQ] Hud Msg for alive players
Reply With Quote #10

This will accurately count and display in team colors. Green for hostages.
PHP Code:
/*Spin-off idea derived from request by malec321*/
#include <amxmodx>
#include <engine_stocks>
#include <fakemeta>

#define PLUGIN  "!Alive"
#define VERSION "1.0.1"
#define AUTHOR  "SPiNX | vato loco [GE-S]"

#define TASK_GETPLAYER    37852
#define TASK_LOOP_TIME    1.0

#define SetBits(%1,%2)       %1 |=   1<<(%2 & 31)
#define ClearBits(%1,%2)     %1 &= ~(1<<(%2 & 31))
#define GetBits(%1,%2)       %1 &    1<<(%2 & 31)

#if !defined client_disconnect
#define client_disconnected client_disconnect
#endif

#define charsmin -1

new g_AIg_cvar_contg_continuousg_rescue
static g_Hostie

static g_SyncTeamCount_CT,  g_SyncTeamCount_Hg_SyncTeamCount_T

new const szEnt[] = "hostage_entity"
new const szRescue[] = "2=Rescued_A_Hostage"
new const CvarDesc[] = "Show who is alive as round ends. 2 is debugger."

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
g_SyncTeamCount_CT CreateHudSyncObj()
    
g_SyncTeamCount_H CreateHudSyncObj()
    
g_SyncTeamCount_T CreateHudSyncObj()

    
register_logevent("@rescue"3szRescue)
    
register_logevent("@LogEvent_Round_Start"2"1=Round_Start")
    
g_continuous register_logevent("@Logevent_Round_End"2"1=Round_End")
    
bind_pcvar_num(create_cvar("continuous_player_alive""0",FCVAR_SERVERCvarDesc,.has_min true, .min_val 0.0, .has_max true, .max_val 2.0), g_cvar_cont)
    
g_Hostie has_map_ent_class(szEnt) ? 0
    state OFF
}

@
rescue()
    ++
g_rescue

@LogEvent_Round_Start()
{
    
g_rescue 0
    state ON
    
@solid_state()

    
g_cvar_cont disable_logevent(g_continuous) : enable_logevent(g_continuous)
}

@
Logevent_Round_End()
    @
solid_state()

public 
client_putinserver(id)
{
    if(
is_user_connected(id) && is_user_bot(id))
    {
        
SetBits(g_AIid)
    }
}

public 
client_disconnected(id)
    
ClearBits(g_AIid)

@
solid_state()<ON>{set_task(TASK_LOOP_TIME"@GetPlayers"TASK_GETPLAYER, .flags="b");if(g_cvar_cont>1)server_print("%s is on..."PLUGIN);}

@
solid_state()<OFF>{remove_taskTASK_GETPLAYER );if(g_cvar_cont>1)server_print("%s is off.."PLUGIN);}

@
GetPlayers()
{
    new
    
ALIVE,
    
R,G,Bid,
    
Float:XFloat:Y,
    
iPlayers[MAX_PLAYERS], iNumiTnumiCTnum;

    
get_players(iPlayersiNum"a")

    if(
iNum)
    {
        for(new 
ALIVEALIVE iNum; ++ALIVE)
        {
            switch( 
get_user_teamiPlayers[ALIVE] ) )
            {
                case 
1: ++iTnum
                
case 2: ++iCTnum
            
}
        }

        
id iPlayers[ALIVE]

        if(
iTnum && iCTnum)
        {
            if(~
GetBits(g_AIid))
            {
                
2550.391;
                
set_hudmessage(RGBXY__TASK_LOOP_TIME+0.01_,  _1)

                
ShowSyncHudMsg(idg_SyncTeamCount_T"[Alive T: %d]"iTnum)

                
0255=0.54;
                
set_hudmessage(RGBXY__TASK_LOOP_TIME+0.01_,  _1)

                
ShowSyncHudMsg(idg_SyncTeamCount_CT"[Alive CT: %d]"iCTnum)
                if(
g_Hostie)
                {
                    
2550=0.462;
                    
set_hudmessage(RGBXY__TASK_LOOP_TIME+0.01_,  _1)
                    new 
iHostage,  Is_Hostage_aliveiHostie_count
                    
while ((iHostage find_ent(iHostage szEnt)) > 0)
                    {
                        
Is_Hostage_alive pev(iHostagepev_health)
                        if(
Is_Hostage_alive)
                            
iHostie_count++
                    }
                    
ShowSyncHudMsg(idg_SyncTeamCount_H"[Hostages: %d]"iHostie_count-g_rescue)
                }
            }
        }
state OFF
    
}state OFF

__________________

Last edited by DJEarthQuake; 05-02-2023 at 16:37. Reason: URL
DJEarthQuake 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 10:23.


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