From 99399febad4f9ebc57b35f25e81f3e84e67aaaa7 Mon Sep 17 00:00:00 2001 From: zaCade Date: Tue, 9 Apr 2019 14:15:34 +0200 Subject: [PATCH] entWatch4: Add internal button cooldown. Using button while 'waiting' would otherwise cause the item to go on cooldown in entWatch, while not actually being successfully used in the map. --- _entWatch4/scripting/classes/CItem.inc | 13 +++++++++++++ _entWatch4/scripting/entWatch-core.sp | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/_entWatch4/scripting/classes/CItem.inc b/_entWatch4/scripting/classes/CItem.inc index 26dcae80..4191a159 100644 --- a/_entWatch4/scripting/classes/CItem.inc +++ b/_entWatch4/scripting/classes/CItem.inc @@ -19,6 +19,7 @@ methodmap CItem < Basic myclass.SetInt("iTimesUsed", 0); myclass.SetInt("iTimeReady", 0); + myclass.SetInt("iWaitTill", 0); return view_as(myclass); } @@ -110,6 +111,18 @@ methodmap CItem < Basic } } + property int iWaitTill + { + public get() + { + return this.GetInt("iWaitTill"); + } + public set(int value) + { + this.SetInt("iWaitTill", value); + } + } + property bool bClient { diff --git a/_entWatch4/scripting/entWatch-core.sp b/_entWatch4/scripting/entWatch-core.sp index 9c96940d..48aac749 100644 --- a/_entWatch4/scripting/entWatch-core.sp +++ b/_entWatch4/scripting/entWatch-core.sp @@ -494,6 +494,15 @@ public Action OnButtonPress(int button, int client) if ((item.bButton && item.iButton == button) && (item.bClient && item.iClient == client)) { + if (HasEntProp(button, Prop_Data, "m_flWait")) + { + if (item.iWaitTill < RoundToCeil(GetEngineTime())) + { + item.iWaitTill = RoundToCeil(GetEngineTime() + GetEntPropFloat(button, Prop_Data, "m_flWait")); + } + else return Plugin_Handled; + } + Action aResult; Call_StartForward(g_hFwd_OnClientItemCanActivate); Call_PushCell(client);