Introduction
This is a module that allows one to process some 'missing class entity' that comes with the map. For example, wanna play CS on some TFC map? Or having trouble handling some custom renderer on the server side?
This module is
NOT for currently existing classes, like "info_target" which already comes with a managing class CBaseEntity.
This is for some edge cases where a map comes with an entity that your MP.DLL has no corresponding class to manage it.
The module will therefore inject a 'fake' class to manage this entity and forward two of many member functions to your AMX plugin.
Natives
Only three of them. Super straightforward.
Code:
/*
* Purpose: Inject an entity class into the engine, and register a callback function of its Spawn()
* @param szClassName: Entity class name, same as the one typed into LINK_ENTITY_TO_CLASS() macro in HLSDK.
* @param szSpawnCallback: The local AMX callback function which will be invoked during DispatchSpawn() phase.
The local AMX callback function must come with a signature the same as Ham_Spawn.
* @return int32_t: 0 if fail, other numbers if succeed.
* @except AMX_ERR_NATIVE: Throw if no such AMX callback is found.
*/
native MEE_RegisterEntitySpawn(const szClassName[], const szSpawnCallback[]);
/*
* Purpose: Inject an entity class into the engine, and register a callback function of its KeyValue()
* @param szClassName: Entity class name, same as the one typed into LINK_ENTITY_TO_CLASS() macro in HLSDK.
* @param szKvdCallback: The local AMX callback function which will be invoked during DispatchKeyValue() phase.
The local AMX callback function must come with a signature as follows:
public callback(iEntity, const szKey[], const szValue[]) -> bool
* @return int32_t: 0 if fail, other numbers if succeed.
* @except AMX_ERR_NATIVE: Throw if no such AMX callback is found.
*/
native MEE_RegisterEntityKvd(const szClassName[], const szKvdCallback[]);
/*
* Purpose: Replace a managing class of one entity with another.
* @param szOriginalClassName: Entity class name, same as the one typed into LINK_ENTITY_TO_CLASS() macro in HLSDK.
* @param szDestClassName: Entity class name, same as the one typed into LINK_ENTITY_TO_CLASS() macro in HLSDK.
* @return bool: 0 on fail, 1 on success.
* @except AMX_ERR_NATIVE: Another replacement had been registered and clashed.
* @note: Be extremely careful with this one, as it might cause memory access errors everywhere.
A safe example will be to treat spawning points from DoDC, TFC maps as if they were the CSCZ one.
*/
native MEE_ReplaceLinkedClass(const szOriginalClassName[], const szDestClassName[]);
You can use RegisterHamFromEntity() to further manipulate the entity in the Spawn() forward I provided. They will work as if it's on CBaseEntity, or "info_target" dummy thingy.
Supported games
Counter-Strike
Counter-Strike: Condition Zero
Untested on other games.
Souce code & Runtime
Available
here.
You will need VC Runtime 2022 from Microsoft.
Linux is unsupported and never will.