# HG changeset patch # User Michael Busby # Date 1342978837 14400 # Node ID 053561f384431b7a43cc9e6ce1f69781f479c208 # Parent fb8a7aa5cd1ac47b61b48d8f1fcb30f96b8e33fa Added GetEntityAddress native (bug 5269, r=dvander). diff -r fb8a7aa5cd1a -r 053561f38443 core/smn_entities.cpp --- a/core/smn_entities.cpp Sun Jul 22 12:01:35 2012 -0400 +++ b/core/smn_entities.cpp Sun Jul 22 13:40:37 2012 -0400 @@ -2226,6 +2226,16 @@ 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 @@ {"SetEntPropFloat", SetEntPropFloat}, {"SetEntPropString", SetEntPropString}, {"SetEntPropVector", SetEntPropVector}, + {"GetEntityAddress", GetEntityAddress}, {NULL, NULL} }; diff -r fb8a7aa5cd1a -r 053561f38443 plugins/include/entity.inc --- a/plugins/include/entity.inc Sun Jul 22 12:01:35 2012 -0400 +++ b/plugins/include/entity.inc Sun Jul 22 13:40:37 2012 -0400 @@ -692,6 +692,15 @@ } /** + * 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 * entities, not just edicts.