Raised This Month: $ Target: $400
 0% 

[SM] Exception reported: Invalid convar handle 0 (error 4)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jugule
AlliedModders Donor
Join Date: Apr 2020
Old 05-03-2020 , 09:39   [SM] Exception reported: Invalid convar handle 0 (error 4)
Reply With Quote #1

Plugin:

PHP Code:
/*
 * MyJailbreak - Weapon Plugin.
 * by: shanapu
 * https://github.com/shanapu/MyJailbreak/
 * 
 * Copyright (C) 2016-2017 Thomas Schmidt (shanapu)
 * Contributer: Hexer10
 *
 * This file is part of the MyJailbreak SourceMod Plugin.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, version 3.0, as published by the
 * Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */

/******************************************************************************
                   STARTUP
******************************************************************************/

// Includes
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <cstrike>
#include <colors>
#include <autoexecconfig>
#include <clientprefs>
#include <mystocks>

// Optional Plugins
#undef REQUIRE_PLUGIN
#include <hosties>
#include <myjailbreak>
#include <warden>
#include <myjbwarden>
#define REQUIRE_PLUGIN

// Compiler Options
#pragma semicolon 1
#pragma newdecls required

//Integers
int g_iMenuUsages[MAXPLAYERS+1];

// Booleans
bool g_bIsLateLoad false;
bool g_bWeaponsSelected[MAXPLAYERS+1] = {false, ...};
bool g_bRememberChoice[MAXPLAYERS+1] = {false, ...};
bool g_bTA[MAXPLAYERS+1] = {false, ...};
bool g_bHealth[MAXPLAYERS+1] = {false, ...};
bool gp_bMyJBWarden false;
bool gp_bWarden false;
bool gp_bMyJailBreak false;
bool gp_bHosties false;
bool g_bAllowCT true;
bool g_bAllowT false;

// Handles
Handle g_hMenu1 null;
Handle g_hMenu2 null;
Handle g_hMenu3 null;
Handle g_hMenu4 null;
Handle g_hTimers[MAXPLAYERS 1] = null;
Handle g_aPrimary;
Handle g_aSecondary;
Handle g_hWeapons1 null;
Handle g_hWeapons2 null;

// Console Variables
ConVar gc_bSpawn;
ConVar gc_bPlugin;
ConVar gc_sPrefix;
ConVar gc_bTAWarden;
ConVar gc_bEventDay;
ConVar gc_bJBmenu;
ConVar gc_bAWP;
ConVar gc_bAutoSniper;
ConVar gc_bM249;
ConVar gc_bNegev;
ConVar gc_bHealthWarden;
ConVar gc_bKevlar;
ConVar gc_bKevlarDays;
ConVar gc_sCustomCommandWeapon;
ConVar gc_bCleanMenu;
ConVar gc_iMenuMaxUsages;

// Extern Convars
ConVar g_bTaserWarden;

// Strings
char g_sPrefix[64];
char primaryWeapon[MAXPLAYERS 1][24];
char secondaryWeapon[MAXPLAYERS 1][24];

enum struct g_hWeapons
{
    
char ItemName[64];
    
char desc[64];
}

// Info
public Plugin myinfo =
{
    
name "MyJailbreak - Weapons",
    
author "shanapu",
    
description "Jailbreak weapons script",
    
version MYJB_VERSION,
    
url "https://github.com/shanapu/MyJailbreak"
};

public 
APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max)
{
    
CreateNative("MyWeapons_AllowTeam"Native_AllowTeam);
    
CreateNative("MyWeapons_GetTeamStatus"Native_TeamStatus);

    
RegPluginLibrary("myweapons");

    
g_bIsLateLoad late;

    return 
APLRes_Success;
}

public 
int Native_AllowTeam(Handle pluginint argc)
{
    
int iTeam GetNativeCell(1);

    if (
iTeam == CS_TEAM_CT)
    {
        
g_bAllowCT GetNativeCell(2);
    }
    if (
iTeam == CS_TEAM_T)
    {
        
g_bAllowT GetNativeCell(2);
    }
}

public 
int Native_TeamStatus(Handle pluginint argc)
{
    
int iTeam GetNativeCell(1);

    if (
iTeam == CS_TEAM_CT)
    {
        return 
g_bAllowCT;
    }
    if (
iTeam == CS_TEAM_T)
    {
        return 
g_bAllowT;
    }

    return 
false;
}

// Start
public void OnPluginStart()
{
    
// Translation
    
LoadTranslations("MyJailbreak.Weapons.phrases");

    
// Client Commands
    
RegConsoleCmd("sm_weapon"Command_Weapons"Open the weapon menu if enabled (in EventDays/for CT)");

    
// AutoExecConfig
    
AutoExecConfig_SetFile("Weapons""MyJailbreak");
    
AutoExecConfig_SetCreateFile(true);

    
AutoExecConfig_CreateConVar("sm_weapons_version"MYJB_VERSION"The version of this MyJailbreak SourceMod plugin"FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
gc_bPlugin AutoExecConfig_CreateConVar("sm_weapons_enable""1""0 - disabled, 1 - enable weapons menu"_true0.0true1.0);
    
gc_sPrefix AutoExecConfig_CreateConVar("sm_weapons_prefix""[{green}MyJB.Weapons{default}]""Set your chat prefix for this plugin.");
    
gc_sCustomCommandWeapon AutoExecConfig_CreateConVar("sm_weapons_cmds""gun, guns, weapons, gunmenu, weaponmenu, giveweapon, arms""Set your custom chat command for weapon menu(!weapon (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands))");
    
gc_bSpawn AutoExecConfig_CreateConVar("sm_weapons_spawnmenu""1""0 - disabled, 1 -  enable autoopen weapon menu on spawn"_true0.0true1.0);
    
gc_bEventDay AutoExecConfig_CreateConVar("sm_weapons_noeventday""1""0 - disabled, 1 - enable the weapon menu on non-EventDays round (normal/simon rounds)"_true0.0true1.0);
    
gc_bAWP AutoExecConfig_CreateConVar("sm_weapons_awp""1""0 - disabled, 1 - enable AWP in menu"_true0.0true1.0);
    
gc_bAutoSniper AutoExecConfig_CreateConVar("sm_weapons_autosniper""1""0 - disabled, 1 - enable scar20 & g3sg1 in menu"_true0.0true1.0);
    
gc_bNegev AutoExecConfig_CreateConVar("sm_weapons_negev""1""0 - disabled, 1 - enable negev in menu"_true0.0true1.0);
    
gc_bM249 AutoExecConfig_CreateConVar("sm_weapons_m249""1""0 - disabled, 1 - enable m249 in menu"_true0.0true1.0);
    
gc_bKevlar AutoExecConfig_CreateConVar("sm_weapons_kevlar""1""0 - disabled, 1 - CT get Kevlar & helm on Spawn"_true0.0true1.0);
    
gc_bKevlarDays AutoExecConfig_CreateConVar("sm_weapons_kevlar_eventdays""1""0 - remove all armor on eventdays, 1 - give all player armor on eventdays"_true0.0true1.0);
    
gc_bJBmenu AutoExecConfig_CreateConVar("sm_weapons_jbmenu""1""0 - disabled, 1 - enable autoopen the MyJailbreak !menu after weapon given."_true0.0true1.0);
    
gc_bCleanMenu AutoExecConfig_CreateConVar("sm_weapons_cleanmenu""1""remove 1. & 2. on first page, to avoid conflict with weapon switch"_true0.0true1.0);
    
gc_iMenuMaxUsages AutoExecConfig_CreateConVar("sm_weapons_max_usages""0""0 - unlimited, max usages of !guns command allowed"_true0.0);

    
AutoExecConfig_ExecuteFile();
    
AutoExecConfig_CleanFile();

    
// Hooks
    
HookEvent("player_spawn"Event_PlayerSpawn);
    
HookConVarChange(gc_sPrefixOnSettingChanged);

    
// Cookies
    
g_hWeapons1 RegClientCookie("Primary Weapons"""CookieAccess_Private);
    
g_hWeapons2 RegClientCookie("Secondary Weapons"""CookieAccess_Private);

    
// Late loading
    
if (g_bIsLateLoad)
    {
        for (
int i 1<= MaxClientsi++)
        {
            if (!
IsClientInGame(i))
                continue;

            
OnClientPutInServer(i);
            
OnClientCookiesCached(i);
        }

        
g_bIsLateLoad false;
    }
}

// ConVarChange for Strings
public void OnSettingChanged(Handle convar, const char[] oldValue, const char[] newValue)
{
    if (
convar == gc_sPrefix)
    {
        
strcopy(g_sPrefixsizeof(g_sPrefix), newValue);
    }
}

public 
void OnLibraryRemoved(const char[] name)
{
    if (
StrEqual(name"warden"))
    {
        
gp_bWarden false;
    }
    else if (
StrEqual(name"myjbwarden"))
    {
        
gp_bMyJBWarden false;
    }
    else if (
StrEqual(name"myjailbreak"))
    {
        
gp_bMyJailBreak false;
    }
    else if (
StrEqual(name"hosties"))
    {
        
gp_bHosties false;
    }
}

public 
void OnLibraryAdded(const char[] name)
{
    if (
StrEqual(name"warden"))
    {
        
gp_bWarden true;
    }
    else if (
StrEqual(name"myjbwarden"))
    {
        
gp_bMyJBWarden true;
    }
    else if (
StrEqual(name"myjailbreak"))
    {
        
gp_bMyJailBreak true;
    }
    else if (
StrEqual(name"hosties"))
    {
        
gp_bHosties true;
    }
}

public 
void OnAllPluginsLoaded()
{
    
gp_bWarden LibraryExists("warden");
    
gp_bMyJBWarden LibraryExists("myjbwarden");
    
gp_bMyJailBreak LibraryExists("myjailbreak");
    
gp_bHosties LibraryExists("hosties");
}

// Initialize Plugin
public void OnConfigsExecuted()
{
    
gc_sPrefix.GetString(g_sPrefixsizeof(g_sPrefix));
    
    
delete g_aPrimary;
    
delete g_aSecondary;
    
    
delete g_hMenu1;
    
delete g_hMenu2;
    
delete g_hMenu3;
    
delete g_hMenu4;
    
    
g_aPrimary = new ArrayList(128);
    
g_aSecondary = new ArrayList(128);
    
ListWeapons();

    
// Create menus
    
g_hMenu1 Menu_BuildOptionsMenu(true);
    
g_hMenu2 Menu_BuildOptionsMenu(false);
    
g_hMenu3 Menu_BuildWeaponsMenu(true);
    
g_hMenu4 Menu_BuildWeaponsMenu(false);

    
// Set custom Commands
    
int iCount 0;
    
char sCommands[128], sCommandsL[12][32], sCommand[32];

    
// weapons
    
gc_sCustomCommandWeapon.GetString(sCommandssizeof(sCommands));
    
ReplaceString(sCommandssizeof(sCommands), " """);
    
iCount ExplodeString(sCommands","sCommandsLsizeof(sCommandsL), sizeof(sCommandsL[]));

    for (
int i 0iCounti++)
    {
        
Format(sCommandsizeof(sCommand), "sm_%s"sCommandsL[i]);
        if (!
CommandExists(sCommand))
            
RegConsoleCmd(sCommandCommand_Weapons"Open the weapon menu if enabled (in EventDays/for CT)");
    }
}

/******************************************************************************
                   COMMANDS
******************************************************************************/

// Open the weapon menu
public Action Command_Weapons(int clientint args)
{
    if (
gc_bPlugin.BoolValue)
    {
        if (
client != && IsClientInGame(client))
        {

            if (
gc_iMenuMaxUsages.IntValue <= g_iMenuUsages[client] && gc_iMenuMaxUsages.IntValue != 0)
            {
                
CReplyToCommand(client"%s %t"g_sPrefix"weapon_menu_max_usages");
                return 
Plugin_Handled;
            }

            
g_bRememberChoice[client] = false;
            
DisplayOptionsMenu(client);

            return 
Plugin_Handled;
        }

        return 
Plugin_Continue;
    }
    else 
CReplyToCommand(client"%s %t"g_sPrefix"weapons_disabled");

    return 
Plugin_Continue;
}

/******************************************************************************
                   EVENTS
******************************************************************************/

// On Player Spawn
public void Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));

    
KillAllTimer(client);

    
g_iMenuUsages[client] = 0;
    
g_bHealth[client] = false;
    
g_bTA[client] = false;

    if (
gc_bSpawn.BoolValue)
    {
        
g_hTimers[client] = CreateTimer(1.0Timer_GetWeaponsGetClientUserId(client));
    }

    if (
gc_bKevlar.BoolValue && (GetClientTeam(client) == CS_TEAM_CT))
    {
        
SetEntProp(clientProp_Send"m_ArmorValue"100);
        
SetEntProp(clientProp_Send"m_bHasHelmet"1);
    }
    
    if (!
gp_bMyJailBreak)
    {
        return;
    }
    
    if (!
MyJailbreak_IsEventDayRunning() && !MyJailbreak_IsEventDayPlanned())
    {
        return;
    }

    if (
gc_bKevlarDays.BoolValue)
    {
        
SetEntProp(clientProp_Send"m_ArmorValue"100);
        
SetEntProp(clientProp_Send"m_bHasHelmet"1);
    }
    else
    {
        
SetEntProp(clientProp_Send"m_ArmorValue"0);
        
SetEntProp(clientProp_Send"m_bHasHelmet"0);
    }
}

public 
void MyJailbreak_OnEventDayStart(char [] EventDayName)
{
    for (
int i 1<= MaxClientsi++)
    {
        if (!
IsValidClient(itruefalse))
            continue;

        if (
gc_bKevlarDays.BoolValue)
        {
            
SetEntProp(iProp_Send"m_ArmorValue"100);
            
SetEntProp(iProp_Send"m_bHasHelmet"1);
        }
        else
        {
            
SetEntProp(iProp_Send"m_ArmorValue"0);
            
SetEntProp(iProp_Send"m_bHasHelmet"0);
        }
    }
}

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

void GiveSavedWeaponsFix(int client)
{
    if (!
gc_bEventDay.BoolValue && !MyJailbreak_IsEventDayRunning())
        return;

    if (
IsPlayerAlive(client))
    {
        if (
gc_bPlugin.BoolValue)
        {
            if ((
g_bAllowT && GetClientTeam(client) == CS_TEAM_T) || (g_bAllowCT && GetClientTeam(client) == CS_TEAM_CT))
            {
                
// StripAllPlayerWeapons(client);
                
if (GetPlayerWeaponSlot(clientCS_SLOT_PRIMARY) == -1)
                {
                    if (
StrEqual(primaryWeapon[client], "random"))
                    {
                        
// Select random menu item (excluding "Random" option)
                        
int random GetRandomInt(0GetArraySize(g_aPrimary)-1);
                        
g_hWeapons Item;
                        
GetArrayArray(g_aPrimaryrandomItemsizeof(Item));
                        
GivePlayerItem(clientItem.ItemName);
                    }
                    else 
GivePlayerItem(clientprimaryWeapon[client]);
                }
                if (
GetPlayerWeaponSlot(clientCS_SLOT_SECONDARY) == -1)
                {
                    if (
StrEqual(secondaryWeapon[client], "random"))
                    {
                        
// Select random menu item (excluding "Random" option)
                        
int random GetRandomInt(0GetArraySize(g_aSecondary)-1);
                        
g_hWeapons Item;
                        
GetArrayArray(g_aSecondaryrandomItemsizeof(Item));
                        
GivePlayerItem(clientItem.ItemName);
                    }
                    else 
GivePlayerItem(clientsecondaryWeapon[client]);
                }
                if (
GetPlayerWeaponSlot(clientCS_SLOT_GRENADE) == -1GivePlayerItem(client"weapon_hegrenade");
            }
        }
    }
}

void SetBuyZones(const char[] status)
{
    
int maxEntities GetMaxEntities();
    
char class[24];

    for (
int i MaxClients 1maxEntitiesi++)
    {
        if (!
IsValidEdict(i))
            continue;

        
GetEdictClassname(i, class, sizeof(class));
        if (
StrEqual(class, "func_buyzone"))
        {
            
AcceptEntityInput(istatus);
        }

    }
}

void GiveSavedWeapons(int client)
{
    if (!
gc_bEventDay.BoolValue && !MyJailbreak_IsEventDayRunning())
        return;

    if (((
g_bAllowT && GetClientTeam(client) == CS_TEAM_T) || (g_bAllowCT && GetClientTeam(client) == CS_TEAM_CT)) && IsPlayerAlive(client))
    {
        
g_iMenuUsages[client]++;
        
        
StripAllPlayerWeapons(client);
        
GivePlayerItem(client"weapon_knife");

        if (
gp_bWarden)
        {
            if (
warden_iswarden(client))
            {
                if (
gc_bHealthWarden.BoolValue && !g_bTA[client])
                {
                    
GivePlayerItem(client"weapon_healthshot");
                    
CPrintToChat(client"%s %t"g_sPrefix"weapons_health");
                    
g_bTA[client] = true;
                }

                if (
gc_bTAWarden.BoolValue && !g_bHealth[client])
                {
                    
GivePlayerItem(client"weapon_tagrenade");
                    
CPrintToChat(client"%s %t"g_sPrefix"weapons_ta");
                    
g_bHealth[client] = true;
                }

                if ((
g_bTaserWarden != null) && g_bTaserWarden.BoolValue)
                {
                    
GivePlayerItem(client"weapon_taser");
                }

            }

        if (
StrEqual(primaryWeapon[client], "random"))
        {
            
// Select random menu item (excluding "Random" option)
            
int random GetRandomInt(0GetArraySize(g_aPrimary)-1);
            
g_hWeapons Item;
            
GetArrayArray(g_aPrimaryrandomItemsizeof(Item));
            
GivePlayerItem(clientItem.ItemName);
        }
        else 
GivePlayerItem(clientprimaryWeapon[client]);

        if (
StrEqual(secondaryWeapon[client], "random"))
        {
            
// Select random menu item (excluding "Random" option)
            
int random GetRandomInt(0GetArraySize(g_aSecondary)-1);
            
g_hWeapons Item;
            
GetArrayArray(g_aSecondaryrandomItemsizeof(Item));
            
GivePlayerItem(clientItem.ItemName);
        }
        else 
GivePlayerItem(clientsecondaryWeapon[client]);

        if (
gc_bJBmenu.BoolValue)
        {
            
FakeClientCommand(client"sm_menu");
        }

        
g_hTimers[client] = CreateTimer(6.0Timer_FixGetClientUserId(client));
    }
    }
}

void ResetClientSettings(int client)
{
    
g_bWeaponsSelected[client] = false;
}

void KillAllTimer(int client)
{
    if (
g_hTimers[client] != null)
    {
        
KillTimer(g_hTimers[client]);
        
g_hTimers[client] = null;
    }
}

void ListWeapons()
{
    
ClearArray(g_aPrimary);
    
ClearArray(g_aSecondary);

    
g_hWeapons Items;

    
Format(Items.ItemName64"weapon_m4a1");
    
Format(Items.desc64"M4A1");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_m4a1_silencer");
    
Format(Items.desc64"M4A1-S");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_ak47");
    
Format(Items.desc64"AK-47");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_famas");
    
Format(Items.desc64"FAMAS");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_galilar");
    
Format(Items.desc64"Galil AR");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_aug");
    
Format(Items.desc64"AUG");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_sg556");
    
Format(Items.desc64"SG 553");
    
PushArrayArray(g_aPrimaryItems);

    if (
gc_bNegev.BoolValue)
    {
        
Format(Items.ItemName64"weapon_negev");
        
Format(Items.desc64"Negev");
        
PushArrayArray(g_aPrimaryItems);
    }

    if (
gc_bM249.BoolValue)
    {
        
Format(Items.ItemName64"weapon_m249");
        
Format(Items.desc64"M249");
        
PushArrayArray(g_aPrimaryItems);
    }

    if (
gc_bAWP.BoolValue)
    {
        
Format(Items.ItemName64"weapon_awp");
        
Format(Items.desc64"AWP");
        
PushArrayArray(g_aPrimaryItems);
    }

    if (
gc_bAutoSniper.BoolValue)
    {
        
Format(Items.ItemName64"weapon_scar20");
        
Format(Items.desc64"SCAR-20");
        
PushArrayArray(g_aPrimaryItems);
        
        
Format(Items.ItemName64"weapon_g3sg1");
        
Format(Items.desc64"G3SG1");
        
PushArrayArray(g_aPrimaryItems);
    }

    
Format(Items.ItemName64"weapon_bizon");
    
Format(Items.desc64"PP-Bizon");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_p90");
    
Format(Items.desc64"P90");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_ump45");
    
Format(Items.desc64"UMP-45");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_mp5sd");
    
Format(Items.desc64"MP5-SD");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_mp7");
    
Format(Items.desc64"MP7");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_mp9");
    
Format(Items.desc64"MP9");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_mac10");
    
Format(Items.desc64"MAC-10");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_ssg08");
    
Format(Items.desc64"SSG 08");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_nova");
    
Format(Items.desc64"Nova");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_xm1014");
    
Format(Items.desc64"XM1014");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_sawedoff");
    
Format(Items.desc64"Sawed-Off");
    
PushArrayArray(g_aPrimaryItems);

    
Format(Items.ItemName64"weapon_mag7");
    
Format(Items.desc64"MAG-7");
    
PushArrayArray(g_aPrimaryItems);

    
// Secondary weapons
    
Format(Items.ItemName64"weapon_deagle");
    
Format(Items.desc64"Desert Eagle");
    
PushArrayArray(g_aSecondaryItems);

    
Format(Items.ItemName64"weapon_revolver");
    
Format(Items.desc64"Revolver");
    
PushArrayArray(g_aSecondaryItems);

    
Format(Items.ItemName64"weapon_tec9");
    
Format(Items.desc64"Tec-9");
    
PushArrayArray(g_aSecondaryItems);

    
Format(Items.ItemName64"weapon_elite");
    
Format(Items.desc64"Dual Berettas");
    
PushArrayArray(g_aSecondaryItems);

    
Format(Items.ItemName64"weapon_fiveseven");
    
Format(Items.desc64"Five-SeveN");
    
PushArrayArray(g_aSecondaryItems);

    
Format(Items.ItemName64"weapon_cz75a");
    
Format(Items.desc64"CZ75-Auto");
    
PushArrayArray(g_aSecondaryItems);

    
Format(Items.ItemName64"weapon_glock");
    
Format(Items.desc64"Glock-18");
    
PushArrayArray(g_aSecondaryItems);

    
Format(Items.ItemName64"weapon_usp_silencer");
    
Format(Items.desc64"USP-S");
    
PushArrayArray(g_aSecondaryItems);

    
Format(Items.ItemName64"weapon_p250");
    
Format(Items.desc64"P250");
    
PushArrayArray(g_aSecondaryItems);

    
Format(Items.ItemName64"weapon_hkp2000");
    
Format(Items.desc64"P2000");
    
PushArrayArray(g_aSecondaryItems);
}

/******************************************************************************
                   FORWARDS LISTEN
******************************************************************************/

public void OnMapStart()
{
    
SetBuyZones("Disable");

    
g_bAllowCT true;
    
g_bAllowT false;
}

public 
void OnClientPutInServer(int client)
{
    
ResetClientSettings(client);
}

public 
void OnClientCookiesCached(int client)
{
    
GetClientCookie(clientg_hWeapons1primaryWeapon[client], 24);
    
GetClientCookie(clientg_hWeapons2secondaryWeapon[client], 24);
    
g_bRememberChoice[client] = false;
}

public 
void OnClientDisconnect(int client)
{
    
KillAllTimer(client);
    
    
SetClientCookie(clientg_hWeapons1primaryWeapon[client]);
    
SetClientCookie(clientg_hWeapons2secondaryWeapon[client]);
}

/******************************************************************************
                   MENUS
******************************************************************************/

// Menu first site - choosing mode
Handle Menu_BuildOptionsMenu(bool sameWeaponsEnabled)
{
    
char info1[255], info2[255], info3[255], info4[255], info5[255], info6[255];

    
int sameWeaponsStyle = (sameWeaponsEnabled) ? ITEMDRAW_DEFAULT ITEMDRAW_DISABLED;
    
Menu menu3 CreateMenu(Handler_BuildOptionsMenu);

    
Format(info1sizeof(info1), "%T\n ""weapons_info_title"LANG_SERVER);
    
SetMenuTitle(menu3info1);

    
SetMenuExitButton(menu3true);

    if (
gc_bCleanMenu.BoolValue)
    {
        
AddMenuItem(menu3"1""0"ITEMDRAW_SPACER);
        
AddMenuItem(menu3"1""0"ITEMDRAW_SPACER);
    }

    
Format(info2sizeof(info2), "%T""weapons_info_choose"LANG_SERVER);
    
AddMenuItem(menu3"New"info2);
    
Format(info3sizeof(info3), "%T""weapons_info_same"LANG_SERVER);
    
AddMenuItem(menu3"Same 1"info3sameWeaponsStyle);
    
Format(info4sizeof(info4), "%T""weapons_info_sameall"LANG_SERVER);
    
AddMenuItem(menu3"Same All"info4sameWeaponsStyle);
    
Format(info5sizeof(info5), "%T""weapons_info_random"LANG_SERVER);
    
AddMenuItem(menu3"Random 1"info5);
    
Format(info6sizeof(info6), "%T""weapons_info_randomall"LANG_SERVER);
    
AddMenuItem(menu3"Random All"info6);

    return 
menu3;
}


// Menu Handler first site - choosing mode
public int Handler_BuildOptionsMenu(Menu menuMenuAction actionint clientint param2)
{
    if (
action == MenuAction_Select)
    {
        
char info[24];
        
menu.GetItem(param2infosizeof(info));

        if (
StrEqual(info"New"))
        {
            
g_bWeaponsSelected[client] = true;
            
DisplayMenu(g_hMenu3clientMENU_TIME_FOREVER);
            
g_bRememberChoice[client] = false;
        }
        else if (
StrEqual(info"Same 1"))
        {
            
g_bWeaponsSelected[client] = true;
            if (!
IsPlayerAlive(client)) CPrintToChat(client"%s %t"g_sPrefix"weapons_next");
            else 
CPrintToChat(client"%s %t"g_sPrefix"weapons_same");
            
            
GiveSavedWeapons(client);
            
g_bRememberChoice[client] = false;
        }
        else if (
StrEqual(info"Same All"))
        {
            if (!
IsPlayerAlive(client)) CPrintToChat(client"%s %t"g_sPrefix"weapons_next");
            else 
CPrintToChat(client"%s %t"g_sPrefix"weapons_sameall");
            
GiveSavedWeapons(client);
            
g_bRememberChoice[client] = true;
        }
        else if (
StrEqual(info"Random 1"))
        {
            
g_bWeaponsSelected[client] = true;
            if (!
IsPlayerAlive(client)) CPrintToChat(client"%s %t"g_sPrefix"weapons_next");
            else 
CPrintToChat(client"%s %t"g_sPrefix"weapons_random");
            
            
primaryWeapon[client] = "random";
            
secondaryWeapon[client] = "random";
            
GiveSavedWeapons(client);
            
g_bRememberChoice[client] = false;
        }
        else if (
StrEqual(info"Random All"))
        {
            if (!
IsPlayerAlive(client)) CPrintToChat(client"%s %t"g_sPrefix"weapons_next");
            else 
CPrintToChat(client"%s %t"g_sPrefix"weapons_randomall");
            
primaryWeapon[client] = "random";
            
secondaryWeapon[client] = "random";
            
GiveSavedWeapons(client);
            
g_bRememberChoice[client] = true;
        }
    }
}

// Menu choose weapons
Handle Menu_BuildWeaponsMenu(bool primary)
{
    
char info7[255], info8[255];
    
Menu menu;
    
g_hWeapons Items;

    if (
primary)
    {
        
menu CreateMenu(Menu_Primary);
        
Format(info7sizeof(info7), "%T\n ""weapons_info_prim"LANG_SERVER);
        
SetMenuTitle(menuinfo7);
        
menu.ExitButton true;

        for (
int i=0i<GetArraySize(g_aPrimary);++i)
        {
            
GetArrayArray(g_aPrimaryiItemssizeof(Items));
            
AddMenuItem(menuItems.ItemNameItems.desc);
        }
    }
    else
    {
        
menu CreateMenu(Menu_Secondary);
        
Format(info8sizeof(info8), "%T\n ""weapons_info_sec"LANG_SERVER);
        
SetMenuTitle(menuinfo8);
        
menu.ExitButton true;

        for (
int i=0i<GetArraySize(g_aSecondary);++i)
        {
            
GetArrayArray(g_aSecondaryiItemssizeof(Items));
            
AddMenuItem(menuItems.ItemNameItems.desc);
        }
    }
    return 
menu;
}

// Menu choose primary weapons
public int Menu_Primary(Menu menuMenuAction actionint clientint param2)
{
    if (
action == MenuAction_Select)
    {
        
char info[24];

        
menu.GetItem(param2infosizeof(info));
        
primaryWeapon[client] = info;
        
DisplayMenu(g_hMenu4clientMENU_TIME_FOREVER);
    }
}

// Menu choose secondary weapons
public int Menu_Secondary(Menu menuMenuAction actionint clientint param2)
{
    if (
action == MenuAction_Select)
    {
        
char info[24];
        
menu.GetItem(param2infosizeof(info));
        
secondaryWeapon[client] = info;
        
GiveSavedWeapons(client);
        if (!
IsPlayerAlive(client))
            
CPrintToChat(client"%s %t"g_sPrefix"weapons_next");
    }
}

// Check for display menu
void DisplayOptionsMenu(int client)
{
    if (!
gc_bEventDay.BoolValue && !MyJailbreak_IsEventDayRunning())
        return;

    if (
gc_bPlugin.BoolValue)
    {
        if ((
g_bAllowT && GetClientTeam(client) == CS_TEAM_T) || (g_bAllowCT && GetClientTeam(client) == CS_TEAM_CT))
        {
            if (
strcmp(primaryWeapon[client], "") == || strcmp(secondaryWeapon[client], "") == 0)
                
DisplayMenu(g_hMenu2client30);
            else
                
DisplayMenu(g_hMenu1client30);
        }
    }
}

/******************************************************************************
                   TIMER
******************************************************************************/

// Give choosed weapon timer
public Action Timer_GetWeapons(Handle timerint userid)
{
    
int client GetClientOfUserId(userid);

    
g_hTimers[client] = null;

    if (!
gc_bEventDay.BoolValue && !MyJailbreak_IsEventDayRunning())
        return;

    if (
IsClientInGame(client))
    {
        if (
GetClientTeam(client) > && IsPlayerAlive(client))
        {
            if (
gc_bPlugin.BoolValue)
            {
                if (
gc_bSpawn.BoolValue)
                {
                    if ((
g_bAllowT && GetClientTeam(client) == CS_TEAM_T) || (g_bAllowCT && GetClientTeam(client) == CS_TEAM_CT))
                    {
                        
// Give weapons or display menu.
                        
if (g_bWeaponsSelected[client])
                        {
                            
GiveSavedWeapons(client);
                            
g_bWeaponsSelected[client] = false;
                        }
                        else if (
g_bRememberChoice[client])
                        {
                            
GiveSavedWeapons(client);
                        }
                        else
                        {
                            
DisplayOptionsMenu(client);
                        }
                    }
                }
            }
        }
    }
}

public 
Action Timer_Fix(Handle timerint userid)
{
    
int client GetClientOfUserId(userid);

    
g_hTimers[client] = null;

    if (
IsValidClient(clientfalsefalse))
    {
        if (
GetClientTeam(client) > 1)
        {
            
GiveSavedWeaponsFix(client);
        }
    }

???
jugule is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 05-04-2020 , 12:12   Re: [SM] Exception reported: Invalid convar handle 0 (error 4)
Reply With Quote #2

Is that whole error ???
__________________
Do not Private Message @me
Bacardi 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 09:50.


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