Raised This Month: $ Target: $400
 0% 

API Scripting Help |HELP| How to add on/off for zombie class


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 03-06-2015 , 08:10   |HELP| How to add on/off for zombie class
Reply With Quote #1

I'm struggling to make cvar for on and off-which means if cvar is off,then that class not appear in the menu for the class,and if set cvar to on,then that class will appear.
Can someone please help me with this?

here is simple class for example:

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <biohazard>

#define D_ZOMBIE_NAME "Chainsaw class"
#define D_ZOMBIE_DESC "strong attack (DMG)"
#define D_PLAYER_MODEL "chainsaw_ghost"
#define D_CLAWS "models/v_new_ghost_chainsaw.mdl"
#define PMODEL "models/player/chainsaw_ghost/chainsaw_ghost.mdl"

new g_zclassid1

new const chainsaw_sounds[][] =
{
        
"weapons/knife_deploy1.wav",
        
"biohazard/chainsaw1_miss.wav",
        
"biohazard/chainsaw1_miss.wav",
        
"biohazard/chainsaw1_miss.wav",
        
"biohazard/chainsaw1_miss.wav",
        
"biohazard/chain_hitwall1.wav",
        
"biohazard/chainsaww_slash1.wav",
        
"biohazard/chainsaww_slash2.wav",
        
"biohazard/chainsaw_stab.wav"
}

new const 
knife_sounds[][] =
{
    
"weapons/knife_deploy1.wav",
    
"weapons/knife_hit1.wav",
    
"weapons/knife_hit2.wav",
    
"weapons/knife_hit3.wav",
    
"weapons/knife_hit4.wav",
    
"weapons/knife_hitwall1.wav",
    
"weapons/knife_slash1.wav",
    
"weapons/knife_slash2.wav",
    
"weapons/knife_stab.wav"
}

public 
register_class_data()
{
    
g_zclassid1 register_class(D_ZOMBIE_NAMED_ZOMBIE_DESC)

    if(
g_zclassid1 != -1)
    {
        
set_class_data(g_zclassid1DATA_HEALTH259.0)
        
set_class_data(g_zclassid1DATA_SPEED250.0)
        
set_class_data(g_zclassid1DATA_GRAVITY0.80)
        
set_class_data(g_zclassid1DATA_ATTACK3.5)
                
set_class_data(g_zclassid1DATA_HITREGENDLY6.0)
        
set_class_pmodel(g_zclassid1D_PLAYER_MODEL)
        
set_class_wmodel(g_zclassid1D_CLAWS)
    }
}

public 
plugin_init()
{
    
register_plugin("[ZP] Chainsaw Zombie Class""0.1""Artos")
    
    
register_forward(FM_EmitSound"fw_EmitSound");

        
register_class_data()
}

public 
plugin_precache()
{    
    for(new 
0sizeof chainsaw_soundsi++)
        
precache_sound(chainsaw_sounds[i])

        
precache_model(PMODEL)
    
precache_model(D_CLAWS)
}

public 
fw_EmitSound(idchannel, const sound[])
{
    if(!
is_user_alive(id) || get_user_class(id) != g_zclassid1 || !is_user_zombie(id))
        return 
FMRES_IGNORED
        
    
for(new 0sizeof chainsaw_soundsi++)
    {
        if(
equal(soundknife_sounds[i]))
        {
            
emit_sound(idchannelchainsaw_sounds[i], 1.0ATTN_NORM0PITCH_NORM)
            return 
FMRES_SUPERCEDE
        
}
    }
            
    return 
FMRES_IGNORED


Last edited by Krtola; 03-06-2015 at 08:24.
Krtola is offline
Send a message via Skype™ to Krtola
 



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 13:21.


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