Raised This Month: $32 Target: $400
 8% 

get entity owner from OnEntityDestroyed function


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nxlinux
Member
Join Date: Oct 2013
Location: China
Old 10-26-2016 , 02:26   get entity owner from OnEntityDestroyed function
Reply With Quote #1

PHP Code:
public OnEntityDestroyed(entity)
{
    
decl String:classname[32];
    if(
IsValidEntity(entity))
    {
        new 
realEnt EntRefToEntIndex(entity);
        new 
client GetEntPropEnt(realEntProp_Data"m_hOwnerEntity");
        }

when entity destroyed, i want get it's owner, why client is -1 always?
nxlinux is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 10-26-2016 , 04:04   Re: get entity owner from OnEntityDestroyed function
Reply With Quote #2

You need to store your reference to owner on entity spawned
__________________
Neuro Toxin is offline
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 10-26-2016 , 09:32   Re: get entity owner from OnEntityDestroyed function
Reply With Quote #3

OnEntityDestroyed doesn't pass an entity reference.

Also, I haven't tested it but try GetEntProp(iEnt, Prop_Send, "m_iAccountID"), see if this one is set, and search for the client based on their Account ID.
Phil25 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 10-26-2016 , 09:52   Re: get entity owner from OnEntityDestroyed function
Reply With Quote #4

Quote:
Originally Posted by Phil25 View Post
OnEntityDestroyed doesn't pass an entity reference.

Also, I haven't tested it but try GetEntProp(iEnt, Prop_Send, "m_iAccountID"), see if this one is set, and search for the client based on their Account ID.
That really only exists on certain entities.
On the other hand I think I figured out what banned my glst account token. m_iAccountID is a banned netprop in csgo, however I don't think it has any effect on any entity that's not a weapon.

Last edited by Mitchell; 10-26-2016 at 09:53.
Mitchell is offline
nxlinux
Member
Join Date: Oct 2013
Location: China
Old 10-26-2016 , 10:41   Re: get entity owner from OnEntityDestroyed function
Reply With Quote #5

Quote:
Originally Posted by Phil25 View Post
OnEntityDestroyed doesn't pass an entity reference.

Also, I haven't tested it but try GetEntProp(iEnt, Prop_Send, "m_iAccountID"), see if this one is set, and search for the client based on their Account ID.
error m_iAccountID not found!!!
nxlinux is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 10-26-2016 , 11:59   Re: get entity owner from OnEntityDestroyed function
Reply With Quote #6

Quote:
Originally Posted by nxlinux View Post
error m_iAccountID not found!!!
PHP Code:
m_iAccount 
__________________
xines is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 10-26-2016 , 12:09   Re: get entity owner from OnEntityDestroyed function
Reply With Quote #7

Quote:
Originally Posted by xines View Post
PHP Code:
m_iAccount 
This is the player's money and is only on the Player entity.
Mitchell is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-26-2016 , 12:14   Re: get entity owner from OnEntityDestroyed function
Reply With Quote #8

Isn't the entity already being destructed when OnEntityDestroyed is called?

i.e. you can't rely on any of its properties having values any more.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 10-26-2016 , 12:22   Re: get entity owner from OnEntityDestroyed function
Reply With Quote #9

It would probably help to mention why you need to get the owner of an entity when it's being destroyed as there is probably other ways to accomplish your goal.
Mitchell is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 10-26-2016 , 12:31   Re: get entity owner from OnEntityDestroyed function
Reply With Quote #10

Quote:
Originally Posted by Mitchell View Post
This is the player's money and is only on the Player entity.
Yes i know that, i just misundersood the situation my bad.
__________________
xines 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 22:13.


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