Raised This Month: $ Target: $400
 0% 

Health HUD


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
craigy09
Senior Member
Join Date: Mar 2010
Old 07-25-2010 , 06:39   Health HUD
Reply With Quote #1

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)
    


Last edited by craigy09; 07-25-2010 at 07:14.
craigy09 is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 07-25-2010 , 10:35   Re: Health HUD
Reply With Quote #2

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
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-26-2010 , 05:02   Re: Health HUD
Reply With Quote #3

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.

Last edited by Gadzislaw007; 07-26-2010 at 05:06.
Gadzislaw007 is offline
Old 07-26-2010, 05:03
Gadzislaw007
This message has been deleted by Gadzislaw007. Reason: Laggg and double post
Reply



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 00:07.


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