From b92cd30fa14518d7fa39e7b99c930cfbf75a5874 Mon Sep 17 00:00:00 2001 From: Richard Helgeby Date: Thu, 16 Jan 2014 18:52:40 +0100 Subject: [PATCH] Don't set weapon transparency if weapon entity has children (that may not have the m_nRenderMode attribute). --- src/zr/zombiereloaded.inc | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/zr/zombiereloaded.inc b/src/zr/zombiereloaded.inc index 9160916..d9aa4db 100644 --- a/src/zr/zombiereloaded.inc +++ b/src/zr/zombiereloaded.inc @@ -477,3 +477,44 @@ stock Math_GetRandomInt(min, max) return RoundToCeil(float(random) / (float(SIZE_OF_INT) / float(max - min + 1))) + min - 1; } + +/** + * (from SMLIB) + * Gets the parent entity of an entity. + * + * @param entity Entity Index. + * @return Entity Index of the parent. + */ +stock Entity_GetParent(entity) +{ + return GetEntPropEnt(entity, Prop_Data, "m_pParent"); +} + +/** + * Returns whether an entity is referred to as the parent entity. + * + * @praram entity Entity index. + * + * @return True if entity has children, false otherwise. + */ +stock bool:Entity_HasChildren(entity) +{ + new maxEntities = GetMaxEntities(); + + // Loop through all entity indexes, after players. + for (new loopEntity = MAXPLAYERS + 1; loopEntity < maxEntities; loopEntity++) + { + if (!IsValidEntity(loopEntity)) + { + continue; + } + + new parentEntity = Entity_GetParent(loopEntity); + if (parentEntity == entity) + { + return true; + } + } + + return false; +}