Added GetEntityAddress native (bug 5269, r=dvander).

This commit is contained in:
Michael Busby 2012-07-22 13:40:37 -04:00
parent 99ff1179cc
commit a46dcd45d7
2 changed files with 20 additions and 0 deletions

View File

@ -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<cell_t>(pEntity);
}
REGISTER_NATIVES(entityNatives)
{
{"ChangeEdictState", ChangeEdictState},
@ -2268,5 +2278,6 @@ REGISTER_NATIVES(entityNatives)
{"SetEntPropFloat", SetEntPropFloat},
{"SetEntPropString", SetEntPropString},
{"SetEntPropVector", SetEntPropVector},
{"GetEntityAddress", GetEntityAddress},
{NULL, NULL}
};

View File

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