Raised This Month: $12 Target: $400
 3% 

Solved Invalid CVAR Pointer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-28-2017 , 11:17   Invalid CVAR Pointer
Reply With Quote #1

I'm getting this annoying error, so firstly it was showing line 160 I deleted it now 159, like seriously? No idea where I've mistaken the cvar.
Quote:
L 01/28/2017 - 17:09:49: Invalid CVAR pointer
L 01/28/2017 - 17:09:49: [AMXX] Displaying debug trace (plugin "surf_mod.amxx")
L 01/28/2017 - 17:09:49: [AMXX] Run time error 10: native error (native "get_pcvar_num")
L 01/28/2017 - 17:09:49: [AMXX] [0] surf_mod.sma::plugin_init (line 159)
PHP Code:
//////////////////////////////////////////////////////////////////////////////////////////
/*                        INCLUDES & DEFINES                        */        
//////////////////////////////////////////////////////////////////////////////////////////

#include <amxmodx>
#include <fun>
#include <stripweapons>
#include <fakemeta>
#include <engine>
#include <dhudmessage>
#include <cstrike>
#include <hamsandwich>
#include <xs>

#define PLUGIN "Elite Surf Mod [ESM]"
#define VERSION "1.0"
#define AUTHOR "DoNii"

#define IsValidPlayer(%1) (1<=%1<=g_maxplayers)

#define DMG_GRENADE ( 1 << 24 ) // grenade bits

#define RefreshPlayersList()    get_players(g_iPlayers, g_iNum, g_szAliveFlags)

#define MAXPLAYERS 32

//////////////////////////////////////////////////////////////////////////////////////////
/*                        VARIABLES                       */        
//////////////////////////////////////////////////////////////////////////////////////////

new Ham:Ham_Player_ResetMaxSpeed Ham_Item_PreFrame

/* ..... Rewards ..... */
/////////////////////////
new speed_used[33];                       
new 
gravity_used[33];                    
new 
godmode_used[33];
new 
invisibility_used[33]; 
new 
deagle_used[33];
new 
ak47_used[33];
new 
armor_used[33];
new 
hp_used[33];
new 
norecoil_used[33];
new 
sniper_used[33];
new 
ak47_zoom[33];
new 
deagle_zoom[33];
/////////////////////////

// Classes
new g_player_class_soldier[33];
new 
g_player_class_bomber[33];
new 
g_player_class_knifer[33];
new 
g_player_class_sniper[33];

// CVARS 
////////////////////
new esm_airaccelerate 
new esm_airmove
new esm_shoot_buttons

// shop
new esm_shop_use 
new esm_shop_gravity_price 
new esm_shop_speed_price 
new esm_shop_godmode_price
new esm_shop_godmode_duration
new esm_shop_invisibility_price
new esm_shop_invisibility_duration
new esm_shop_goldendeagle_price
new esm_shop_goldendeagle_damage
new esm_shop_goldenak47_price
new esm_shop_goldenak47_damage
new esm_shop_goldendeagle_zoom
new esm_shop_goldenak47_zoom

// vshop
new esm_vshop_sniper_damage
new esm_vshop_sniper_price

// gameplay
new esm_parachute
new esm_semiclip
new esm_ignore_falldamage
new esm_strip_weapons
new esm_no_owner_damage
new esm_damage_print
new esm_knife_custom
////////////////////

new g_iPlayers[MAXPLAYERS];
new 
g_iNum;
new 
g_iPlayer;
new 
i
new 
g_player_has_vip[33];
new 
g_maxplayers

new const g_szAliveFlags[] = "a"

static TASK_GODMODE 222
static TASK_INVISIBILITY 333

/* Special Weapon Models */
new const GOLDEN_DEAGLE_V[64] = "models/esm/v_golden_deagle.mdl"
new const GOLDEN_DEAGLE_P[64] = "models/esm/p_golden_deagle.mdl"

new const GOLDEN_AK47_V[64] = "models/esm/v_golden_ak47.mdl"
new const GOLDEN_AK47_P[64] = "models/esm/p_golden_ak47.mdl"

new const SNIPER_V[64] = "models/esm/sniper_v.mdl"
new const SNIPER_P[64] = "models/esm/sniper_p.mdl"

new const KNIFE_V[64] = "models/esm/knife_new_v.mdl"
new const KNIFE_P[64] = "models/esm/knife_new_p.mdl"

new const SOLDIER_CLASS[64] = "models/esm/soldier_model.mdl"
new const BOMBER_CLASS[64] = "models/esm/bomber_model.mdl"
new const KNIFER_CLASS[64] = "models/esm/knifer_model.mdl"
new const SNIPER_CLASS[64] = "models/esm/sniper_model.mdl"

new Floatcl_pushangle[33][3]

const 
WEAPONS_BITSUM = (1<<CSW_KNIFE|1<<CSW_HEGRENADE|1<<CSW_FLASHBANG|1<<CSW_SMOKEGRENADE|1<<CSW_C4)

new const 
surf_shop_cmds[][] = {
    
    
"say shop",
    
"say /shop",
    
"say_team shop",
    
"say_team /shop"
}

new const 
vip_shop_cmds[][] = {
    
    
"say vshop",
    
"say /vshop",
    
"say_team vshop",
    
"say_team /vshop"
}

new const 
func_list[][] = {
    
    
"func_button",
    
"func_door_rotating",
    
"func_door"
}

//////////////////////////////////////////////////////////////////////////////////////////
/*                        Main                       */        
//////////////////////////////////////////////////////////////////////////////////////////

public plugin_init() {
    
    
// Plugin register
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
g_maxplayers get_maxplayers()
    
    
// Set Cvars
    
set_cvar_num("sv_airaccelerate"get_pcvar_num(esm_airaccelerate))
    
set_cvar_num("sv_airmove"get_pcvar_num(esm_airmove))
    
    
/* Cvar List */
    
    // server
    
esm_airaccelerate register_cvar("esm_airaccelerate""100"// air accelerate cvar
    
esm_airmove register_cvar("esm_airmove""100"// air move cvar
    
    // shop
    
esm_shop_use register_cvar("esm_shop_use""2"// who can use shop, 0 - CT only | 1 - T only | 2 - Both (CT, T)
    
esm_shop_gravity_price register_cvar("esm_shop_gravity_price""2000"// gravity price
    
esm_shop_speed_price register_cvar("esm_shop_speed_price""4000"// speed price
    
esm_shop_godmode_price register_cvar("esm_shop_godmode_price""6000"// godmode price
    
esm_shop_godmode_duration register_cvar("esm_shop_godmode_duration""10.0"// godmode duration
    
esm_shop_invisibility_price register_cvar("esm_shop_invisibility_price""8000"// invisibility price
    
esm_shop_invisibility_duration register_cvar("esm_shop_invisibility_duration""5.0"// invisibility duration
    
esm_shop_goldendeagle_price register_cvar("esm_shop_goldendeagle_price""10000"// golden deagle price
    
esm_shop_goldendeagle_damage register_cvar("esm_shop_goldendeagle_damage""2"// golden deagle damage
    
esm_shop_goldendeagle_zoom register_cvar("esm_goldendeagle_zoom""1"// zoom for golden deagle, 0 - off | 1 - on
    
esm_shop_goldenak47_price register_cvar("esm_shop_goldenak47_price""12000"// golden ak47 price
    
esm_shop_goldenak47_damage register_cvar("esm_shop_goldenak47_damage""3"// golden ak47 damage
    
esm_shop_goldenak47_zoom register_cvar("esm_shop_goldenak47_zoom ""1"// zoom for golden ak47, 0 - off | 1 - on
    
    // vshop
    
esm_vshop_sniper_damage register_cvar("esm_vshop_sniper_damage""4"// VIP Shop sniper damage multiplier
    
esm_vshop_sniper_price register_cvar("esm_vshop_sniper_price""10000"// sniper price
    
    // gameplay
    
esm_shoot_buttons register_cvar("esm_shoot_buttons""1"// open jail by shooting button, 0 - off | 1 - on
    
esm_parachute register_cvar("esm_parachute""1"// parachute , 0 - off | 1 - on
    
esm_semiclip register_cvar("esm_semiclip""1"// semiclip, 0 - off | 1 - on
    
esm_ignore_falldamage register_cvar("esm_ignore_falldamage""1"// 0 - allow fall damage | 1 - no fall damage
    
esm_strip_weapons register_cvar("esm_strip_weapons""1"// strip weapons on spawn, 0 - off | 1 - on
    
esm_no_owner_damage register_cvar("esm_no_owner_damage""1"// no damage to HE grenade owner, 0 - off | 1 - on
    
esm_damage_print register_cvar("esm_damage_print""1"// print damage, 0 - off | 1 - chat | 2 - HUD | 3 - DHUD
    
esm_knife_custom register_cvar("esm_knife_custom""1"// enable custom knife models, 0 - off | 1 - on
    
    // Ham Hooks
    
    
for ( new isizeof func_listi++ )
    
RegisterHam(Ham_TraceAttackfunc_list[i], "fw_ButtonFunc"
    
    new 
weapon_name[24]
    for (new 
1<= 30i++)
    {
        if (!(
WEAPONS_BITSUM << i) && get_weaponname(iweapon_name23))
        {
            
RegisterHam(Ham_Weapon_PrimaryAttackweapon_name"fw_Weapon_PrimaryAttack_Pre")
            
RegisterHam(Ham_Weapon_PrimaryAttackweapon_name"fw_Weapon_PrimaryAttack_Post"1)
        }
    }
    
    
RegisterHam(Ham_Item_Deploy"weapon_deagle""fw_HamDeployDeagle"1)
    
RegisterHam(Ham_Item_Deploy"weapon_ak47""fw_HamDeployAk47"1)
    
RegisterHam(Ham_Item_Deploy"weapon_awp""fw_HamDeploySniper"1)
    
RegisterHam(Ham_Item_Deploy"weapon_knife""fw_HamDeployKnife"1)
    
    
RegisterHam(Ham_Spawn"player""fw_HamSpawnPost"1)
    
RegisterHam(Ham_TakeDamage"player""fw_HamTakeDamagePre")
    
RegisterHam(Ham_Player_ResetMaxSpeed"player""playerResetMaxSpeed"1)
    
RegisterHam(Ham_Player_PreThink"player""Ham_CBasePlayer_PreThink_Post"1)
    
    
// Client cmds
    
for ( new isizeof surf_shop_cmdsi++ )
    
register_clcmd(surf_shop_cmds[i], "esm_shop_open")    
    
    for ( new 
isizeof vip_shop_cmdsi++ )    
    
register_clcmd(vip_shop_cmds[i], "vip_shop_open")
    
    
register_clcmd("chooseteam""main_menu")    
    
    
// Fakemeta forwards
    
register_forward(FM_CmdStart"fw_CmdStart")
    
register_forward(FM_AddToFullPack"FM_client_AddToFullPack_Post"1)
}


//////////////////////////////////////////////////////////////////////////////////////////
/*                        PRECACHING                        */        
//////////////////////////////////////////////////////////////////////////////////////////

public plugin_precache() {
    
    
precache_model(GOLDEN_DEAGLE_V)
    
precache_model(GOLDEN_DEAGLE_P)    
    
    
precache_model(GOLDEN_AK47_V)
    
precache_model(GOLDEN_AK47_P)
    
    
precache_model(SNIPER_V)
    
precache_model(SNIPER_P)
    
    
precache_model(KNIFE_V)
    
precache_model(KNIFE_P)

    
precache_model(SOLDIER_CLASS)
    
precache_model(BOMBER_CLASS)
    
precache_model(KNIFER_CLASS)
    
precache_model(SNIPER_CLASS)
    
}

//////////////////////////////////////////////////////////////////////////////////////////
/*                        STOCKS                        */        
//////////////////////////////////////////////////////////////////////////////////////////

SetDeagleModel(id) {
    
    
set_pev(idpev_viewmodel2GOLDEN_DEAGLE_V)
    
set_pev(idpev_weaponmodel2GOLDEN_DEAGLE_P)
}

SetAk47Model(id) {
    
    
set_pev(idpev_viewmodel2GOLDEN_AK47_V)
    
set_pev(idpev_weaponmodel2GOLDEN_AK47_P)
}

SetSniperModel(id) {
    
    
set_pev(idpev_viewmodel2SNIPER_V)
    
set_pev(idpev_weaponmodel2SNIPER_P)
}

SetKnifeModel(id) {
    
    
set_pev(idpev_viewmodel2KNIFE_V)
    
set_pev(idpev_weaponmodel2KNIFE_P)
}

SetSoldierClass(id) {
    
    
g_player_class_soldier[id] = true
    g_player_class_bomber
[id] = false
    g_player_class_knifer
[id] = false
    g_player_class_sniper
[id] = false
}

SetBomberClass(id) {
    
    
g_player_class_soldier[id] = false
    g_player_class_bomber
[id] = true
    g_player_class_knifer
[id] = false
    g_player_class_sniper
[id] = false
}

SetKniferClass(id) {
    
    
g_player_class_soldier[id] = false
    g_player_class_bomber
[id] = false
    g_player_class_knifer
[id] = true
    g_player_class_sniper
[id] = false
}

SetSniperClass(id) {
    
    
g_player_class_soldier[id] = false
    g_player_class_bomber
[id] = false
    g_player_class_knifer
[id] = false
    g_player_class_sniper
[id] = true
}

SetClassModel(id) {
    
    if(
g_player_class_soldier[id]) cs_set_user_model(idSOLDIER_CLASS)
    
    else if(
g_player_class_bomber[id]) cs_set_user_model(idBOMBER_CLASS)
    
    else if(
g_player_class_knifer[id]) cs_set_user_model(idKNIFER_CLASS)
    
    else if(
g_player_class_sniper[id]) cs_set_user_model(idSNIPER_CLASS)
    
}

SetClassAbilities(id) {
    
    new 
CsTeams:team cs_get_user_team(id)    
    
    if(
g_player_class_soldier[id]) {
        
        
set_user_health(id150)
        
        
strip_user_weapons(id)
        
give_item(id"weapon_deagle")
        
cs_set_user_bpammo(idCSW_DEAGLE35)
        
        if(
team == CS_TEAM_T) {
            
give_item(id"weapon_ak47")
            
cs_set_user_bpammo(idCSW_AK4790)
        }
        
        else if(
team == CS_TEAM_CT) {
            
give_item(id"weapon_m4a1"); 
            
cs_set_user_bpammo(idCSW_M4A190)
        }
        
        
set_user_rendering(idkRenderFxGlowShell02550kRenderNormal60);
        
    }
    
    else if(
g_player_class_bomber[id]) {
        
        
set_user_health(id200)
        
        
strip_user_weapons(id)
        
give_item(id"weapon_hegrenade")
        
cs_set_user_bpammo(idCSW_HEGRENADE50)
        
        
set_user_rendering(idkRenderFxGlowShell25500kRenderNormal60);
    }
    
    else if(
g_player_class_knifer[id]) {
        
        
set_user_health(id250)
        
        
strip_user_weapons(id)
        
give_item(id"weapon_knife")
        
        
set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha,40)  
    }
    
    else if(
g_player_class_sniper[id]) {
        
        
set_user_health(id300)
        
        
strip_user_weapons(id)
        
give_item(id"weapon_awp")
        
        
set_user_rendering(idkRenderFxGlowShell00255kRenderNormal60);
    }
}

ResetVariables(id) {
    
    
speed_used[id] = false                      
    gravity_used
[id] = false                    
    godmode_used
[id] = false      
    invisibility_used
[id] = false
    deagle_used
[id] = false    
    ak47_used
[id] = false
    armor_used
[id] = false
    hp_used
[id] = false
    norecoil_used
[id] = false
    sniper_used
[id] = false
}

stock ham_strip_weapon(id,weapon[])
{
    if(!
equal(weapon,"weapon_",7)) return 0;
    
    new 
wId get_weaponid(weapon);
    if(!
wId) return 0;
    
    new 
wEnt;
    while((
wEnt engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
    if(!
wEnt) return 0;
    
    if(
get_user_weapon(id) == wIdExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);
    
    if(!
ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
    
ExecuteHamB(Ham_Item_Kill,wEnt);
    
    
set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));
    
    return 
1;
}  

//////////////////////////////////////////////////////////////////////////////////////////
/*                        FUNCTIONS                        */        
//////////////////////////////////////////////////////////////////////////////////////////

public esm_shop_open(id) {
    
    new 
menu menu_create"\r[ESM] \wSurf Shop :""surf_shop" );
    
    
menu_additemmenu"\w[\r1 \wRound] \wLess Gravity \y[\r$\w2000\y]""");
    
menu_additemmenu"\w[\r1 \wRound] \wMore Speed \y[\r$\w4000\y]""");
    
menu_additemmenu"\w[\r5 \wSec] \wGodmode \y[\r$\w6000\y]""");    
    
menu_additemmenu"\w[\r10 \wSec] \wInvisibility \y[\r$\w8000\y]""");
    
menu_additemmenu"\w[\r1 \wRound] \wGolden Deagle \y[\r$\w10000\y]""");    
    
menu_additemmenu"\w[\r1 \wRound] \wGolden AK47 \y[\r$\w12000\y]""");    
    
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );
    
    if(
is_user_alive(id)) {
        
        new 
CsTeams:team cs_get_user_team(id)
        
        if(
get_pcvar_num(esm_shop_use) == 0) {
            
            if(
team != CS_TEAM_CT) {
                
client_print(idprint_chat"[ESM] Only CT Players Can Use")
                return 
PLUGIN_HANDLED;
            }
            
            else if(
team == CS_TEAM_CT) {
                
menu_displayidmenu);
            }
        }
        
        else if(
get_pcvar_num(esm_shop_use) == 1) {
            
            if(
team != CS_TEAM_T) {
                
client_print(idprint_chat"[ESM] Only T Players Can Use")
                return 
PLUGIN_HANDLED;
            }
            
            else if(
team == CS_TEAM_T) {
                
menu_displayidmenu);
            }    
        }
        
        else if(
get_pcvar_num(esm_shop_use) == 2) {
            
            if(
team != CS_TEAM_SPECTATOR) {
                
menu_displayidmenu);
            }    
        }
    }
    
    else {
        
        
client_print(idprint_chat"[ESM] Dead Players Can't Use")
        return 
PLUGIN_HANDLED
    
}
    
    return 
PLUGIN_CONTINUE
}

public 
surf_shopidmenuitem )
{
    if(!
is_user_alive(id)) {
        
client_print(idprint_chat"[ESM] You Can't Buy While Dead")
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED;
    }
    
    switch( 
item )
    {
        
    case 
0:
        {
            if(
cs_get_user_money(id) >= get_pcvar_num(esm_shop_gravity_price) && !gravity_used[id]) {
                
set_user_gravity(id0.7)
                
client_printidprint_chat"[ESM] You Just Bought ^"Less Gravity^"" );
                
cs_set_user_money(idcs_get_user_money(id) - get_pcvar_num(esm_shop_gravity_price))
                
gravity_used[id] = true       
                
            
}
            
            else if(
gravity_used[id]) {
                
client_print(idprint_chat"[ESM] You Can Only Buy Once Per Round")
                return 
PLUGIN_HANDLED;
            }
            
            else if(
cs_get_user_money(id) < get_pcvar_num(esm_shop_gravity_price)) {
                
client_print(idprint_chat"[ESM] Insufficient Funds")
                return 
PLUGIN_HANDLED;
            }
            
        }
        
    case 
1:
        {
            if(
cs_get_user_money(id) >= get_pcvar_num(esm_shop_speed_price) && !speed_used[id]) {
                
set_user_maxspeed(id350.0)
                
client_printidprint_chat"[ESM] You Just Bought ^"More Speed^"" );
                
cs_set_user_money(idcs_get_user_money(id) - get_pcvar_num(esm_shop_speed_price))
                
speed_used[id] = true
                
            
}
            
            else if(
speed_used[id]) {
                
client_print(idprint_chat"[ESM] You Can Only Buy Once Per Round")
                
menu_destroy(menu)
                return 
PLUGIN_HANDLED;
            }
            
            else if(
cs_get_user_money(id) < get_pcvar_num(esm_shop_speed_price)) {
                
client_print(idprint_chat"[ESM] Insufficient Funds")
                
menu_destroy(menu)
                return 
PLUGIN_HANDLED;
            }
            
        }
        
    case 
2:
        {
            if(
cs_get_user_money(id) >= get_pcvar_num(esm_shop_godmode_price) && !godmode_used[id]) {
                
set_user_godmode(id1)
                
client_printidprint_chat"[ESM] You Just Bought ^"Godmode^"" );
                
cs_set_user_money(idcs_get_user_money(id) - get_pcvar_num(esm_shop_godmode_price))
                
godmode_used[id] = true
                
                set_task
(get_pcvar_float(esm_shop_godmode_duration), "remove_godmode"id+TASK_GODMODE)              
                
            }
            
            else if(
godmode_used[id]) {
                
client_print(idprint_chat"[ESM] You Can Only Buy Once Per Round")
                
menu_destroy(menu)
                return 
PLUGIN_HANDLED;
            }
            
            else if(
cs_get_user_money(id) < get_pcvar_num(esm_shop_godmode_price)) {
                
client_print(idprint_chat"[ESM] Insufficient Funds")
                return 
PLUGIN_HANDLED;
            }
            
        }
        
    case 
3:
        {
            if(
cs_get_user_money(id) >= get_pcvar_num(esm_shop_invisibility_price) && !invisibility_used[id]) {
                
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,40)  
                
client_printidprint_chat"[ESM] You Just Bought ^"Invisibility^"" );
                
cs_set_user_money(idcs_get_user_money(id) - get_pcvar_num(esm_shop_invisibility_price))
                
invisibility_used[id] = true  
                
                set_task
(get_pcvar_float(esm_shop_invisibility_duration), "remove_invisibility"id+TASK_INVISIBILITY)      
                
            }
            
            else if(
invisibility_used[id]) {
                
client_print(idprint_chat"[ESM] You Can Only Buy Once Per Round")
                return 
PLUGIN_HANDLED;
            }
            
            else if(
cs_get_user_money(id) < get_pcvar_num(esm_shop_invisibility_price)) {
                
client_print(idprint_chat"[ESM] Insufficient Funds")
                return 
PLUGIN_HANDLED;
            }
        }
        
    case 
4:
        {
            if(
cs_get_user_money(id) >= get_pcvar_num(esm_shop_goldendeagle_price) && !deagle_used[id]) {
                
client_printidprint_chat"[ESM] You Just Bought ^"Golden Deagle^"" );
                
cs_set_user_money(idcs_get_user_money(id) - get_pcvar_num(esm_shop_goldendeagle_price))
                
deagle_used[id] = true
                
                StripWeapons
(idPrimary);
                
                
give_item(id"weapon_deagle")
                
cs_set_user_bpammo(idCSW_DEAGLE35)
                
SetDeagleModel(id)
            }
            
            else if(
deagle_used[id]) {
                
client_print(idprint_chat"[ESM] You Can Only Buy Once Per Round")
                return 
PLUGIN_HANDLED;
            }
            
            else if(
cs_get_user_money(id) < get_pcvar_num(esm_shop_goldendeagle_price)) {
                
client_print(idprint_chat"[ESM] Insufficient Funds")
                return 
PLUGIN_HANDLED;
            }
            
        }
        
    case 
5:
        {
            if(
cs_get_user_money(id) >= get_pcvar_num(esm_shop_goldenak47_price) && !ak47_used[id]) {
                
client_printidprint_chat"[ESM] You Just Bought ^"Golden AK47^"" );
                
cs_set_user_money(idcs_get_user_money(id) - get_pcvar_num(esm_shop_goldenak47_price))
                
ak47_used[id] = true
                
                StripWeapons
(idPrimary)
                
                
give_item(id"weapon_ak47")
                
cs_set_user_bpammo(idCSW_AK4790)
                
SetAk47Model(id)
            }
            
            else if(
ak47_used[id]) {
                
client_print(idprint_chat"[ESM] You Can Only Buy Once Per Round")
                return 
PLUGIN_HANDLED;
            }
            
            else if(
cs_get_user_money(id) < get_pcvar_num(esm_shop_goldenak47_price)) {
                
client_print(idprint_chat"[ESM] Insufficient Funds")
                return 
PLUGIN_HANDLED;
            }
            
        }
    }
    
    return 
PLUGIN_HANDLED;
}

public 
class_menu(id) {
    
    new 
menu menu_create"\r[ESM] \wClass Menu:""menu_handler_class" );
    
    
menu_additemmenu"\wSoldier \r[M4A1|AK47 + Deagle]""");
    
menu_additemmenu"\wBomber \r[HE Grenades]""");
    
menu_additemmenu"\wKnifer \r[Ultra Knife]""");
    
menu_additemmenu"\wSniper \r[AWP + Glock|USP]""");
    
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );
    
    
menu_displayidmenu);
    
}

public 
menu_handler_class(idmenuitem) {
    
    if(
is_user_alive(id)) {
        
        switch( 
item )
        {
            
        case 
0:
            {    
                
SetSoldierClass(id)
                
client_print(idprint_chat"You Selected Soldier Class")
            }
            
        case 
1:
            {
                
SetBomberClass(id
                
client_print(idprint_chat"You Selected Bomber Class")
                
            }
            
        case 
2:
            {    
                
SetKniferClass(id)
                
client_print(idprint_chat"You Selected Knifer Class")
                
            }
            
        case 
3:
            {
                
                
SetSniperClass(id)
                
client_print(idprint_chat"You Selected Sniper Class")
                
            }
            
        default: 
            {
                
                
SetSoldierClass(id)
                
client_print(idprint_chat"You Didn't Select Any Class, Default Class Is Soldier Class")
                
            }
        }
    }

    
menu_destroymenu );
    return 
PLUGIN_HANDLED;
}

public 
main_menu(id) {

    new 
menu menu_create"\r[ESM] \wMain Menu:""menu_handler_main" );

    
menu_additemmenu"\wSurf Shop""");
    
menu_additemmenu"\rVIP \wMenu""");
    
menu_additemmenu"\rADMIN \wMenu^n^n""");
    
menu_additemmenu"\wHelp MOTD""");

    
menu_setpropmenuMPROP_EXITMEXIT_ALL );

    
menu_displayidmenu);    

}

public 
menu_handler_mainidmenuitem )
{

    switch( 
item ) {
        
    case 
0:
        {
            if(
is_user_alive(id)) {
                
                
client_cmd(id"say /shop")
                
            }
        }
        
    case 
1:
        {
            if(
is_user_alive(id) && get_user_flags(id) & ADMIN_LEVEL_H) {
                
                
client_cmd(id"say /vshop")
                
            }
        }
        
    case 
2:
        {
            if(
is_user_alive(id) && get_user_flags(id) & ADMIN_KICK) {
                
                
client_cmd(id"say /ashop")
                
            }    
        }
        
    case 
3:
        {
            
            
show_motd(id"esm_motd.txt")
            
        }
    }

    
menu_destroymenu );
    return 
PLUGIN_HANDLED;
}

public 
FM_client_AddToFullPack_Post(eseiEntidhostflagsplayerpSet) {
    if(
esm_semiclip == 1) {
        
        if( 
player && id != iEnt && get_orig_retval() && is_user_alive(id) )
        {
            
set_es(esES_SolidSOLID_NOT)
        }
    }
}

public 
Ham_CBasePlayer_PreThink_Post(id) {

    if(
esm_semiclip == 1) {
        
        if( !
is_user_alive(id) )
        {
            return
        }
        
        
RefreshPlayersList()
        
        for(
0i<g_iNumi++)
        {
            
g_iPlayer g_iPlayers[i]
            if( 
id != g_iPlayer && get_user_team(id) == get_user_team(g_iPlayer))
            {
                
set_pev(g_iPlayerpev_solidSOLID_NOT)
            }
        }
    }
}

public 
client_PostThink(id) {

    if(
esm_semiclip == 1) {
        
        if( !
is_user_alive(id) )
        {
            return
        }
        
        
RefreshPlayersList()
        
        for(
0i<g_iNumi++)
        {
            
g_iPlayer g_iPlayers[i]
            if( 
g_iPlayer != id && get_user_team(id) == get_user_team(g_iPlayer))
            {
                
set_pev(g_iPlayerpev_solidSOLID_SLIDEBOX)
            }
        }
    }
}  

public 
playerResetMaxSpeed(id) {

    if(
speed_used[id]) 
    {
        
set_user_maxspeed(id350.0)
    }
}  

public 
fw_HamDeployDeagle(ent) {

    new 
id get_pdata_cbase(ent414);

    if(
deagle_used[id]) {
        
SetDeagleModel(id)
    }
}

public 
fw_HamDeployAk47(ent) {

    new 
id get_pdata_cbase(ent414);

    if(
ak47_used[id]) {
        
SetAk47Model(id)
    }
}

public 
fw_HamDeploySniper(ent) {

    new 
id get_pdata_cbase(ent414);

    if(
sniper_used[id]) {
        
SetSniperModel(id)
    }
}

public 
fw_HamDeployKnife(ent) { 

    new 
id get_pdata_cbase(ent414);

    if(
get_pcvar_num(esm_knife_custom) == 1) {
        
SetKnifeModel(id)
    }
}

public 
fw_HamSpawnPost(id) {

    
ResetVariables(id)
    
give_item(id"weapon_knife"// because it strips everything

    
if(IsValidPlayer(id) && is_user_alive(id) && get_pcvar_num(esm_strip_weapons) == 1

    
strip_user_weapons(id)
    
    
SetClassModel(id)    
    
SetClassAbilities(id)
}

public 
fw_HamTakeDamagePre(victiminflictorattackerFloat:damagedamagebit) {
    
    new 
Float:dmg damage // thanks Jimmy !
    
    
if(IsValidPlayer(victim) && damagebit DMG_FALL && get_pcvar_num(esm_ignore_falldamage) == 1) {
        
        return 
HAM_SUPERCEDE // don't take damage
    
}
    
    if(
IsValidPlayer(attacker)) {
        
        if(
get_user_weapon(attacker) == CSW_DEAGLE && deagle_used[attacker]) {
            
dmg *= get_pcvar_num(esm_shop_goldendeagle_damage)
            
SetHamParamFloat(4dmg)
        }
        
        if(
IsValidPlayer(attacker) && get_user_weapon(attacker) == CSW_AK47 && ak47_used[attacker]) {
            
dmg *= get_pcvar_num(esm_shop_goldenak47_damage)
            
SetHamParamFloat(4dmg)
        }    
        
        if(
IsValidPlayer(attacker) && get_user_weapon(attacker) == CSW_AWP && sniper_used[attacker]) {
            
dmg *= get_pcvar_num(esm_vshop_sniper_damage)
            
SetHamParamFloat(4dmg)
        }   
        
        if(
attacker == victim && damagebit DMG_GRENADE && get_pcvar_num(esm_no_owner_damage) == 1) {
            
            return 
HAM_SUPERCEDE // no damage to owner of HE
        
}
        
        if(
attacker != victim && cs_get_user_team(attacker) != cs_get_user_team(victim)) {
            
            if(
get_pcvar_num(esm_damage_print) == 1) {
                
set_hudmessage(random_num(50,255), random_num(50,255), random_num(50,255), 0.50random_float(0.300.70), 06.00.5)
                
show_hudmessage(attacker"%d"floatround(dmg))
            }
            
            else if(
get_pcvar_num(esm_damage_print) == 2) {
                
                
set_dhudmessage(random_num(50,255), random_num(50,255), random_num(50,255), 0.50random_float(0.300.70), 06.00.5)
                
show_dhudmessage(attacker"%d"floatround(dmg))
            }
            
        } 
        
    }
    
    return 
HAM_IGNORED;
}

public 
fw_CmdStart(iduc_handle)
{
    if( !
is_user_aliveid ) ) 
    return 
PLUGIN_HANDLED
    
    
static ButtonOldButtons;
    
Button get_uc(uc_handleUC_Buttons);
    
OldButtons pev(idpev_oldbuttons);
    
    if( ( 
Button IN_ATTACK2 ) && !(OldButtons IN_ATTACK2 ) ) {
        new 
szWeapID get_user_weaponid )
        
        if( 
szWeapID == CSW_DEAGLE && get_pcvar_num(esm_shop_goldendeagle_zoom) == 1) {
            
            if(
deagle_used[id]) { 
                
                if(!
deagle_zoom[id]) {
                    
                    
deagle_zoom[id] = true
                    cs_set_user_zoom
idCS_SET_AUGSG552_ZOOM)
                    
emit_soundidCHAN_ITEM"weapons/zoom.wav"0.202.400100 )
                }
                
                else {
                    
deagle_zoom[id] = false
                    cs_set_user_zoom
idCS_RESET_ZOOM)
                    
                }
            }    
        }
        
        else if( 
szWeapID == CSW_AK47 && get_pcvar_num(esm_shop_goldenak47_zoom) == 1) {
            
            if(
ak47_used[id]) { 
                
                if(!
ak47_zoom[id]) {
                    
                    
ak47_zoom[id] = true
                    cs_set_user_zoom
idCS_SET_AUGSG552_ZOOM)
                    
emit_soundidCHAN_ITEM"weapons/zoom.wav"0.202.400100 )
                }
                
                else {
                    
ak47_zoom[id] = false
                    cs_set_user_zoom
idCS_RESET_ZOOM)
                    
                }
            }
        }
    }
    
    if((
Button IN_USE) && (OldButtons IN_USE) && get_pcvar_num(esm_parachute) == 1)
    {
        static 
Float:fVelocity[3]; pev(idpev_velocityfVelocity);
        if(
fVelocity[2] < 0.0)
        {
            
fVelocity[2] = -60.0
            set_pev
(idpev_velocityfVelocity)
        }
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
vip_shop_open(id) {
    
    if(!
g_player_has_vip[id]) {
        
client_print(idprint_chat"[ESM] No Access To This Shop")
        return 
PLUGIN_HANDLED;
    }
    
    new 
menu menu_create"\r[ESM] \wVIP Shop""vip_shop_handler" );
    
    
menu_additemmenu"\r+\w50 Armor \r[\w$\r1500\r]""");
    
menu_additemmenu"\r+\w50 HP \r[\w$\r3500\r]""");
    
menu_additemmenu"\r[\w1 Round\r] \wNo-Recoil \r[\w$\r6000\r] """);
    
menu_additemmenu"\rHigh-Damage \wSniper \r[\w$\r10000\r]""");
    
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );
    
    if(
is_user_alive(id)) {
        
menu_displayidmenu);
    }
    
    return 
PLUGIN_HANDLED;
}

public 
vip_shop_handleridmenuitem )
{
    if(!
is_user_alive(id)) {
        
client_print(idprint_chat"[VSHOP] Only Alive [VIP] Players Can Use")
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }
    
    new 
money cs_get_user_money(id)
    
    switch( 
item )
    {
    case 
0:
        {
            if(
money >= 1500 && !armor_used[id]) {
                
set_user_armor(idget_user_armor(id) + 50)
                
client_print(idprint_chat"You Just Bought +50 Armor")
                
            }
            
            else if(
money 1500) {
                
client_print(idprint_chat"[VSHOP] Insufficient Funds")
                return 
PLUGIN_HANDLED
            
}
            
            else if(
armor_used[id]) {
                
client_print(idprint_chat"[VSHOP] You Can Only Buy Once A Round")
                return 
PLUGIN_HANDLED
            
}
        }
        
    case 
1:
        {
            if(
money >= 3500 && !hp_used[id]) {
                
set_user_health(idget_user_health(id) + 50)
                
client_print(idprint_chat"You Just Bought +50 HP")
                
            }
            
            else if(
money 3500) {
                
client_print(idprint_chat"[VSHOP] Insufficient Funds")
                return 
PLUGIN_HANDLED
            
}
            
            else if(
hp_used[id]) {
                
client_print(idprint_chat"[VSHOP] You Can Only Buy Once A Round")
                return 
PLUGIN_HANDLED
            
}
            
        }
        
    case 
2:
        {
            
            if(
money >= 6000 && !norecoil_used[id]) {
                
norecoil_used[id] = true
                client_print
(idprint_chat"You Just Bought No Recoil")
                
            }
            
            else if(
money 6000) {
                
client_print(idprint_chat"[VSHOP] Insufficient Funds")
                return 
PLUGIN_HANDLED
            
}
            
            else if(
norecoil_used[id]) {
                
client_print(idprint_chat"[VSHOP] You Can Only Buy Once A Round")
                return 
PLUGIN_HANDLED
            
}    
            
        }
    case 
3:
        {
            
            if(
cs_get_user_money(id) >= get_pcvar_num(esm_vshop_sniper_price) && !sniper_used[id]) {
                
sniper_used[id] = true
                client_print
(idprint_chat"You Just Bought High-Damage Sniper")
                
                
StripWeapons(idPrimary);
                
                
give_item(id"weapon_awp")
                
cs_set_user_bpammo(idCSW_AWP30)
                
SetSniperModel(id)
            }
            
            else if(
money get_pcvar_num(esm_vshop_sniper_price)) {
                
client_print(idprint_chat"[VSHOP] Insufficient Funds")
                return 
PLUGIN_HANDLED
            
}
            
            else if(
sniper_used[id]) {
                
client_print(idprint_chat"[VSHOP] You Can Only Buy Once A Round")
                return 
PLUGIN_HANDLED
            
}
            
        }
    }
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;
}

public 
fw_ButtonFunc(iEntiAttackerFloat:fDamageFloat:vDirection[3], TraceHandleiDamageBits ) {
    
    if(
get_pcvar_num(esm_shoot_buttons) == 1)
    
dllfunc(DLLFunc_UseiEntiAttacker
}

public 
client_putinserver(id) {
    
    if(
is_user_connected(id) && get_user_flags(id) & ADMIN_LEVEL_H) {
        
g_player_has_vip[id] = true
    
}
    
}

public 
client_disconnect(id) {
    
    
ResetVariables(id)
}

public 
fw_Weapon_PrimaryAttack_Pre(ent) {
    
    new 
id pev(entpev_owner)
    
    if (
IsValidPlayer(id) && is_user_alive(id) && norecoil_used[id])
    {
        
pev(idpev_punchanglecl_pushangle[id])
    }
    return 
HAM_IGNORED;
}

public 
fw_Weapon_PrimaryAttack_Post(ent)
{
    new 
id pev(entpev_owner)
    
    if (
IsValidPlayer(id) && is_user_alive(id) && norecoil_used[id])
    {
        new 
Floatpush[3]
        
pev(idpev_punchanglepush)
        
xs_vec_sub(pushcl_pushangle[id], push)
        
xs_vec_mul_scalar(push0.0push)
        
xs_vec_add(pushcl_pushangle[id], push)
        
set_pev(idpev_punchanglepush)
    }
    
    return 
HAM_IGNORED;
}

public 
remove_godmode(id) {
    
    
id -= TASK_GODMODE
    
    set_user_godmode
(id0)
}

public 
remove_invisibility(id) {
    
    
id -= TASK_INVISIBILITY
    
    set_user_rendering
(id)

__________________

Last edited by edon1337; 02-11-2017 at 11:29.
edon1337 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-28-2017 , 11:39   Re: Invalid CVAR Pointer
Reply With Quote #2

Show the line throwing the error. I'm on a phone and cannot easily find line by number.
__________________
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-28-2017 , 11:49   Re: Invalid CVAR Pointer
Reply With Quote #3

Think about what the error message is telling you and then look at your code. You will find that the problem is you are trying to retrieve the value of a cvar before you define them. Simply move those 2 lines below and it will work.
Code:
    //Attempting to use esm_airaccelerate and esm_airmove     set_cvar_num("sv_airaccelerate", get_pcvar_num(esm_airaccelerate))     set_cvar_num("sv_airmove", get_pcvar_num(esm_airmove))         //The above 2 you are trying to get values from are defined here, so the plugin doesn't know they exist yet in your above lines.     esm_airaccelerate = register_cvar("esm_airaccelerate", "100") // air accelerate cvar     esm_airmove = register_cvar("esm_airmove", "100") // air move cvar     //Move both set_cvar_num() lines here and it'll work
__________________

Last edited by Bugsy; 01-28-2017 at 11:50.
Bugsy is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-28-2017 , 15:30   Re: Invalid CVAR Pointer
Reply With Quote #4

Firstly, I'm Sorry for not being online to post the line which gave the error, secondly thanks, that was the problem.
__________________
edon1337 is offline
Reply



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 07:45.


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