Created
January 7, 2026 21:11
-
-
Save Rainyan/3000152f1dfc4ddf9acb24083489d7c3 to your computer and use it in GitHub Desktop.
CBaseEntityList overrides for NT from SourceMod (untested)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <sourcemod> | |
| #include <dhooks> | |
| #pragma semicolon 1 | |
| #pragma newdecls required | |
| static int _numAdds = 0; | |
| public void OnPluginStart() | |
| { | |
| Address vmt = view_as<Address>(0x22502528); | |
| HookVirtual(vmt, 0, OnAddEntity); | |
| HookVirtual(vmt, 1, OnRemoveEntity); | |
| } | |
| void HookVirtual(Address vmt, int index, DHookCallback cb) | |
| { | |
| DynamicHook dh = new DynamicHook(index, HookType_Raw, ReturnType_Void, ThisPointer_Address); | |
| if (!dh) | |
| SetFailState("Dynamic hook failed"); | |
| DHookAddParam(dh, HookParamType_ObjectPtr); | |
| DHookAddParam(dh, HookParamType_Object, 4); | |
| dh.HookRaw(Hook_Post, vmt, cb); | |
| delete dh; | |
| } | |
| stock MRESReturn OnAddEntity(int pThis, DHookParam hParams) | |
| { | |
| ++_numAdds; | |
| PrintToServer(" + OnAddEntity callback: 0x%X (num adds: %d)", pThis, _numAdds); | |
| return MRES_Ignored; | |
| } | |
| stock MRESReturn OnRemoveEntity(int pThis, DHookParam hParams) | |
| { | |
| --_numAdds; | |
| PrintToServer(" - OnRemoveEntity callback: 0x%X (num adds: %d)", pThis, _numAdds); | |
| return MRES_Ignored; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment