Last active
August 11, 2024 11:06
-
-
Save Rainyan/35cca17e9e4cfaaa920e584c740a5cf5 to your computer and use it in GitHub Desktop.
Address to index converter for Neotokyo SourceMod plugins.
This file contains 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 <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