View Single Post
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 07-12-2011 , 13:55   Re: [REQ] Edit Plugin
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>


#define PLUGIN_NAME    "Health Display"
#define PLUGIN_VERSION    "11.1"
#define PLUGIN_AUTHOR    "Exolent"


#pragma semicolon 1


new bool:g_player_didnt_spawn[33];

new 
health_on;
new 
health_time;
new 
health_color;
new 
health_custom;
new 
health_effects;
new 
health_always;

public 
plugin_init()
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);
    
register_cvar("health_display"PLUGIN_VERSIONFCVAR_SPONLY);
    
    
register_clcmd("say /health""CmdHealth");
    
register_clcmd("say_team /health""CmdHealth");
    
register_clcmd("fullupdate""CmdFullupdate");
    
    
register_event("Health""EventHealth""be""1>0");
    
register_event("ResetHUD""EventResetHud""be");
    
register_event("TextMsg""EventRestartAttempt""a""2&#Game_w");
    
register_event("DeathMsg""EventDeathMsg""a");
    
    
health_on register_cvar("health_on""1");
    
health_time register_cvar("health_time""12");
    
health_color register_cvar("health_color""1");
    
health_custom register_cvar("health_custom""255 255 0");
    
health_effects register_cvar("health_effects""1");
    
health_always register_cvar("health_always""0");
}

public 
client_disconnect(client)
{
    
remove_task(client);
}

public 
CmdHealth(client)
{
    if(
cs_get_user_team(client) == CS_TEAM_T)
    {
        
client_print(clientprint_chat"Health Display is only for CT's.");
    }
    
    if( !
get_pcvar_num(health_on) && cs_get_user_team(client) == CS_TEAM_CT)
    {
        
client_print(clientprint_chat"Health Display is currently off.");
    }
    else if( 
is_user_alive(client) && cs_get_user_team(client) == CS_TEAM_CT)
    {
        
ShowHealth(client);
    }
    
    return 
PLUGIN_HANDLED;
}

public 
CmdFullupdate(client)
{
    return 
PLUGIN_HANDLED_MAIN;
}

public 
EventHealth(client)
{
    if( 
get_pcvar_num(health_on) && cs_get_user_team(client) == CS_TEAM_CT )
    {
        
ShowHealth(client);
    }
}

public 
EventResetHud(client)
{
    if( 
g_player_didnt_spawn[client] )
    {
        
g_player_didnt_spawn[client] = false;
    }
    else if( 
is_user_alive(client) && get_pcvar_num(health_always) && cs_get_user_team(client) == CS_TEAM_CT)
    {
        
set_task(0.1"ShowHealth"client);
    }
}

public 
EventRestartAttempt()
{
    new 
players[32], pnum;
    
get_players(playerspnum"a");
    
    for( new 
0pnumi++ )
    {
        
g_player_didnt_spawn[players[i]] = true;
    }
}

public 
EventDeathMsg()
{
    new 
client read_data(2);
    
    
remove_task(client);
    
    
set_hudmessage(__________3);
    
show_hudmessage(client"");
}

public 
ShowHealth(client)
{
    
remove_task(client);
    
    new 
hud_redhud_greenhud_blue;
    switch( 
get_pcvar_num(health_color) )
    {
        case 
0:
        {
            
hud_red 255;
            
hud_green 255;
            
hud_blue 255;
        }
        case 
1:
        {
            new 
color[16], red[4], green[4], blue[4];
            
get_pcvar_string(health_customcolor15);
            
parse(colorred3green3blue3);
            
            
hud_red str_to_num(red);
            
hud_green str_to_num(green);
            
hud_blue str_to_num(blue);
        }
        case 
2:
        {
            
hud_red random(256);
            
hud_green random(256);
            
hud_blue random(256);
        }
    }
    
    new 
Float:hud_time get_pcvar_float(health_time);
    
    
set_hudmessage(hud_redhud_greenhud_blue, -1.00.9get_pcvar_num(health_effects), hud_timehud_time0.10.23);
    
show_hudmessage(client"Health: %i"get_user_health(client));
    
    if( 
get_pcvar_num(health_always) && cs_get_user_team(client) == CS_TEAM_CT)
    {
        
set_task(hud_time 0.1"ShowHealth"client);
    }

r0ck is offline