From b5c1b36d259a045f41fa43d8ddd22904805f51cc Mon Sep 17 00:00:00 2001 From: zaCade Date: Mon, 15 Apr 2019 19:34:16 +0200 Subject: [PATCH] entWatch4: Drop based on configured slot. Dont drop if not configured, or knife. --- _entWatch4/configs/entwatch/template.txt | 6 ++++++ _entWatch4/scripting/classes/CConfig.inc | 13 +++++++++++++ _entWatch4/scripting/entWatch-core.sp | 11 +++++++++++ _entWatch4/scripting/include/entWatch_core.inc | 7 +++++++ 4 files changed, 37 insertions(+) diff --git a/_entWatch4/configs/entwatch/template.txt b/_entWatch4/configs/entwatch/template.txt index e5fe55ef..e26b03b2 100644 --- a/_entWatch4/configs/entwatch/template.txt +++ b/_entWatch4/configs/entwatch/template.txt @@ -17,6 +17,12 @@ // 5 = CHAT & HUD. // 6 = USE & HUD. // 7 = ALL. + "slot" "0" // The weapon slot. + // 0 = None + // 1 = Primary + // 2 = Secondary + // 3 = Knife + // 4 = Grenade "mode" "0" // The mode of the item. // 1 = Cooldown. // 2 = Limited uses. diff --git a/_entWatch4/scripting/classes/CConfig.inc b/_entWatch4/scripting/classes/CConfig.inc index b4fc4088..3f32d6f5 100644 --- a/_entWatch4/scripting/classes/CConfig.inc +++ b/_entWatch4/scripting/classes/CConfig.inc @@ -21,6 +21,7 @@ methodmap CConfig < Basic myclass.SetInt("iTriggerID", 0); myclass.SetInt("iDisplay", 0); + myclass.SetInt("iSlot", 0); myclass.SetInt("iMode", 0); myclass.SetInt("iMaxUses", 0); @@ -132,6 +133,18 @@ methodmap CConfig < Basic } } + property int iSlot + { + public get() + { + return this.GetInt("iSlot"); + } + public set(int value) + { + this.SetInt("iSlot", value); + } + } + property int iMode { public get() diff --git a/_entWatch4/scripting/entWatch-core.sp b/_entWatch4/scripting/entWatch-core.sp index 63dcff9b..a65202e8 100644 --- a/_entWatch4/scripting/entWatch-core.sp +++ b/_entWatch4/scripting/entWatch-core.sp @@ -159,6 +159,7 @@ public void OnMapStart() config.iButtonID = hConfig.GetNum("buttonid"); config.iTriggerID = hConfig.GetNum("triggerid"); config.iDisplay = hConfig.GetNum("display"); + config.iSlot = hConfig.GetNum("slot"); config.iMode = hConfig.GetNum("mode"); config.iMaxUses = hConfig.GetNum("maxuses"); config.iCooldown = hConfig.GetNum("cooldown"); @@ -417,6 +418,11 @@ public void OnClientDisconnect(int client) if (item.bClient && item.iClient == client) { + if (item.bWeapon && !(item.dConfig.iSlot == SLOT_NONE || item.dConfig.iSlot == SLOT_KNIFE)) + { + SDKHooks_DropWeapon(item.iClient, item.iWeapon, NULL_VECTOR, NULL_VECTOR); + } + item.iClient = INVALID_ENT_REFERENCE; Call_StartForward(g_hFwd_OnClientItemDisconnect); @@ -443,6 +449,11 @@ public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast if (item.bClient && item.iClient == client) { + if (item.bWeapon && !(item.dConfig.iSlot == SLOT_NONE || item.dConfig.iSlot == SLOT_KNIFE)) + { + SDKHooks_DropWeapon(item.iClient, item.iWeapon, NULL_VECTOR, NULL_VECTOR); + } + item.iClient = INVALID_ENT_REFERENCE; Call_StartForward(g_hFwd_OnClientItemDeath); diff --git a/_entWatch4/scripting/include/entWatch_core.inc b/_entWatch4/scripting/include/entWatch_core.inc index ad99cec4..7444bddd 100644 --- a/_entWatch4/scripting/include/entWatch_core.inc +++ b/_entWatch4/scripting/include/entWatch_core.inc @@ -9,6 +9,13 @@ #define REGISTER_BUTTON 2 #define REGISTER_TRIGGER 3 +/* SLOTS */ +#define SLOT_NONE 0 +#define SLOT_PRIMARY 1 +#define SLOT_SECONDARY 2 +#define SLOT_KNIFE 3 +#define SLOT_GRENADES 4 + /* MODES */ #define MODE_COOLDOWN 1 #define MODE_MAXUSES 2