Added GetEntityAddress native (bug 5269, r=dvander).
Added GetEntityAddress native (
bug 5269, r=dvander).
1.1 --- a/core/smn_entities.cpp Sun Jul 22 12:01:35 2012 -0400
1.2 +++ b/core/smn_entities.cpp Sun Jul 22 13:40:37 2012 -0400
1.3 @@ -2226,6 +2226,16 @@
1.4 return 0;
1.5 }
1.6
1.7 +static cell_t GetEntityAddress(IPluginContext *pContext, const cell_t *params)
1.8 +{
1.9 + CBaseEntity * pEntity = GetEntity(params[1]);
1.10 + if (!pEntity)
1.11 + {
1.12 + return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
1.13 + }
1.14 + return reinterpret_cast<cell_t>(pEntity);
1.15 +}
1.16 +
1.17 REGISTER_NATIVES(entityNatives)
1.18 {
1.19 {"ChangeEdictState", ChangeEdictState},
1.20 @@ -2268,5 +2278,6 @@
1.21 {"SetEntPropFloat", SetEntPropFloat},
1.22 {"SetEntPropString", SetEntPropString},
1.23 {"SetEntPropVector", SetEntPropVector},
1.24 + {"GetEntityAddress", GetEntityAddress},
1.25 {NULL, NULL}
1.26 };
2.1 --- a/plugins/include/entity.inc Sun Jul 22 12:01:35 2012 -0400
2.2 +++ b/plugins/include/entity.inc Sun Jul 22 13:40:37 2012 -0400
2.3 @@ -692,6 +692,15 @@
2.4 }
2.5
2.6 /**
2.7 + * Gets the memory address of an entity.
2.8 + *
2.9 + * @param entity Entity index.
2.10 + * @return Address of the entity.
2.11 + * @error Invalid entity.
2.12 + */
2.13 +native Address:GetEntityAddress(entity);
2.14 +
2.15 +/**
2.16 * Retrieves the classname of an entity.
2.17 * This is like GetEdictClassname(), except it works for ALL
2.18 * entities, not just edicts.