Raised This Month: $ Target: $400
 0% 

Hats only for admins


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Chrisrs1
Junior Member
Join Date: Feb 2014
Old 05-24-2014 , 13:19   Hats only for admins
Reply With Quote #1

Well atm im using this plugin.

Code:
#include < amxmodx >
#include < engine >
#include < cstrike >
#include < hamsandwich >

new const g_szHatModel[ CsTeams ][ ] = {
    "",
    "models/santahat.mdl",
    "models/santahat_blue.mdl",
    ""
};

new g_iHats[ 33 ];

public plugin_init( ) {
    register_plugin( "Santa Hat + Snow", "1.3", "xPaw" );
    
    register_cvar( "santa_hat", "1.3", FCVAR_SERVER );
    
    register_event( "TeamInfo", "EventTeamInfo", "a" );
    
    RegisterHam( Ham_Spawn, "player", "FwdHamPlayerSpawn", 1 );
}

public plugin_precache( ) {
//  create_entity( "env_snow" );
    
    precache_model( g_szHatModel[ CS_TEAM_T ] );
    precache_model( g_szHatModel[ CS_TEAM_CT ] );
}

public client_disconnect( id )
    if( is_valid_ent( g_iHats[ id ] ) )
        remove_entity( g_iHats[ id ] );

public FwdHamPlayerSpawn( const id ) {
    if( is_user_alive( id ) ) {
        new iEntity = g_iHats[ id ];
        
        if( !is_valid_ent( iEntity ) ) {
            if( !( iEntity = g_iHats[ id ] = create_entity( "info_target" ) ) )
                return;
            
            new CsTeams:iTeam = cs_get_user_team( id );
            
            if( iTeam != CS_TEAM_T && iTeam != CS_TEAM_CT )
                iTeam = CS_TEAM_T;
            
            entity_set_model( iEntity, g_szHatModel[ iTeam ] );
            entity_set_int( iEntity, EV_INT_movetype, MOVETYPE_FOLLOW );
            entity_set_edict( iEntity, EV_ENT_aiment, id );
        }
    }
}

public EventTeamInfo( ) {
    new id = read_data( 1 ), iEntity = g_iHats[ id ];
    
    if( !is_valid_ent( iEntity ) ) {
        if( iEntity > 0 )
            g_iHats[ id ] = 0;
        
        return;
    }
    
    new szTeam[ 2 ];
    read_data( 2, szTeam, 1 );
    
    if( szTeam[ 0 ] == 'C' )
        entity_set_model( iEntity, g_szHatModel[ CS_TEAM_CT ] );
    else
        entity_set_model( iEntity, g_szHatModel[ CS_TEAM_T ] );
}
But it put the hat for everyone, and i just want it for admins (ct & tt).

I want someone to make it just for admin please,
Thanks in advance.
Chrisrs1 is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-24-2014 , 14:19   Re: Hats only for admins
Reply With Quote #2

Here it is, for admins with flag 'e' - for slay!
PHP Code:
#include < amxmodx >
#include < engine >
#include < cstrike >
#include < hamsandwich >

new const g_szHatModelCsTeams ][ ] = {
    
"",
    
"models/santahat.mdl",
    
"models/santahat_blue.mdl",
    
""
};

new 
g_iHats33 ];

public 
plugin_init( ) {
    
register_plugin"Santa Hat + Snow""1.3""xPaw" );
    
    
register_cvar"santa_hat""1.3"FCVAR_SERVER );
    
    
register_event"TeamInfo""EventTeamInfo""a" );
    
    
RegisterHamHam_Spawn"player""FwdHamPlayerSpawn");
}

public 
plugin_precache( ) {
//  create_entity( "env_snow" );
    
    
precache_modelg_szHatModelCS_TEAM_T ] );
    
precache_modelg_szHatModelCS_TEAM_CT ] );
}

public 
client_disconnectid )
    if( 
is_valid_entg_iHatsid ] ) )
        
remove_entityg_iHatsid ] );

public 
FwdHamPlayerSpawn( const id ) {
    if( 
is_user_aliveid ) ) {
        new 
iEntity g_iHatsid ];
        
        if( !
is_valid_entiEntity ) ) {
            if( !( 
iEntity g_iHatsid ] = create_entity"info_target" ) ) )
                return;
    if(!(
get_user_flags(id) & ADMIN_SLAY))
        return
            
            new 
CsTeams:iTeam cs_get_user_teamid );
            
            if( 
iTeam != CS_TEAM_T && iTeam != CS_TEAM_CT )
                
iTeam CS_TEAM_T;
            
            
entity_set_modeliEntityg_szHatModeliTeam ] );
            
entity_set_intiEntityEV_INT_movetypeMOVETYPE_FOLLOW );
            
entity_set_edictiEntityEV_ENT_aimentid );
        }
    }
}

public 
EventTeamInfo( ) {
    new 
id read_data), iEntity g_iHatsid ];
    
    if( !
is_valid_entiEntity ) ) {
        if( 
iEntity )
            
g_iHatsid ] = 0;
        
        return;
    }
    
    new 
szTeam];
    
read_data2szTeam);
    
    if( 
szTeam] == 'C' )
        
entity_set_modeliEntityg_szHatModelCS_TEAM_CT ] );
    else
        
entity_set_modeliEntityg_szHatModelCS_TEAM_T ] );

Just put a simple check and return if it's not right. Like this:
PHP Code:
if(!(get_user_flags(id) & ADMIN_SLAY))
        return 
Put this in the spawn function and should work.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Old 05-24-2014, 17:47
Chrisrs1
This message has been deleted by Chrisrs1.
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:49.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode