From 386da2e248c10f341fcd06cbd16706ec87d58c9e Mon Sep 17 00:00:00 2001 From: zaCade Date: Thu, 13 Mar 2025 18:40:50 +0100 Subject: [PATCH] [entWatch-core] Mark items destroyed when one of their entities is destroyed. --- entWatch4/scripting/entWatch-core.sp | 5 ++++- entWatch4/scripting/include/entWatch/CItem.inc | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/entWatch4/scripting/entWatch-core.sp b/entWatch4/scripting/entWatch-core.sp index 8068f733..c3fdd89a 100644 --- a/entWatch4/scripting/entWatch-core.sp +++ b/entWatch4/scripting/entWatch-core.sp @@ -354,7 +354,7 @@ stock bool RegisterExistingItem(CConfig config, int entity, int type) //---------------------------------------------------------------------------------------------------- stock bool RegisterItemEntity(CItem item, int entity, int type) { - if (Entity_IsValid(entity)) + if (Entity_IsValid(entity) && !item.bDestroyed) { int iOwner = Entity_GetOwner(entity); int iParent = Entity_GetParent(entity); @@ -415,18 +415,21 @@ public void OnEntityDestroyed(int entity) { item.iClient = INVALID_ENT_REFERENCE; item.iWeapon = INVALID_ENT_REFERENCE; + item.bDestroyed = true; return; } else if (item.bButton && item.iButton == entity) { item.iButton = INVALID_ENT_REFERENCE; + item.bDestroyed = true; return; } else if (item.bTrigger && item.iTrigger == entity) { item.iTrigger = INVALID_ENT_REFERENCE; + item.bDestroyed = true; return; } diff --git a/entWatch4/scripting/include/entWatch/CItem.inc b/entWatch4/scripting/include/entWatch/CItem.inc index e993453d..84bd9e06 100644 --- a/entWatch4/scripting/include/entWatch/CItem.inc +++ b/entWatch4/scripting/include/entWatch/CItem.inc @@ -22,6 +22,8 @@ methodmap CItem < Basic myclass.SetFloat("flWait", 0.0); + myclass.SetBool("bDestroyed", false); + return view_as(myclass); } @@ -124,6 +126,18 @@ methodmap CItem < Basic } } + property bool bDestroyed + { + public get() + { + return this.GetBool("bDestroyed"); + } + public set(bool value) + { + this.SetBool("bDestroyed", value); + } + } + property bool bClient {