In a perfect world you would only want the entity thinking when there are player(s) spectating. I don't feel like doing the extra work though. I also do not have the zombieplague include so I was not able to compile\test.
PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <zombieplague>
new const Version[] = "0.1";
const MAX_PLAYERS = 32;
new g_status_sync , g_iSpecEntity;
#define IsSpectating(%1) (is_user_connected(%1)&&!is_user_alive(%1)&&!is_user_bot(%1))
public plugin_init()
{
register_plugin( "Spectate Info" , Version , "@bdul!+Sn!ff3r+bugsy" );
register_dictionary("zp_aim_info.txt");
g_status_sync = CreateHudSyncObj()
g_iSpecEntity = create_entity( "info_target" );
entity_set_string( g_iSpecEntity , EV_SZ_classname , "spec_entity" );
register_think( "spec_entity" , "fw_SpecEntThink" );
entity_set_float( g_iSpecEntity , EV_FL_nextthink , ( get_gametime() + 0.2 ) );
}
public fw_SpecEntThink( iEntity )
{
static iSpectator , iSpectated;
for ( iSpectator = 1 ; iSpectator <= MAX_PLAYERS ; iSpectator++ )
{
if ( IsSpectating( iSpectator ) && ( iSpectated = pev( iSpectator , pev_iuser2 ) ) )
{
//iSpectator is spectating iSpectated
static name[32];
get_user_name(iSpectated, name, charsmax(name))
new color1 = 0, color2 = 0
new team1 = zp_get_user_zombie(iSpectator), team2 = zp_get_user_zombie(iSpectated)
if (team2 == 1)
color1 = 255
else
color2 = 255
if (team1 == team2) // friend
{
set_hudmessage(color1, 50, color2, -1.0, 0.60, 1, 0.01, 3.0, 0.01, 0.01, -1)
ShowSyncHudMsg(iSpectator, g_status_sync, "%L", LANG_PLAYER, "AIM_INFO", name, get_user_health(iSpectated), get_user_armor(iSpectated), zp_get_user_ammo_packs(iSpectated))
}
}
}
entity_set_float( g_iSpecEntity , EV_FL_nextthink , ( get_gametime() + 0.2 ) );
}
__________________