Код
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
new const hats[][] = {
"models/santahat_red.mdl",
"models/santahat_blue.mdl"
}
new g_bwEnt[33];
new g_CachedStringInfoTarget;
public plugin_init()
{
register_plugin( "Santa Hat Only for human", "1.2", "xPaw" );
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1);
g_CachedStringInfoTarget = engfunc(EngFunc_AllocString, "info_target");
}
public plugin_precache()
{
for (new i = 0; i < sizeof hats; i++)
precache_model(hats[i])
}
public fwHamPlayerSpawnPost(player)
{
if (is_user_alive(player))
{
new iEnt = g_bwEnt[player];
if( !pev_valid(iEnt) )
{
g_bwEnt[player] = iEnt = engfunc (EngFunc_CreateNamedEntity, g_CachedStringInfoTarget);
set_pev(iEnt, pev_movetype, MOVETYPE_FOLLOW);
set_pev(iEnt, pev_aiment, player);
engfunc(EngFunc_SetModel, iEnt, hats[random_num(0,1)]);
}
}
}
public zp_user_infected_post(id)
{
if(zp_get_user_zombie(id))
{
engfunc(EngFunc_RemoveEntity,g_bwEnt[id])
g_bwEnt[id] = 0
}
}
public zp_user_humanized_post(player)
{
new iEnt = g_bwEnt[player];
if( !pev_valid(iEnt) )
{
g_bwEnt[player] = iEnt = engfunc (EngFunc_CreateNamedEntity, g_CachedStringInfoTarget);
set_pev(iEnt, pev_movetype, MOVETYPE_FOLLOW);
set_pev(iEnt, pev_aiment, player);
engfunc(EngFunc_SetModel, iEnt, hats[random_num(0,1)]);
}
}