Raised This Month: $ Target: $400
 0% 

Cvar doesn't work?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 11-01-2011 , 08:48   Cvar doesn't work?
Reply With Quote #1

I made a code, with cvar, and its not working.
PHP Code:
new vmr
/*...*/
public plugin_init()
{
    
vmr register_cvar("vip_menu_round","3"// From which round VIP can take VIP menu
}
/*...*/
public cmdvipmenu(id)
{
    
round++;
    if( 
round get_pcvar_num(vmr) )
    {
        
Showrod(id)
    }
}
/*...*/
public Event_RoundRestart(id)
{
    
round=0;

__________________
Please enter this website everyday: http://forums.alliedmods.net/showthread.php?t=169067

Last edited by Evaldas.Grigas; 11-01-2011 at 08:55.
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-01-2011 , 08:51   Re: Cvar doesn't work?
Reply With Quote #2

Saying it doesn't work, doesn't help. There is nothing wrong with your code, so, the question is how you have "tested". And since you don't show all the code, it's up to you to debug yourself your code.
__________________
Arkshine is offline
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 11-01-2011 , 08:54   Re: Cvar doesn't work?
Reply With Quote #3

Well, I write /vipmenu ingame 3 times and then I get the menu. But it should block vipmenu until round 3. I don't know how to debug it
Edit:
Debugging: 3

EDIT: The problem is that if I delete this cvar and wirte 3 insted of get_pcvar_num(vmr) it works.

EDIT:
PHP Code:
#define DAMAGE_RECIEVED
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <hamsandwich>
#include <ammo_stocks>
#include <csx>
#include <stripweapons>

static const COLOR[] = "^x04" //green
static const CONTACT[] = ""
new maxplayers
new gmsgSayText
new mpdmkbmhbmvtvmrmtrmctM4A1ammoAK47ammoAWPammoDEAGLEammoM4A1bpammoAK47bpammoAWPbpammoDEAGLEbpammo
new g_MsgSync
new health_add
new health_hs_add
new health_max
new nKiller
new nKiller_hp
new nHp_add
new nHp_max
new round;
new 
szMap20 ]
new 
gUsed[33]
new 
iPlayers[2];
#if defined DAMAGE_RECIEVED
new g_MsgSync2
#endif

new const vipmenu[][] =
{
    
"say /vipmenu""say vipmenu"


new const 
mapnames[][] =
{
    
"awp_""cs_deagle""35hp_""aim_"
}

public 
plugin_init()
{
    
register_plugin("VIP plugin""3.4""Evaldas.Grigas")
    
mpd register_cvar("money_per_damage","3"// How much VIP gets money per damage
    
mkb register_cvar("money_kill_bonus","200"// Hom much bonus VIP gets for kill
    
mhb register_cvar("money_hs_bonus","500"// How much bonus VIP gets for head shot
    
mvt register_cvar("max_vipmenu_times","3"// How much times VIP can use VIP menu per round
    
vmr register_cvar("vip_menu_round","3"// From which round VIP can take VIP menu 
    
mtr register_cvar("minimum_tr","5"// How much player must be in T team, so VIP can take AWP choise
    
mct register_cvar("minimum_ct","5"// How much player must be in CT team, so VIP can take AWP choise
    
health_add register_cvar("amx_vip_hp""5"// How much health VIP get for kill
    
health_hs_add register_cvar("amx_vip_hp_hs""10"// How much health VIP get for head shot
    
health_max register_cvar("amx_vip_max_hp""100"// How much VIP can have health
    
M4A1ammo register_cvar("m4a1_ammo","30"// How much VIP gets M4A1 ammo
    
M4A1bpammo register_cvar("m4a1_bammo","90"// How much VIP gets M4A1 bpammo
    
AK47ammo register_cvar("ak47_pammo","30"// How much VIP gets AK47 ammo
    
AK47bpammo register_cvar("ak47_bpammo","90"// How much VIP gets AK47 bpammo
    
AWPammo register_cvar("awp_pammo","10"// How much VIP gets AWP ammo
    
AWPbpammo register_cvar("awp_bpammo","30"// How much VIP gets AWP bpammo
    
DEAGLEammo register_cvar("deagle_pammo","7"// How much VIP gets DEAGLE ammo
    
DEAGLEbpammo register_cvar("deagle_bpammo","35"// How much VIP gets DEAGLE bpammo
    
register_clcmd("awp","HandleCmd")
    
register_clcmd("sg550","HandleCmd")
    
register_clcmd("g3sg1","HandleCmd")
    
register_event("Damage","Damage","b")
    
register_event("DeathMsg","death_msg","a")
    
register_event("ResetHUD""resetModel""b")
    
register_clcmd("say /vip","ShowMotd")
    
register_clcmd("say /vips","ShowVIP")
    
maxplayers get_maxplayers()
    
gmsgSayText get_user_msgid("SayText")
    
register_cvar("amx_contactinfo"CONTACTFCVAR_SERVER)
    
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1
    
register_event("TextMsg","Event_RoundRestart","a","2&#Game_w")
    
register_event("DeathMsg""hook_death""a""1>0")
    
register_event("Damage""on_damage""b""2!0""3=0""4!0")
    
g_MsgSync CreateHudSyncObj()
    
#if defined DAMAGE_RECIEVED
    
g_MsgSync2 CreateHudSyncObj()
    
#endif    
    
for(new 0sizeof vipmenui++)
    
register_clcmd(vipmenu[i], "cmdvipmenu"
    
get_mapnameszMap charsmaxszMap ) );
}

public 
EventRoundStart( ) 
{
    for( new 
1maxplayersi++ )
    {
        if( 
is_user_connected(i) && is_user_alive) && get_user_team(i) != )
            
iPlayers[get_user_team(i) - 1]++;
    }
}


public 
plugin_precache() 
{
    
precache_model("models/player/adminash_ct/adminash_ct.mdl")
    
precache_model("models/player/adminash_t/adminash_t.mdl")

    return 
PLUGIN_CONTINUE
}

public 
resetModel(idlevelcid
{
    if (
get_user_flags(id) & ADMIN_LEVEL_H
    {
        if (
cs_get_user_team(id) == CS_TEAM_T
        {
            
cs_set_user_model(id"adminash_t")
        }
        else if(
cs_get_user_team(id) == CS_TEAM_CT
        {
            
cs_set_user_model(id"adminash_ct")
        }
        else 
        {
            
cs_reset_user_model(id)
        }
    }
    return 
PLUGIN_CONTINUE
}

public 
cmdvipmenu(id
{
    
round++;
    if (
get_user_flags(id) & ADMIN_LEVEL_H
    {
        if( 
gUsed[id] < get_pcvar_num(mvt) )
        {
            if ( 
is_user_alive(id) && get_user_flags(id) & ADMIN_LEVEL_H )
            {
                if( 
round >= get_pcvar_num(vmr) )
                {
                    
Showrod(id)
                }
            }
        }
    }
    else
    {
        
client_print(idprint_center"[VIP] You don't have VIP! Write /vip, and you will see VIP privileges.")
    }
    return 
PLUGIN_HANDLED
}

public 
on_damage(id)
{
    new 
attacker get_user_attacker(id)
    
    
#if defined DAMAGE_RECIEVED
    
if ( is_user_connected(id) && is_user_connected(attacker) )
    if (
get_user_flags(attacker) & ADMIN_LEVEL_H)
    {
        new 
damage read_data(2)
        
        
set_hudmessage(255000.450.5020.14.00.10.1, -1)
        
ShowSyncHudMsg(idg_MsgSync2"%i^n"damage)
        
#else
        
if ( is_user_connected(attacker) && if (get_user_flags(attacker) & ADMIN_LEVEL_H) )
        {
            new 
damage read_data(2)
            
#endif
            
set_hudmessage(0100200, -1.00.5520.14.00.020.02, -1)
            
ShowSyncHudMsg(attackerg_MsgSync"%i^n"damage)
        }
    }
    
public 
Damage(id)
{
    new 
weaponhitpointattacker get_user_attacker(id,weapon,hitpoint)
    if(
attacker<=maxplayers && is_user_alive(attacker) && attacker!=id)
    if (
get_user_flags(attacker) & ADMIN_LEVEL_H
    {
        new 
money read_data(2) * get_pcvar_num(mpd)
        if(
hitpoint==1money += get_pcvar_num(mhb)
        
cs_set_user_money(attacker,cs_get_user_money(attacker) + money)
    }
}
    
public 
death_msg()
{
    if(
read_data(1)<=maxplayers && read_data(1) && read_data(1)!=read_data(2)) cs_set_user_money(read_data(1),cs_get_user_money(read_data(1)) + get_pcvar_num(mkb) - 300)
}
    
public 
fwHamPlayerSpawnPost(id
{    
    for( new 
sizeofmapnames ) ; i++ )
    {
        if ( 
equalszMap mapnames] ) )
        return;
    }    
    if(
is_user_alive(id) && get_user_flags(id) & ADMIN_LEVEL_H)
    {
        
StripWeapons(idSecondary);
        
GiveClientWeapon(idCSW_DEAGLEfalseget_pcvar_num(DEAGLEammo), get_pcvar_num(DEAGLEbpammo));
        
give_item(id"weapon_knife");
        
give_item(id"weapon_hegrenade");
        
give_item(id"weapon_flashbang");
        
give_item(id"weapon_flashbang");
        
give_item(id"weapon_smokegrenade");
        
give_item(id"item_assaultsuit");
        
give_item(id"item_thighpack");
    }
}

public 
Event_RoundRestart(id)
{
    
round=0;
}

public 
hook_death()
{
    
nKiller read_data(1)

    if ( (
read_data(3) == 1) && (read_data(5) == 0) )
    {
        
nHp_add get_pcvar_num (health_hs_add)
    }
    else
    
nHp_add get_pcvar_num (health_add)
    
nHp_max get_pcvar_num (health_max)
    if(!(
get_user_flags(nKiller) & ADMIN_LEVEL_H))
        return;
    
    
nKiller_hp get_user_health(nKiller)
    
nKiller_hp += nHp_add
    
if (nKiller_hp nHp_maxnKiller_hp nHp_max
    set_user_health
(nKillernKiller_hp)
    
set_hudmessage(02550, -1.00.1501.01.00.10.1, -1)
    
show_hudmessage(nKiller"Healed +%d hp"nHp_add)
    
message_begin(MSG_ONEget_user_msgid("ScreenFade"), {0,0,0}, nKiller)
    
write_short(1<<10)
    
write_short(1<<10)
    
write_short(0x0000)
    
write_byte(0)
    
write_byte(0)
    
write_byte(200)
    
write_byte(75)
    
message_end()        
}
    
public 
Showrod(id)
{
    for( new 
sizeofmapnames ) ; i++ )
    {
        if ( 
containiszMap mapnames] ) != -)
        return;
    }
    
set_task(10.0"CancelMenu"id);
    new 
menu menu_create("\rVIP menu:""Pressedrod");
    
menu_additem(menu"\yM4A1 and Deagle.""1"0);
    
menu_additem(menu"\yAK47 and Deagle.""2"0);
    if( 
iPlayers[0] >= get_pcvar_num(mtr) && iPlayers[1] >= get_pcvar_num(mct) )
    {
        
menu_additem(menu"\yAWP and Deagle.""3"0);
    }
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
}
    
public 
Pressedrod(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);
    new 
key str_to_num(data);
    switch(
key)
    {
    case 
1: {             
            
StripWeapons(idPrimary);
            
StripWeapons(idSecondary);
            
GiveClientWeapon(idCSW_M4A1falseget_pcvar_num(M4A1ammo), get_pcvar_num(M4A1bpammo))
            
GiveClientWeapon(idCSW_DEAGLEfalseget_pcvar_num(DEAGLEammo), get_pcvar_num(DEAGLEbpammo))
            
give_item(id,"weapon_knife");
            
give_item(id"item_assaultsuit");
            
give_item(id"item_thighpack");
            
            
client_print(idprint_center"You have chosen M4A1 and Deagle!")
            
gUsed[id]++
        }
    case 
2: { 
            
StripWeapons(idPrimary);
            
StripWeapons(idSecondary);
            
GiveClientWeapon(idCSW_AK47falseget_pcvar_num(AK47ammo), get_pcvar_num(AK47bpammo))
            
GiveClientWeapon(idCSW_DEAGLEfalseget_pcvar_num(DEAGLEammo), get_pcvar_num(DEAGLEbpammo))
            
give_item(id"item_assaultsuit");
            
give_item(id"item_thighpack");

            
client_print(idprint_center"You have chosen AK47 and Deagle!")
            
gUsed[id]++
        }
    case 
3: { 
            
StripWeapons(idPrimary);
            
StripWeapons(idSecondary);
            
GiveClientWeapon(idCSW_AWPfalseget_pcvar_num(AWPammo), get_pcvar_num(AWPbpammo))
            
GiveClientWeapon(idCSW_DEAGLEfalseget_pcvar_num(DEAGLEammo), get_pcvar_num(DEAGLEbpammo))
            
give_item(id"item_assaultsuit");
            
give_item(id"item_thighpack");

            
client_print(idprint_center"You have chosen AWP and Deagle!")
            
gUsed[id]++
        }
    }
    
menu_destroy(menu);
    return 
PLUGIN_CONTINUE
}

public 
CancelMenu(id)
{
    
show_menu(id0"^n"1);
}

public 
HandleCmd(id)
{
    if(
get_user_flags(id) & ADMIN_LEVEL_H
        return 
PLUGIN_CONTINUE
    client_print
(idprint_center"Snipers only for VIP!")
    return 
PLUGIN_HANDLED
}

public 
ShowMotd(id)
{
    
show_motd(id"vip.txt")
}

public 
client_putinserver(id)
{
    if (!
task_exists(id)) set_task(60.0"PrintText" ,id)
}

public 
PrintText(id)
{
    
client_print(idprint_chat"[VIP] Write /vip, to see VIP privileges.")
}

public 
ShowVIP(id
{
    if(
get_user_flags(id) & ADMIN_LEVEL_H)
    {
        
set_task(0.1,"print_adminlist",id)
    }
    return 
PLUGIN_CONTINUE


public 
print_adminlist(userid
{
    if(
get_user_flags(id) & ADMIN_LEVEL_H)
    {
        new 
adminnames[33][32]
        new 
message[256]
        new 
idcountxlen
        
        
for(id id <= maxplayers id++)
        if(
is_user_connected(id))
        if(
get_user_flags(id) & ADMIN_LEVEL_H)
        
get_user_name(idadminnames[count++], 31)
        
        
len format(message255"%sVIP online: ",COLOR)
        if(
count 0
        {
            for(
count x++) 
            {
                
len += format(message[len], 255-len"%s%s "adminnames[x], < (count-1) ? ", ":"")
                if(
len 96 
                {
                    
print_message(usermessage)
                    
len format(message255"%s ",COLOR)
                }
            }
            
print_message(usermessage)
        }
        else 
        {
            
len += format(message[len], 255-len"There is no VIP online.")
            
print_message(usermessage)
        }
    }
}

print_message(idmsg[]) 
{
    
message_begin(MSG_ONEgmsgSayText, {0,0,0}, id)
    
write_byte(id)
    
write_string(msg)
    
message_end()

__________________
Please enter this website everyday: http://forums.alliedmods.net/showthread.php?t=169067

Last edited by Evaldas.Grigas; 11-01-2011 at 09:22.
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-01-2011 , 16:37   Re: Cvar doesn't work?
Reply With Quote #4

Then you need to find out what value is getting retrieved by get_pcvar_num(vmr). Just print it somewhere that you can see it (this is debugging, it's not that hard).
__________________
fysiks is offline
Reply


Thread Tools
Display Modes

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 14:26.


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