AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Health HUD (https://forums.alliedmods.net/showthread.php?t=133425)

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_CreateNamedEntityengfunc(EngFunc_AllocString,"info_target"))
    for(new 
i=1i<4i++){
        if(
pev_valid(g_timer_entid)){
            break
        }else{
            
log_amx("Warning: Failed to create timer entity, retrying(%d)"i)
            
g_timer_entid engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString,"info_target"))
        }
    }

    if(
pev_valid(g_timer_entid)){
        
set_pev(g_timer_entidpev_classname"hp_display_timer")
        
global_get(glb_timeg_t_time)
        
set_pev(g_timer_entidpev_nextthinkg_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
(Entpev_nextthinkg_t_time)
    
timer_cycle()
    return 
FMRES_IGNORED
}

public 
timer_cycle(){
    for(new 
i=1i<g_max_playersi++)
        if(
is_user_alive(i))
            
display_health(i)
}

public 
display_health(id){
    static 
msg[64]
    
set_hudmessage(REDGREENBLUE0.020.9__UPDATE_INTERVAL__, -1)
    
format(msg63"Health: %d"get_user_health(id))
    
set_hudmessage(2552552550.300.8806.012.0)
    
ShowSyncHudMsg(idg_HSOmsg)
    



GXLZPGX 07-25-2010 10:35

Re: Health HUD
 
I'm not too good with HUD locations, but to make it white, at the top, it says:

#define RED 150 //hud msg red
#define GREEN 255 //hud msg green
#define BLUE 0 //hud msg blue

Change it to

#define RED 255 //hud msg red
#define GREEN 255 //hud msg green
#define BLUE 255 //hud msg blue

Gadzislaw007 07-26-2010 05:02

Re: Health HUD
 
Code:

#include <amxmodx>
#include <fakemeta>
 
#define UPDATE_INTERVAL 0.3 //time in seconds between hud msg updates
#define RED 255 //hud msg red
#define GREEN 255 //hud msg green
#define BLUE 255 //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, -1.0, 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)
   
}

Try this.


All times are GMT -4. The time now is 00:07.

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