Skip to content

Instantly share code, notes, and snippets.

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