Raised This Month: $51 Target: $400
 12% 

Change entity owner


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 07-19-2015 , 12:40   Change entity owner
Reply With Quote #1

I need to set entity owner for hegrenade_projectile (CSS)

PHP Code:
int *CHelper::getOwnerEntity(CBaseEntity *pEntity//function is the same for getThrower
{
    
IServerNetworkable *pNetWeapon = ((IServerUnknown *)pEntity)->GetNetworkable();
    
ServerClass *pServerClass pNetWeapon->GetServerClass();
    if (!
pServerClass)
    {
        
g_pSM->LogError(myself"Invalid server class.");
    }

    
sm_sendprop_info_t info;
    if (!
gamehelpers->FindSendPropInfo(pServerClass->GetName(), "m_hOwnerEntity", &info))  // m_hThrower for getThrower
    
{
        
g_pSM->LogError(myself"Could not find m_hOwnerEntity on %s"pServerClass->GetName());
    }
    
    return (
int *)(((intptr_t)pEntity) + info.actual_offset);

Here is the way I change these values:
PHP Code:
    int *owner CHelper::getOwnerEntity(explosion);
    if(
owner) {
        *
owner newowner;
    }
    
int *thrower CHelper::getThrower(explosion);
    if(
thrower) {
        *
thrower newowner;
    } 
But after these manipulations the grenade still remains own to the world (all the player killed by this HE are killed by the world)

Last edited by kadet.89; 07-19-2015 at 12:42.
kadet.89 is offline
Send a message via Skype™ to kadet.89
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 07-19-2015 , 19:27   Re: Change entity owner
Reply With Quote #2

m_hOwnerEntity stores an EHANDLE (CBaseHandle<CBaseEntity>), not a CBaseEntity ptr.
__________________
asherkin is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode