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

How to get an entity's owner?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rsdtt
Senior Member
Join Date: Oct 2009
Old 01-07-2014 , 23:34   How to get an entity's owner?
Reply With Quote #1

I use AddNormalSoundHook() to get a knife sound, and I want to know who use this knife

Code:
AddNormalSoundHook(Hook_NormalSound)

public Action:Hook_NormalSound(clients[64], &numClients, String:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags)
{
	new client = GetEntPropEnt(entity, Prop_Data, "m_hOwner")
	PrintToServer("NormalSHook sample %s, entity %d, client %d", sample, entity, client)
	
	
	return Plugin_Continue
}
I try this, but it doesn't work.
__________________
I am learning sm now
rsdtt is offline
rsdtt
Senior Member
Join Date: Oct 2009
Old 01-07-2014 , 23:38   Re: How to get an entity's owner?
Reply With Quote #2

I wanted to record the knife attack times, right mouse knife dosen't record in weapon_fire event.

sorry for my bad English
__________________
I am learning sm now
rsdtt is offline
V952
Member
Join Date: Jan 2012
Location: Odessa, Ukraine
Old 01-08-2014 , 00:01   Re: How to get an entity's owner?
Reply With Quote #3

Try to use m_hOwnerEntity instead of m_hOwner. Add classname check because not all entities have m_hOwner field, you will have a bunch of errors.
P.S.: To catch primary attack of the weapon you have to install hook on CBaseCombatWeapon::PrimaryAttack function, this is the best case for what you want. You can try this with SDKHooks.
__________________
HL2DM Real-Life Server: 195.138.78.198:27015
V952 is offline
Send a message via Skype™ to V952
rsdtt
Senior Member
Join Date: Oct 2009
Old 01-08-2014 , 01:24   Re: How to get an entity's owner?
Reply With Quote #4

Quote:
Originally Posted by V952 View Post
Try to use m_hOwnerEntity instead of m_hOwner. Add classname check because not all entities have m_hOwner field, you will have a bunch of errors.
P.S.: To catch primary attack of the weapon you have to install hook on CBaseCombatWeapon:rimaryAttack function, this is the best case for what you want. You can try this with SDKHooks.
you are right, when I just make the knife sound, it haven't error.
thank you very much
__________________
I am learning sm now
rsdtt is offline
rsdtt
Senior Member
Join Date: Oct 2009
Old 01-08-2014 , 01:45   Re: How to get an entity's owner?
Reply With Quote #5

Quote:
Originally Posted by V952 View Post
Try to use m_hOwnerEntity instead of m_hOwner. Add classname check because not all entities have m_hOwner field, you will have a bunch of errors.
P.S.: To catch primary attack of the weapon you have to install hook on CBaseCombatWeapon:rimaryAttack function, this is the best case for what you want. You can try this with SDKHooks.
can you teach me how to use this SDKHooks?
I learn sm just a few day, and I wanted to know more . Thanks
__________________
I am learning sm now
rsdtt is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 01-08-2014 , 10:50   Re: How to get an entity's owner?
Reply With Quote #6

Are you sure entity is not already the owner...
Mitchell is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 01-08-2014 , 11:33   Re: How to get an entity's owner?
Reply With Quote #7

OnPlayerRunCommand you can check IN_ATTACK and IN_ATTACK2 and IN_ATTACK3, isn't that left and right mouse buttons and something else (IN_ATTACK3?)
__________________
View my Plugins | Donate

Last edited by TnTSCS; 01-08-2014 at 11:33.
TnTSCS is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-08-2014 , 11:42   Re: How to get an entity's owner?
Reply With Quote #8

Quote:
Originally Posted by TnTSCS View Post
OnPlayerRunCommand you can check IN_ATTACK and IN_ATTACK2 and IN_ATTACK3, isn't that left and right mouse buttons and something else (IN_ATTACK3?)
left mouse button, right mouse button, and mouse-wheel click (but only in TF2).
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 01-08-2014 , 13:28   Re: How to get an entity's owner?
Reply With Quote #9

With OnPlayerRunCmd you can't trace multiple attacks in the case if player is holding the mouse button.
xf117 is offline
Send a message via ICQ to xf117
rsdtt
Senior Member
Join Date: Oct 2009
Old 01-09-2014 , 04:06   Re: How to get an entity's owner?
Reply With Quote #10

Quote:
Originally Posted by xf117 View Post
With OnPlayerRunCmd you can't trace multiple attacks in the case if player is holding the mouse button.
yes, so I use weapon_fire and sound hook.

I still want to know how to install hook on CBaseCombatWeapon:rimaryAttack
__________________
I am learning sm now
rsdtt 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 07:24.


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