I tried this, it works... partially, but still the FM_PlayerPostThink is being called many times per second. Is there a way to optimizing this, please?
code is also a bit modified to show health percentage for monster_apache, don't mind that.
Code:
new pica
public fw_PlayerPostThink(id){
pica ++
if (pica >= 60 ) {
static ent,bh
static classname[32],hpinfo[18]
get_user_aiming(id,ent,bh)
if(!ent)
return
static health,armor
if(0<ent<=g_maxplayers){
return
}else{
pica = 0
pev(ent,pev_classname,classname,31)
if(!TrieKeyExists(g_vodka,classname)||pev(ent,pev_deadflag)!=DEAD_NO)
return
health = pev(ent,pev_health)
new hratio = procentaPico(health)
TrieGetCell(g_vodka,classname,armor)
TrieGetString(g_lolka,classname,classname,31)
formatex(hpinfo,17,"(%d%s)",hratio,"%")
}
if(health<=0)
return
set_hudmessage(206, 24, 0, -1.0, 0.60, 0, 0.0, 2.0, 0.0, 0.2, -1)
show_hudmessage(id,"%s %s",classname,hpinfo)
} else {
return
}
}
public procentaPico(int) {
new hratio_tmp = floatround((floatdiv( float(int), float(apachehetloch)) * 100), floatround_ceil )
return hratio_tmp
}