Not sure if this is what you mean but here
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
new g_Enable;
new g_bwEnt[33];
new g_CachedStringInfoTarget;
public plugin_init() {
register_plugin( "Hat plugin", "1.2", "xPaw" );
register_cvar("devil2", "1.2", FCVAR_SERVER);
g_Enable = register_cvar("amx_devil", "1");
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1);
g_CachedStringInfoTarget = engfunc( EngFunc_AllocString, "info_target" );
}
public plugin_precache()
{
precache_model("models/hat/devil2.mdl");
precache_model("models/hat/angel2.mdl");
}
public fwHamPlayerSpawnPost( id, const player ) {
new team = get_user_team( id );
if ( get_pcvar_num( g_Enable ) && is_user_alive( player ) && team == 1 ) {
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, "models/hat/devil2.mdl" );
}
else if ( team == 2 ) {
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, "models/hat/angel2.mdl" );
}
}
}
}
__________________