How can I interrogate map entities, such as control points and their properties for a Team Fortress server?
I spent a long time investigating SourceMod because I discovered it had a function called FindEntityByClassname, which sounded ideal, but I can't make head or tail of its cryptic code.
PHP Code:
static cell_t FindEntityByClassname(IPluginContext *pContext, const cell_t *params)
{
static ValveCall *pCall = NULL;
if (!pCall)
{
ValvePassInfo pass[3];
InitPass(pass[0], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL, VDECODE_FLAG_ALLOWNULL|VDECODE_FLAG_ALLOWWORLD);
InitPass(pass[1], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
InitPass(pass[2], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
if (!CreateBaseCall("FindEntityByClassname", ValveCall_EntityList, &pass[2], pass, 2, &pCall))
{
return pContext->ThrowNativeError("\"FindEntityByClassname\" not supported by this mod");
} else if (!pCall) {
return pContext->ThrowNativeError("\"FindEntityByClassname\" wrapper failed to initialize");
}
}
CBaseEntity *pEntity;
START_CALL();
*(void **)vptr = g_EntList;
DECODE_VALVE_PARAM(1, vparams, 0);
DECODE_VALVE_PARAM(2, vparams, 1);
FINISH_CALL_SIMPLE(&pEntity);
return gamehelpers->EntityToBCompatRef(pEntity);
}