Raised This Month: $ Target: $400
 0% 

Help me to add cvar


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Alon
Member
Join Date: Jan 2011
Old 06-21-2011 , 23:42   Help me to add cvar
Reply With Quote #1

Hello ,
Can you help me add a Cvar to This Plugin :

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

public plugin_init() {
        
register_plugin("AMX Admin Model""1.1.1""whitemike")
        
register_event("ResetHUD""resetModel""b")
        return 
PLUGIN_CONTINUE
}

public 
plugin_precache() {
        
precache_model("models/player/admin_ct/admin_ct.mdl")
        
precache_model("models/player/admin_te/admin_te.mdl")

        return 
PLUGIN_CONTINUE
}

public 
resetModel(idlevelcid) {
        if (
get_user_flags(id) & ADMIN_KICK) {
                new 
CsTeams:userTeam cs_get_user_team(id)
                if (
userTeam == CS_TEAM_T) {
                        
cs_set_user_model(id"admin_te")
                }
                else if(
userTeam == CS_TEAM_CT) {
                        
cs_set_user_model(id"admin_ct")
                }
                else {
                        
cs_reset_user_model(id)
                }
        }

        return 
PLUGIN_CONTINUE

Thanks for helpers
Alon is offline
DjOptimuS
Senior Member
Join Date: Jan 2009
Old 06-21-2011 , 23:46   Re: Help me to add cvar
Reply With Quote #2

cvar for what ? ON/OFF ?

If so, try this

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

new g_cvarResetModel;

public 
plugin_init() {
    
register_plugin("AMX Admin Model""1.1.1""whitemike");
    
register_event("ResetHUD""resetModel""b");
    
    
g_cvarResetModel register_cvar("amx_reset_model""1");
}

public 
plugin_precache()
{
    
precache_model("models/player/admin_ct/admin_ct.mdl");
    
precache_model("models/player/admin_te/admin_te.mdl");
}

public 
resetModel(idlevelcid)
{
    
    if(!
get_pcvar_num(g_cvarResetModel))
        return 
PLUGIN_CONTINUE
    
    
if(!(get_user_flags(id) & ADMIN_KICK))
        return 
PLUGIN_CONTINUE
    
    
new CsTeams:team cs_get_user_team(id);
    
    switch(
team)
    {
        case(
CS_TEAM_T):
        {
            
cs_set_user_model(id"admin_te");
        }
        
        case(
CS_TEAM_CT):
        {
            
cs_set_user_model(id"admin_ct");
        }
        
        default:
        {
            
cs_reset_user_model(id);
        }
    }
    
    return 
PLUGIN_CONTINUE

For ON
amx_reset_model "1"

For OFF
amx_reset_model "0"

Last edited by DjOptimuS; 06-21-2011 at 23:54. Reason: Optimizing the Code
DjOptimuS is offline
Alon
Member
Join Date: Jan 2011
Old 06-22-2011 , 01:32   Re: Help me to add cvar
Reply With Quote #3

yes i need cvar to ON/OFF .

its dont work .
Alon is offline
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 23:30.


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