Hi,
so i have this function CBaseEntity::IsPlayer (i know there are other ways to check for the player) and it crashes upon execution and I'm not sure why it crashes. I've tried to use the ArgBuffer class but that also crashes.
Offset is correct as it works just fine when i tested it directly via SDKCall.
Edit: Looks liek the crash doesnt obviously point to the Execute function.
https://crash.limetech.org/7ngxvvi4ly75
SM Version
Meta Version
PHP Code:
static cell_t Native_IsPlayer(IPluginContext* pContext, const cell_t* params)
{
CBaseEntity* pEntity = GetCBaseEntity(params[1], false);
if (!pEntity)
{
return pContext->ThrowNativeError("Entity index %d is invalid", params[1]);
}
static ICallWrapper* pWrapper = nullptr;
if (!pWrapper)
{
REGISTER_NATIVE_OFFSET("CBaseEntity::IsPlayer",
PassInfo retInfo;
retInfo.flags = PASSFLAG_BYVAL; \
retInfo.size = sizeof(bool); \
retInfo.type = PassType_Basic; \
g_pBinTools->CreateVCall(offset, 0, 0, &retInfo, nullptr, 0));
}
//ArgBuffer<CBaseEntity*> vstk(pEntity);
unsigned char vstk[sizeof(CBaseEntity*)];
unsigned char* vptr = vstk;
*(CBaseEntity**)vptr = pEntity;
bool bResult;
pWrapper->Execute(vstk, &bResult);
return (bResult == true) ? 1 : 0;
}
REGISTER_NATIVE_OFFET is defined as
PHP Code:
#define REGISTER_NATIVE_OFFSET(name, code)\
int offset;\
GET_OFFSET(name);\
code;\
g_RegNatives.Register(pWrapper);
GET_OFFSET is defined as
PHP Code:
#define GET_OFFSET(name) \
if(!g_pGameConf->GetOffset(name, &offset) || !offset) \
{\
return pContext->ThrowNativeError("Failed to get offset: %s", name);\
}\