PS: i know there is plugin show speed but i want speed in this plugin
Code: Select all
#include <amxmodx>
#include <amxmisc>
#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_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
register_cvar("health_display", PLUGIN_VERSION, FCVAR_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( !get_pcvar_num(health_on) )
{
client_print(client, print_chat, "Health Display is currently off.");
}
else if( is_user_alive(client) )
{
ShowHealth(client);
}
return PLUGIN_HANDLED;
}
public CmdFullupdate(client)
{
return PLUGIN_HANDLED_MAIN;
}
public EventHealth(client)
{
if( get_pcvar_num(health_on) )
{
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) )
{
set_task(0.1, "ShowHealth", client);
}
}
public EventRestartAttempt()
{
new players[32], pnum;
get_players(players, pnum, "a");
for( new i = 0; i < pnum; i++ )
{
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_red, hud_green, hud_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_custom, color, 15);
parse(color, red, 3, green, 3, blue, 3);
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_red, hud_green, hud_blue, -1.0, 0.9, get_pcvar_num(health_effects), hud_time, hud_time, 0.1, 0.2, 3);
show_hudmessage(client, "Health: %i", get_user_health(client));
if( get_pcvar_num(health_always) )
{
set_task(hud_time - 0.1, "ShowHealth", client);
}
}