[entWatch-core] Mark items destroyed when one of their entities is destroyed.

This commit is contained in:
zaCade 2025-03-13 18:40:50 +01:00
parent 786225b6a2
commit 386da2e248
2 changed files with 18 additions and 1 deletions

View File

@ -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;
}

View File

@ -22,6 +22,8 @@ methodmap CItem < Basic
myclass.SetFloat("flWait", 0.0);
myclass.SetBool("bDestroyed", false);
return view_as<CItem>(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
{