AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with a Cvar plz! (https://forums.alliedmods.net/showthread.php?t=113000)

Zapdos1 12-22-2009 16:27

Help with a Cvar plz!
 
well, my problem is, what i wrote in console "amx_boxing 0" to disable the plugin, but it still enable, what i have to do?

PHP Code:

#include <amxmodx> 
#include <hamsandwich> 
#include <fakemeta>
#include <engine> 

// Sobre comprar 
new g_szBuyCommands[][] =  

    
"usp""glock""deagle""p228""elites""fn57""m3""xm1014""mp5""tmp""p90""mac10""ump45""ak47",  
    
"galil""famas""sg552""m4a1""aug""scout""awp""g3sg1""sg550""m249""vest""vesthelm""flash""hegren"
    
"sgren""defuser""nvgs""shield""primammo""secammo""km45""9x19mm""nighthawk""228compact""12gauge"
    
"autoshotgun""smg""mp""c90""cv47""defender""clarion""krieg552""bullpup""magnum""d3au1""krieg550"
    
"buyammo1""buyammo2" 



// Sobre cvars 
new boxing_enableboxing_blockbuypointer_restart

new bool:g_bEnabledg_iMaxPlayersg_iSyncHudg_msgCurWeapon

// Arma
new VIEW_MODEL[]    = "models/boxing_mod/v_knife.mdl" 
new PLAYER_MODEL[]    = "models/boxing_mod/p_knife.mdl" 
new WORLD_MODEL[]    = "models/boxing_mod/w_knife.mdl"

new const boxing_sounds[][] =
{
    
"boxing_sound/boxing_deploy1.wav",    
    
"boxing_sound/boxing_hit1.wav",    
    
"boxing_sound/boxing_hit2.wav",    
    
"boxing_sound/boxing_hit3.wav",    
    
"boxing_sound/boxing_hit4.wav",    
    
"boxing_sound/boxing_hitwall1.wav",
    
"boxing_sound/boxing_slash1.wav",    
    
"boxing_sound/boxing_slash2.wav",    
    
"boxing_sound/boxing_stab.wav"    
}

new const 
oldknife_sounds[][] =
{
    
"weapons/knife_deploy1.wav",    // Deploy Sound
    
"weapons/knife_hit1.wav",    // Hit 1
    
"weapons/knife_hit2.wav",    // Hit 2
    
"weapons/knife_hit3.wav",    // Hit 3
    
"weapons/knife_hit4.wav",    // Hit 4
    
"weapons/knife_hitwall1.wav",    // Hit Wall
    
"weapons/knife_slash1.wav",    // Slash 1
    
"weapons/knife_slash2.wav",    // Slash 2
    
"weapons/knife_stab.wav"    // Stab
}

public 
plugin_init() 

    
// Plugin info
    
register_plugin("Boxing Mod""1.0""Zapdos1"
    
    
// Cvars 
    
boxing_enable register_cvar("amx_boxing","1"
    
boxing_blockbuy register_cvar("amx_boxing_block_buy""1"
    
pointer_restart get_cvar_pointer("sv_restart")
    
    
// Lang 
    
register_dictionary("boxing.txt")   
    
    
// Events
    
register_event("CurWeapon""event_CurWeapon""be","1=1")
    
register_event("HLTV""event_RoundStart""a""1=0""2=0")
    
    
// Fakemeta fwds.
    
register_forward(FM_SetModel"fw_SetModel")
    
register_forward(FM_EmitSound"fw_EmitSound")
    
    
// Hamsandwich fwds.
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")

    for (new 
isizeof g_szBuyCommandsi++) 
        
register_clcmd(g_szBuyCommands[i], "BlockBuyCommands"
    
    
g_bEnabled false
    g_iMaxPlayers 
get_maxplayers()
    
g_iSyncHud CreateHudSyncObj()
    
g_msgCurWeapon get_user_msgid("CurWeapon")


public 
plugin_precache() 
{    
    
precache_model(VIEW_MODEL)     
    
precache_model(PLAYER_MODEL
    
precache_model(WORLD_MODEL)
    
    for(new 
0sizeof boxing_soundsi++)
    
precache_sound(boxing_sounds[i])
}

public 
BlockBuyCommands() 

    if (
get_pcvar_num(boxing_blockbuy) && get_pcvar_num(boxing_enable) && g_bEnabled
        return 
PLUGIN_HANDLED
        
    return 
PLUGIN_CONTINUE
}  

public 
event_RoundStart() 

    if (
get_pcvar_num(boxing_enable) && !g_bEnabled)
    {
        
// Restart
        
set_pcvar_num(pointer_restart5)
        
        
// Hud message
        
set_hudmessage(255255255, -1.0, -1.006.012.0
        
ShowSyncHudMsg(0g_iSyncHud"[CS Boxing] - Have Fun!!!"
        
        
// Messages
        
client_print(0print_chat"[AMXX] %L"LANG_PLAYER"WELCOME_MESSAGE");  
        
client_print(0print_chat"[AMXX] %L"LANG_PLAYER"CLIENT_MESSAGE")
        
        
// Game enabled
        
g_bEnabled true
        
        
for(new 1<= g_iMaxPlayersi++)
        {
            if(
is_user_connected(i))
                
reset_user_knife(i)
        }
    }


public 
event_CurWeapon(id
{     
    new 
weaponID read_data(2
    
    if(
weaponID == CSW_KNIFE)
    {
        
entity_set_string(idEV_SZ_viewmodelVIEW_MODEL)   
        
entity_set_string(idEV_SZ_weaponmodelPLAYER_MODEL
    }
    else
        
reset_user_knife(id)
    
    return 
PLUGIN_CONTINUE 


public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_bits)
{            
    if(
damage_bits DMG_SLASH)
    {
        
SetHamParamFloat(4damage 2.0
        return 
HAM_HANDLED  
    
}
    
    return 
HAM_IGNORED
}

public 
fw_SetModel(entitymodel[])
{
    if(!
is_valid_ent(entity)) 
        return 
FMRES_IGNORED
    
    
if(!equali(model"models/w_knife.mdl")) 
        return 
FMRES_IGNORED
    
    
static className[33]
    
entity_get_string(entityEV_SZ_classnameclassName32
    
    if(
equal(className"weaponbox") || equal(className"armoury_entity") || equal(className"grenade"))
    {
        
entity_set_model(entityWORLD_MODEL
        return 
FMRES_SUPERCEDE
    
}
    
    return 
FMRES_IGNORED


stock reset_user_knife(id// by metal :$
{         
    
engclient_cmd(id"weapon_knife")
    
emessage_begin(MSG_ONEg_msgCurWeapon_id)
    
ewrite_byte(1// active
    
ewrite_byte(CSW_KNIFE// weapon
    
ewrite_byte(-1// clip
    
emessage_end()
}  

public 
fw_EmitSound(idchannel, const sound[])
{
    if(!
is_user_connected(id))
        
    for(new 
0sizeof boxing_soundsi++)
    {
        if(
equal(soundoldknife_sounds[i]))
        {
            
emit_sound(idchannelboxing_sounds[i], 1.0ATTN_NORM0PITCH_NORM)
            return 
FMRES_SUPERCEDE
        
}
    }
            
    return 
FMRES_IGNORED


(sorry for my english)

Zapdos1 12-22-2009 16:48

Re: Help with a Cvar plz!
 
Quote:

Error: Undefined symbol "varz" on line 131
Warning: Expression has no effect on line 131
Error: Expected token: ";", but found ")" on line 131
Error: Invalid expression, assumed zero on line 131
Error: Too many error messages on one line on line 131

Compilation aborted.
4 Errors.
PHP Code:


register_cvar
("amx_boxing","1")

public 
event_RoundStart() 
{
    new 
vars[2]
    
get_cvar_string("amx_boxing"varz1)
    if (
equal(vars,"1") && !g_bEnabled)
 
        
// Restart
        
set_pcvar_num(pointer_restart5)
        
        
// Hud message
        
set_hudmessage(255255255, -1.0, -1.006.012.0
        
ShowSyncHudMsg(0g_iSyncHud"[CS Boxing] - Have Fun!!!"
        
        
// Messages
        
client_print(0print_chat"[AMXX] %L"LANG_PLAYER"WELCOME_MESSAGE");  
        
client_print(0print_chat"[AMXX] %L"LANG_PLAYER"CREDIT_MESSAGE")
        
        
// Game enabled
        
g_bEnabled true
        
        
for(new 1<= g_iMaxPlayersi++)
        {
            if(
is_user_connected(i))
                
reset_user_knife(i)
        }



ProIcons 12-22-2009 16:49

Re: Help with a Cvar plz!
 
new vars[2]
get_cvar_string("amx_boxing", varz, 1)

in cvar_string you have varz it must be vars

get_cvar_string("amx_boxing", vars, 1);

and a ; in the end

Doc-Holiday 12-22-2009 16:52

Re: Help with a Cvar plz!
 
after you change the value you have to restart the round...

You have it on round start the only time you actully have the plugin check if its on or off.


Also remove the buy zones dont block buy commands just remove it completely that way they know that they cannot buy
PHP Code:

#define fm_cs_set_user_nobuy(%1)    set_pdata_int(%1, 235, get_pdata_int(%1, 235) & ~(1<<0) )

public plugin_cfg()
{
    
register_message(get_user_msgid("StatusIcon") , "Message_StatusIcon");


public 
Message_StatusIcon(iMsgIdMSG_DESTid)
{
    static 
szIcon[5];
    
get_msg_arg_string(2szIcon4);
    if( 
szIcon[0] == 'b' && szIcon[2] == 'y' && szIcon[3] == 'z' )
    {
        if( 
get_msg_arg_int(1) )
        {
            
fm_cs_set_user_nobuy(id);
            return 
PLUGIN_HANDLED;
        }
    }
    return 
PLUGIN_CONTINUE



Zapdos1 12-22-2009 17:13

Re: Help with a Cvar plz!
 
Quote:

Originally Posted by ProIcons (Post 1027418)
new vars[2]
get_cvar_string("amx_boxing", varz, 1)

in cvar_string you have varz it must be vars

get_cvar_string("amx_boxing", vars, 1);

and a ; in the end

Quote:

Originally Posted by NcB_Sav (Post 1027420)
after you change the value you have to restart the round...

You have it on round start the only time you actully have the plugin check if its on or off.

so, what i have to do? :S

PHP Code:


register_cvar
("amx_boxing","1")

public 
enable(id)
{
    new 
vars[2]
    
get_cvar_string("amx_boxing"vars1);
    if (
equal(vars,"1") && !g_bEnabled)


????????

Doc-Holiday 12-22-2009 19:30

Re: Help with a Cvar plz!
 
why are you using a string for a num cvar?


string would be


register_cvar("amx_string", "My Dog Died")

ProIcons 12-23-2009 05:00

Re: Help with a Cvar plz!
 
get_cvar_num



All times are GMT -4. The time now is 04:07.

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