| craigy09 |
07-25-2010 06:39 |
Health HUD
hi im trying to edit this plugin so the health shows just above the timer in the middle instead of the lefthand side. also trying to make it white. Any help would be great! thanks!
PHP Code:
#include <amxmodx> #include <fakemeta> #define UPDATE_INTERVAL 0.3 //time in seconds between hud msg updates #define RED 150 //hud msg red #define GREEN 255 //hud msg green #define BLUE 0 //hud msg blue
#define TID_TIMER 5155
new g_HSO new g_timer_entid new Float:g_t_time new g_max_players
public plugin_init(){ register_plugin("RealHealthDisplay", "1.0", "Sylwester") g_max_players = get_maxplayers() create_timer() g_HSO = CreateHudSyncObj() } public create_timer(){ g_timer_entid = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target")) for(new i=1; i<4; i++){ if(pev_valid(g_timer_entid)){ break }else{ log_amx("Warning: Failed to create timer entity, retrying(%d)", i) g_timer_entid = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target")) } }
if(pev_valid(g_timer_entid)){ set_pev(g_timer_entid, pev_classname, "hp_display_timer") global_get(glb_time, g_t_time) set_pev(g_timer_entid, pev_nextthink, g_t_time + UPDATE_INTERVAL) register_forward(FM_Think,"fwd_Think") }else{ log_amx("Warning: Failed to create timer entity, using task instead") set_task(UPDATE_INTERVAL, "timer_cycle", TID_TIMER, "", 0, "b") } }
public fwd_Think(Ent){ if(Ent != g_timer_entid) return FMRES_IGNORED g_t_time += UPDATE_INTERVAL set_pev(Ent, pev_nextthink, g_t_time) timer_cycle() return FMRES_IGNORED }
public timer_cycle(){ for(new i=1; i<g_max_players; i++) if(is_user_alive(i)) display_health(i) }
public display_health(id){ static msg[64] set_hudmessage(RED, GREEN, BLUE, 0.02, 0.9, _, _, UPDATE_INTERVAL, _, _, -1) format(msg, 63, "Health: %d", get_user_health(id)) set_hudmessage(255, 255, 255, 0.30, 0.88, 0, 6.0, 12.0) ShowSyncHudMsg(id, g_HSO, msg) }
|