You don't need any task, and you forgot to check if user is alive in spawn callback :
PHP Code:
/* Plugin Generated by Imag!ne for Advent`S Team */
#include < amxmodx >
#include < amxmisc >
#include < hamsandwich >
#include < cstrike >
#include < engine >
#include < fun >
new const ADMIN_DGL_V_MODEL[] = "models/AdventSyn/v_deagle.mdl";
new g_pCvarHealthAdmin;
public plugin_init( )
{
register_plugin( "Op Admin" , "2.0.1" , "Imag!ne" );
RegisterHam( Ham_Spawn, "player", "AdminPlusHandler", 1);
g_pCvarHealthAdmin = register_cvar( "amx_health_admin" , "130" );
}
public plugin_precache( )
{
precache_model(ADMIN_DGL_V_MODEL);
}
public AdminPlusHandler( id )
{
if( is_user_alive(id) && is_user_admin( id ) && cs_get_user_team( id ) == CS_TEAM_CT )
{
strip_user_weapons( id );
set_user_health( id , get_pcvar_num( g_pCvarHealthAdmin ) );
give_item( id, "weapon_deagle" );
cs_set_user_bpammo( id , CSW_DEAGLE , 250 );
entity_set_string( id, EV_SZ_viewmodel, ADMIN_DGL_V_MODEL );
}
}
Also, it is better to cache allocated model string index so engine won't allocate it few times (allocated strings are never cleared untill server is shutting down) :
PHP Code:
/* Plugin Generated by Imag!ne for Advent`S Team */
#include < amxmodx >
#include < amxmisc >
#include < hamsandwich >
#include < fakemeta >
#include < cstrike >
// #include < engine >
#include < fun >
new const ADMIN_DGL_V_MODEL[] = "models/AdventSyn/v_deagle.mdl";
new g_iszAdminDeagleViewModel;
new g_pCvarHealthAdmin;
public plugin_init( )
{
register_plugin( "Op Admin" , "2.0.1" , "Imag!ne" );
RegisterHam( Ham_Spawn, "player", "AdminPlusHandler", 1);
g_pCvarHealthAdmin = register_cvar( "amx_health_admin" , "130" );
}
public plugin_precache( )
{
precache_model(ADMIN_DGL_V_MODEL);
g_iszAdminDeagleViewModel = engfunc(EngFunc_AllocString, ADMIN_DGL_V_MODEL);
}
public AdminPlusHandler( id )
{
if( is_user_alive(id) && is_user_admin( id ) && cs_get_user_team( id ) == CS_TEAM_CT )
{
strip_user_weapons( id );
set_user_health( id , get_pcvar_num( g_pCvarHealthAdmin ) );
give_item( id, "weapon_deagle" );
cs_set_user_bpammo( id , CSW_DEAGLE , 250 );
set_pev_string( id, pev_viewmodel, g_iszAdminDeagleViewModel );
}
}
__________________