View Single Post
xerox8521
Senior Member
Join Date: Sep 2011
Old 03-18-2016 , 12:40   Re: Correct way to handle Vectors
Reply With Quote #6

NVM. did it differently using sourcepawn now.


Hm yea tried that but doesn't seem to work either.

PHP Code:
cell_t Native_GetWeaponShootPosition(IPluginContext *pContext, const cell_t *params)
{
    static 
ICallWrapper *pWrapper NULL;
    if(!
pWrapper)
    {
        
REGISTER_NATIVE_ADDR("CBasePlayer::Weapon_ShootPosition",
        
            
PassInfo ret;\
            
            
ret.flags PASSFLAG_BYVAL;\
            
ret.size sizeof(Vector);\
            
ret.type PassType_Basic;\
            
pWrapper g_pBinTools->CreateCall(addrCallConv_ThisCall, &retNULL0));
    }
    
CBaseEntity *pEntity;
    if(!(
pEntity GetCBaseEntity(params[1], true)))
    {
        return 
pContext->ThrowNativeError("Client index %d is invalid",params[1]);
    }
    
    
cell_t *pPos;
    
pContext->LocalToPhysAddr(params[2], &pPos);
    
    
unsigned char vstk[sizeof(CBaseEntity *)];
    
unsigned char *vptr vstk;
    
    *(
CBaseEntity **)vptr pEntity;
    
//vptr +=sizeof(CBaseEntity *);
    
Vector pos;
    
pWrapper->Execute(vstk, &pos);
    
    
pPos[0] = sp_ftoc(pos.x);
    
pPos[1] = sp_ftoc(pos.y);
    
pPos[2] = sp_ftoc(pos.z);
    return 
1;


Last edited by xerox8521; 03-18-2016 at 12:46.
xerox8521 is offline