Last active
November 7, 2024 01:34
-
-
Save Rainyan/35cca17e9e4cfaaa920e584c740a5cf5 to your computer and use it in GitHub Desktop.
Address to index converter for Neotokyo SourceMod plugins.
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
| #if defined _NT_GET_BASE_ENTITY_INC_ | |
| #endinput | |
| #endif | |
| #define _NT_GET_BASE_ENTITY_INC_ | |
| #include <sdktools> | |
| // For a valid base entity pointer, returns its entity index. | |
| stock int GetBaseEntity(Address self) | |
| { | |
| static Handle call = INVALID_HANDLE; | |
| if (call == INVALID_HANDLE) | |
| { | |
| StartPrepSDKCall(SDKCall_Raw); | |
| PrepSDKCall_SetVirtual(5); | |
| PrepSDKCall_SetReturnInfo(SDKType_CBaseEntity, SDKPass_Pointer); | |
| call = EndPrepSDKCall(); | |
| if (call == INVALID_HANDLE) | |
| { | |
| SetFailState("Failed to prep SDK call"); | |
| } | |
| } | |
| return SDKCall(call, self); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment