AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Colored StatusText? (https://forums.alliedmods.net/showthread.php?t=130021)

hzqst 06-19-2010 08:49

Colored StatusText?
 
I tried vformat (code from zombieplague colored saytext) but not work
Also tried code from kzarg, no colored statustext message seen there
Sorry my bad English

vato loco [GE-S] 06-20-2010 06:58

Re: Colored StatusText?
 
2 Attachment(s)
take a look on the code of
xPaw's
Aim Info + Country by xPaw

or this by Sylwester

PHP Code:

#include <amxmodx>
#include <fakemeta>

#define UPDATE_INTERVAL 0.5
#define TID_TIMER 26642

new g_max_players
new g_timer_entid
new Float:g_t_time
new g_HSO

new pc_enabled
new pc_team_color
new pc_details

new g_target[33]
new 
g_name[33][32]
new 
g_weap_name[32][32] = {"""p228""""scout""HE",
"xm1014""c4""mac10""aug""SG""elite",
"fiveseven""ump45""sg550""galil""famas""usp""glock",
"awp""mp5""m249""m3""m4a1""tmp",
"g3sg1""FB""deagle""sg552""ak47",
"knife""p90"""}
new 
g_hp[33]
new 
g_ap[33]
new 
g_weapon[33]
new 
g_team[33]

public 
plugin_init(){
    
register_plugin("Target Info on HUD""1.1""Sylwester")

    
register_message(get_user_msgid("StatusValue"), "update_target")
    
register_message(get_user_msgid("Health"), "update_hp")
    
register_message(get_user_msgid("Battery"), "update_ap")
    
register_message(get_user_msgid("CurWeapon"), "update_weapon")
    
register_event("TeamInfo""join_team","a")

    
pc_enabled register_cvar("ti_enabled""1"//0 - plugin disabled //1 - plugin enabled
    
pc_team_color register_cvar("ti_team_color""1"//0-same color for all teams//1-team color
    
pc_details register_cvar("ti_details""2"//0-only name//1-show details//2-teammates details

    
g_max_players get_maxplayers()
    
g_HSO CreateHudSyncObj()
    
create_timer()
}


public 
update_weapon(msg_idmsg_destid){
    if(
get_msg_arg_int(1))
        
g_weapon[id] = get_msg_arg_int(2)
}


public 
update_hp(msg_idmsg_destid){
    
g_hp[id] = get_user_health(id)
}


public 
update_ap(msg_idmsg_destid){
    
g_ap[id] = get_user_armor(id)
}


public 
update_target(msg_idmsg_destid){
    if(
get_msg_arg_int(1) == 2)
        
g_target[id] = get_msg_arg_int(2)
}


public 
client_connect(id){
    
g_target[id] = 0
    g_team
[id] = 0
    get_user_name
(idg_name[id], 31)
}


public 
client_infochanged(id){ //update name
    
get_user_info(id"name"g_name[id], 31)
}


public 
join_team(){
    static 
idteam[2]
    
id read_data(1)
    
read_data(2team1)
    switch(
team[0]){
        case 
'C'g_team[id] = 2
        
case 'T'g_team[id] = 1
        
default : g_team[id] = 0
    
}
}


public 
create_timer(){
    
g_timer_entid engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString,"info_target"))

    if(
pev_valid(g_timer_entid)){
        
set_pev(g_timer_entidpev_classname"ti_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 
plugin_unpause(){
    if(
pev_valid(g_timer_entid)){
        
global_get(glb_timeg_t_time)
        
g_t_time += UPDATE_INTERVAL
        set_pev
(g_timer_entidpev_nextthinkg_t_time)
    }
}


public 
timer_cycle(){
    static 
idcache[512], tarposdetailsteam_color
    
if(get_pcvar_num(pc_enabled) == 0)
        return
    
details get_pcvar_num(pc_details)
    
team_color get_pcvar_num(pc_team_color)
    for(
id 1id<=g_max_playersid++){
        if(!
is_user_alive(id) || g_target[id] == 0)
            continue
        
tar g_target[id]
        if(
team_color == 0){
            
set_hudmessage(25015050, -1.00.531_UPDATE_INTERVAL-0.10.10.1, -1)
        }else{
            switch(
g_team[tar]){
                case 
1set_hudmessage(2553030, -1.00.531_UPDATE_INTERVAL-0.10.10.1, -1)
                case 
2set_hudmessage(3030255, -1.00.531_UPDATE_INTERVAL-0.10.10.1, -1)
                default: 
set_hudmessage(150150150, -1.00.531_UPDATE_INTERVAL-0.10.10.1, -1)
            }
        }

        
pos formatex(cache511"%s"g_name[tar])
        if(
details == || (details == && g_team[id] == g_team[tar]))
            
pos += formatex(cache[pos], 511-pos" -- %d HP / %d AP / %s"g_hp[tar], g_ap[tar], g_weap_name[g_weapon[tar]])
        
ShowSyncHudMsg(idg_HSOcache)
    }




hleV 06-20-2010 07:27

Re: Colored StatusText?
 
He wants StatusText, not HUD message.

Emp` 06-20-2010 12:47

Re: Colored StatusText?
 
In the comments of my Player Look plugin, you can read more about StatusText and StatusValue.

tl;dr: you can only have colors in StatusText if you have a player's name in there as well (it will be that player's designated team color: red,blue,gray)

Alucard^ 06-20-2010 12:58

Re: Colored StatusText?
 
Oh, i have a question about this... is possible to show COLORED StatusText without aiming a player? i tried but didn't work... but maybe is there any other method... (or with orpheu?)


All times are GMT -4. The time now is 23:38.

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