View Single Post
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 02-11-2020 , 09:11   Re: VCall Crashes upon execution
Reply With Quote #2

Looks like you forgot to get the pWarpper pointer. that is the first thing I noticed, try this:
PHP Code:
static cell_t Native_IsPlayer(IPluginContextpContext, const cell_tparams)
{
    
CBaseEntitypEntity GetCBaseEntity(params[1], false);
    if (!
pEntity)
    {
        return 
pContext->ThrowNativeError("Entity index %d is invalid"params[1]);
    }

    static 
ICallWrapperpWrapper nullptr;
    if (!
pWrapper)
    {
        
REGISTER_NATIVE_OFFSET("CBaseEntity::IsPlayer",
            
PassInfo retInfo;
            
retInfo.flags PASSFLAG_BYVAL; \
            
retInfo.size sizeof(bool); \
            
retInfo.type PassType_Basic; \
            
pWrapper  g_pBinTools->CreateVCall(offset00, &retInfonullptr0));
    }

    if( !
pWrapper )
    {
         return 
pContext->ThrowNativeError("Failed to get ICallWarpper pointer");
    }

    
//ArgBuffer<CBaseEntity*> vstk(pEntity);

    
unsigned char vstk[sizeof(CBaseEntity*)];
    
unsigned charvptr vstk;

    *(
CBaseEntity**)vptr pEntity;

    
bool bResult;
    
pWrapper->Execute(vstk, &bResult);
    return (
bResult == true) ? 0;

EDIT: Ah, one more thing. don't forget to free it, I think using a List or a Vector to store the pointer and free it on extension unload is a good idea.

Last edited by TheDS1337; 02-11-2020 at 09:14.
TheDS1337 is offline