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

Using SDKHook_Touch with grenades?


Post New Thread Reply   
 
Thread Tools Display Modes
Beaverboys
Member
Join Date: Aug 2012
Old 05-19-2015 , 18:20   Re: Using SDKHook_Touch with grenades?
Reply With Quote #11

Quote:
Originally Posted by Miu View Post
Your code works fine for me. Does Sticky Nades Lite not work for you either?
I just tested with bots and it worked correctly. Previously I had been testing by throwing the grenade at myself. Do you know how I could get it to sense when I hit myself with a grenade as well?
Beaverboys is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 05-19-2015 , 18:52   Re: Using SDKHook_Touch with grenades?
Reply With Quote #12

Um, I'd guess it's hard-coded to ignore the thrower. Perhaps it has some owner/thrower property that you can change? If all else fails, you can always just compare the nades position with the client manually.
Miu is offline
Mehis
Senior Member
Join Date: Mar 2013
Location: basement
Old 05-20-2015 , 11:51   Re: Using SDKHook_Touch with grenades?
Reply With Quote #13

It's because the grenade thrower is the projectile's owner, at least that's the case in CSS. In Source owner entity doesn't collide with its child entity. I didn't know it never fired touch, tho.
Mehis is offline
Internet Bully
Member
Join Date: Apr 2014
Old 05-20-2015 , 16:30   Re: Using SDKHook_Touch with grenades?
Reply With Quote #14

You might be able to check for hp/armor decrements of 1 using OnDamageTake and then check the weapon/source (hegrenade_projectile?) or damagetype (DMG_CLUB (1 << 7)) to see if it was a nade bouncing on you.
__________________
Buy me a beer
or donate to Sourcemod
Taking some private plugin requests

Last edited by Internet Bully; 05-20-2015 at 16:55.
Internet Bully is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 05-20-2015 , 17:47   Re: Using SDKHook_Touch with grenades?
Reply With Quote #15

Quote:
Originally Posted by Beaverboys View Post
I'm trying to use SDKHook_Touch to sense when a hegrenade_projectile touches a player but I can't get it to work. This is basically what my code looks like:

PHP Code:
public OnEntityCreated(entity, const String:classname[])
{
    if(!
strcmp(classname"hegrenade_projectile"false))
    {
        new 
iReference EntIndexToEntRef(entity);
        
CreateTimer(0.0OnGrenadeCreatediReference);
    }
}

public 
Action:OnGrenadeCreated(Handle:timerany:ref)
{
    new 
entity EntRefToEntIndex(ref);
    if(
entity != INVALID_ENT_REFERENCE)
        
SetEntProp(entityProp_Data"m_nNextThinkTick", -1); // prevent the grenade from exploding
    
SDKHook(entity,SDKHook_Touch,GrenadeTouch);
}

public 
GrenadeTouch(entity,other)
{
    if (
<= other <= MaxClients// grenade touches a player
    
{
        
// Do stuff ...
    
}

Try RequestFrame
__________________
Chdata is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 05-22-2015 , 16:11   Re: Using SDKHook_Touch with grenades?
Reply With Quote #16

if the grenade makes a bouncing sound when it hits yourself then hook all the bounce sounds and use that as your touch.
blodia is offline
Reply


Thread Tools
Display Modes

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 18:09.


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