AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED]to add cvars (https://forums.alliedmods.net/showthread.php?t=101908)

sabrioz 08-28-2009 11:15

[SOLVED]to add cvars
 
hello all..
i'm newbie here..

i just want to know how can i add a cvars for this plugin

this is my edited script:

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <csx>
#include <fun>

const g_GrenadeNum 5;

public 
plugin_init() {
    
register_plugin("HE Only mode""0.1""AlliedModder")
    
register_event("CurWeapon""event_he_off""be""1=0""2=4")
    
register_cvar("amx_he_only""0")
}

public 
event_he_off(id) {
    if (!
get_cvar_num("amx_he_only"))
        return

    
engclient_cmd(id"weapon_hegrenade")
    
client_print(idprint_center"HE only mode is on. You can't swith your weapons!")
}

public 
grenade_throwid greindex wId 
{
    if ( 
wId == CSW_HEGRENADE )
        
cs_set_user_bpammoid CSW_HEGRENADE g_GrenadeNum );


i want to add cvars for enable and disable HE Only Mode..example like this:

say hemod = enable HE Only Mode
say /hemod = enable HE Only Mode

say hemodoff = disable HE Only Mode
say /hemodoff = diasable HE Only Mode

Alucard^ 08-28-2009 11:58

Re: [HOW]to add cvars
 
Pcvars are faster than normal cvars...

Well, the code should be something like this, but i am not sure:

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <csx>
#include <fun>

const g_GrenadeNum 5

new p_Enable

public plugin_init()
{
    
register_plugin("HE Only mode""0.1""AlliedModder")
    
register_event("CurWeapon""event_he_off""be""1=0""2=4")
    
p_Enable register_cvar("amx_he_only""0")
}

public 
event_he_off(id)
{
    if (!
get_pcvar_num(p_Enable) )
        return 
PLUGIN_HANDLED
    
    engclient_cmd
(id"weapon_hegrenade")
    
client_print(idprint_center"HE only mode is on. You can't swith your weapons!")
}

public 
grenade_throw(id greindex wId 
{
    if ( 
wId == CSW_HEGRENADE )
        
cs_set_user_bpammo(id CSW_HEGRENADE g_GrenadeNum )


But about the /hemode, that is a command, not cvar... to do this i think you have to use bools or condition operators maybe...

IneedHelp 08-28-2009 13:37

Re: [HOW]to add cvars
 
Quote:

Originally Posted by Alucard^ (Post 915375)
PHP Code:

    if (!get_pcvar_num(p_Enable) )
        return 
PLUGIN_HANDLED 



Alucard^ 08-28-2009 15:35

Re: [HOW]to add cvars
 
Ye, sry... my mistake, fixed.


All times are GMT -4. The time now is 15:11.

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