#include <amxmodx>
#include <reapi>
#include <zombieplague>
new const g_szModel[] = "models/awesome.mdl";
new g_iEnt[MAX_PLAYERS+1],
g_iModelIndex;
public plugin_init()
{
register_plugin("Hat for Authorization", "0.1", "` BesTCore;");
RegisterHookChain(RG_CBasePlayer_Spawn, "RG_CBasePlayer_Spawn_Post", .post = true);
}
public zp_user_infected_post(id, infector, nemesis)
{
if( !infector || nemesis)
{
return;
}
RemoveTheHat(id);
}
public RG_CBasePlayer_Spawn_Post(id)
{
if(get_member(id, m_bJustConnected))
{
return;
}
CreateModel(id);
}
public CreateHat(const id)
{
g_iEnt[id] = rg_create_entity("info_target");
CreateModel(id);
}
public CreateModel(id)
{
set_entvar(g_iEnt[id], var_modelindex, g_iModelIndex);
set_entvar(g_iEnt[id], var_movetype, MOVETYPE_FOLLOW);
set_entvar(g_iEnt[id], var_aiment, id);
}
RemoveTheHat(const id)
{
if(!is_nullent(g_iEnt[id]))
{
set_entvar(g_iEnt[id], var_flags, FL_KILLME);
g_iEnt[id] = 0;
}
}
public client_putinserver(id)
{
if(is_user_alive(id) || !zp_get_user_zombie(id)) {
CreateHat(id);
}
}
public client_disconnected(id)
{
RemoveTheHat(id);
}
public plugin_precache()
{
for(new i = 0; i < sizeof(g_szModel); i++)
{
g_iModelIndex = precache_model(fmt("%s", g_szModel));
}
}