Raised This Month: $ Target: $400
 0% 

Cvar Utilities


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 06-20-2014 , 10:43   Cvar Utilities
Reply With Quote #1

Code:
enum e_Cvar {
    CVAR_BASE_HEALTH,
    CVAR_TIME_TO_WAVE,
    CVAR_MONSTER_DAMAGE,
    CVAR_BOSS_DAMAGE,
    CVAR_KILL_GOLD,
    CVAR_KILL_MONEY,
    CVAR_KILL_BONUS_GOLD,
    CVAR_KILL_BOSS_GOLD,
    CVAR_KILL_BP_AMMO,
    CVAR_BLOCK_CMD_KILL,
    CVAR_KILL_MONSTER_FX,
    CVAR_ONE_PLAYER_MODE,
    CVAR_WAVE_GOLD,
    CVAR_WAVE_MONEY,
    CVAR_COUNTDOWN_MODE,
    CVAR_RESPAWN_PLAYER_CMD,
    CVAR_SEND_MONSTER_TIME,
    CVAR_SWAP_MONEY,
    CVAR_SWAP_MONEY_MONEY,
    CVAR_SWAP_MONEY_GOLD,
    CVAR_DAMAGE_RATIO,
    CVAR_DAMAGE_GOLD
}

new gCvarInfo[e_Cvar]
new gCvarValue[e_Cvar]

public plugin_init()
{
gCvarInfo[CVAR_BASE_HEALTH]     = CvarRegister("td_base_health", "80");
    gCvarInfo[CVAR_TIME_TO_WAVE]     = CvarRegister("td_time_to_wave", "12")
    gCvarInfo[CVAR_MONSTER_DAMAGE]     = CvarRegister("td_damage", "4");
    gCvarInfo[CVAR_BOSS_DAMAGE]     = CvarRegister("td_boss_damage", "8");
    
    // =====
    
    gCvarInfo[CVAR_KILL_GOLD]     = CvarRegister("td_kill_gold", "3");
    gCvarInfo[CVAR_KILL_BONUS_GOLD]    = CvarRegister("td_kill_bonus_gold", "10");
    gCvarInfo[CVAR_KILL_BOSS_GOLD]     = CvarRegister("td_kill_boss_gold", "6");
    gCvarInfo[CVAR_KILL_MONEY]     = CvarRegister("td_kill_money", "650");
    gCvarInfo[CVAR_KILL_BP_AMMO]     = CvarRegister("td_kill_bp_ammo", "15");
    gCvarInfo[CVAR_WAVE_GOLD]     = CvarRegister("td_wave_gold", "5");
    gCvarInfo[CVAR_WAVE_MONEY]     = CvarRegister("td_wave_money", "1000");
    
    gCvarInfo[CVAR_SWAP_MONEY]     = CvarRegister("td_swap_money", "1");
    gCvarInfo[CVAR_SWAP_MONEY_MONEY] = CvarRegister("td_swap_money_money", "10000");
}
public OnChangeCvarValue( handleCvar, const oldValue[], const newValue[], const cvarName[], const defaultValue[] )
{
    if(handleCvar != _:gCvarInfo[CVAR_SEND_MONSTER_TIME])
    {
        server_print("%s %d", newValue, handleCvar)
        gCvarValue[e_Cvar:handleCvar] = str_to_num(newValue)
    }
}
I want to set value of Cvar to gCvarValue which is created by enum, when i want to set this value, i've got Index out of bounds error.

How to do it usings enum's ?
grs4 is offline
 


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


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