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

Hooking trigger activating


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 10-18-2013 , 15:05   Hooking trigger activating
Reply With Quote #1

I'm trying to do something like this:
Code:
public Action:OnTrigger(client, entity, const String:classname[])
{
    if(StrEqual(classname, "trigger_multiple") && !HasPartner[client])
    {
        return Plugin_Handled;
    }
    
    return Plugin_Continue;
}
There's any hook for this? I never saw one.

Thanks
__________________
retired
shavit is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-18-2013 , 15:13   Re: Hooking trigger activating
Reply With Quote #2

You need to use HookEntityOutput to hook OnTrigger.

Something like

PHP Code:
public OnPluginStart()
{
    
HookEntityOutput("trigger_multiple""OnTrigger"Trigger_Multiple);
}

public 
Trigger_Multiple(const String:output[], calleractivatorFloat:delay)
{
    
// caller is the trigger_multiple entity index
    // activator is the client index

Alternately, you can use SDKHooks and its StartTouch or Touch hooks.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 10-18-2013 at 15:18.
Powerlord is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 10-18-2013 , 15:16   Re: Hooking trigger activating
Reply With Quote #3

Quote:
Originally Posted by Powerlord View Post
You need to use HookEntityOutput to hook OnTrigger.
HookEntityOutput's functag isn't Action:, so I can't use return Plugin_Handled; to block it from triggering there.

Edit: Saw the update, about SDKHooks, do I need to hook the client or the trigger_multiple?
Edit2: Found it out, thanks for helping

Code:
public OnEntityCreated(entity, const String:classname[])
{
    if(StrEqual(classname, "func_button"))
    {
        SDKHook(entity, SDKHook_Use, OnUseHook);
    }
    
    else if(StrEqual(classname, "trigger_multiple"))
    {
        SDKHook(entity, SDKHook_StartTouch, OnTrigger);
        SDKHook(entity, SDKHook_EndTouch, OnTrigger);
        SDKHook(entity, SDKHook_Touch, OnTrigger);
    }
}

public Action:OnTrigger(entity, other)
{
    if(!HasPartner[other])
    {
        return Plugin_Handled;
    }
    
    return Plugin_Continue;
}
__________________
retired

Last edited by shavit; 10-18-2013 at 15:22.
shavit is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 10-18-2013 , 21:38   Re: Hooking trigger activating
Reply With Quote #4

If you hook strttouch and abort it, it wont happen again until they leave and re touch the triggerr.
Touch will fire every frame... So if you are using this, no point kn also hooking start touch.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-18-2013 , 22:53   Re: Hooking trigger activating
Reply With Quote #5

Yeah, I only use StartTouch to block things like grabbing healthkits for FF2 bosses. Or at least I was going to use it for that.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 10-20-2013 , 00:52   Re: Hooking trigger activating
Reply With Quote #6

Its good to use for items, brushes, buttons, etc where you only need to check if they hit it initialy to trigger something like a teleport, or state change. I use starttouch all the time for hooking models for pickups to generate unique effects also. Endtouch is good for switching bools, so you dont gotta use the costly ontouch.. Since when clients die and such endtouch will fire.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram 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 06:17.


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