diff --git a/core/smn_entities.cpp b/core/smn_entities.cpp index 39d55551..4af79bef 100644 --- a/core/smn_entities.cpp +++ b/core/smn_entities.cpp @@ -2226,6 +2226,16 @@ static cell_t SetEntityFlags(IPluginContext *pContext, const cell_t *params) return 0; } +static cell_t GetEntityAddress(IPluginContext *pContext, const cell_t *params) +{ + CBaseEntity * pEntity = GetEntity(params[1]); + if (!pEntity) + { + return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]); + } + return reinterpret_cast(pEntity); +} + REGISTER_NATIVES(entityNatives) { {"ChangeEdictState", ChangeEdictState}, @@ -2268,5 +2278,6 @@ REGISTER_NATIVES(entityNatives) {"SetEntPropFloat", SetEntPropFloat}, {"SetEntPropString", SetEntPropString}, {"SetEntPropVector", SetEntPropVector}, + {"GetEntityAddress", GetEntityAddress}, {NULL, NULL} }; diff --git a/plugins/include/entity.inc b/plugins/include/entity.inc index 274bbc60..2a5e5703 100644 --- a/plugins/include/entity.inc +++ b/plugins/include/entity.inc @@ -691,6 +691,15 @@ stock SetEntDataArray(entity, offset, const array[], arraySize, dataSize=4, bool } } +/** + * Gets the memory address of an entity. + * + * @param entity Entity index. + * @return Address of the entity. + * @error Invalid entity. + */ +native Address:GetEntityAddress(entity); + /** * Retrieves the classname of an entity. * This is like GetEdictClassname(), except it works for ALL