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

Hooking an entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MockingBird
Member
Join Date: Mar 2005
Old 09-30-2009 , 00:29   Hooking an entity
Reply With Quote #1

Hi all..

Im working on a plugin that requires interaction with the map. I want the plugin to be able to hook the entity, and run a function when that entity receives a certain input..

Is there a way to do this firstly without extensions. If not, what extensions do I need? I had a brief look, and the search function has failed me.

Thanks.
MockingBird is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 09-30-2009 , 15:07   Re: Hooking an entity
Reply With Quote #2

http://docs.sourcemod.net/api/index....ad=file&id=51&
AtomicStryker is offline
MockingBird
Member
Join Date: Mar 2005
Old 10-01-2009 , 04:38   Re: Hooking an entity
Reply With Quote #3

Wow, cant believe I missed that lol...

anyway I am now having an issue with the callback not being run.

PHP Code:
HookEntities()
{
    new 
dungbell EntRefToEntIndex(FindEnt("logic_relay""dungbellxp"))
    
HookSingleEntityOutput(dungbell"Trigger"DungBell)
    
PrintToServer("Dungbell: %i"dungbell)
}

FindEnt(const String:classname[], const String:name[])
{
    new 
ent = -1;
    while(
true)
    {
        
ent FindEntityByClassname(entclassname)
        if(
ent == -1) break
        
        new 
String:entName[65]
        
GetEntityTargetName(ententNamesizeof(entName))
        
        if(
StrEqual(entNamename))
        {
            return 
ent;
        }
    }
}

public 
DungBell(const String:output[], calleractivatorFloat:delay)
{
    
PrintToChatAll("DungBell - Activator: %i"activator)
    if(
activator <= MaxPlayers && IsClientInGame(activator))
    {
        
RewardXP(activatorSKILL_STR10)
    }

I receive no error, and the entity hooked is '2064', which I assume is the correct ID.

My map setup:
trigger_multiple is activated, which calls 'Trigger' on a logic_relay called 'dungbellxp' which calls 'Trigger' on a logic_relay called 'XP'.

The last call is to create an output that can be hooked.

Any ideas why it isnt calling?

Thanks in advanced.

Last edited by MockingBird; 10-01-2009 at 04:52.
MockingBird is offline
pRED*
Join Date: Dec 2006
Old 10-01-2009 , 05:31   Re: Hooking an entity
Reply With Quote #4

Trigger is an input, not an output.

http://wiki.alliedmods.net/Category:Game_Resources

Take a look at the datamaps list there for vars labelled as Output.

OnTrigger would probably be what you want (I assume it would be fired when the Trigger input is received)
pRED* is offline
MockingBird
Member
Join Date: Mar 2005
Old 10-01-2009 , 06:43   Re: Hooking an entity
Reply With Quote #5

Ah I see, I was looking at it the wrong way (Trigger is an output from the entity, which is what I was thinking, but an input to the entity its firing at, which is what I should have been thinking xD).

Ill see if that works.

edit:
homg so cool.

thanks pred

Last edited by MockingBird; 10-01-2009 at 06:51.
MockingBird 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 10:46.


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