View Single Post
ajr1234
Senior Member
Join Date: Mar 2011
Location: Chicago, IL, U.S.A.
Old 02-13-2013 , 20:47   Re: spawn objects
Reply With Quote #12

The hook only affects the entity-- not all entities of the classname. You can still hook other entities of the same class. Also, you can hook more than one entity, i.e.:

PHP Code:
// hook entities to a particular callback
HookSingleEntityOutput(entity1"OnStartTouch"ontouch);
HookSingleEntityOutput(entity2"OnStartTouch"ontouch);
HookSingleEntityOutput(entity3"OnStartTouch"ontouch);
HookSingleEntityOutput(entity4"OnStartTouch"someothercallback);


// let's say some player touches entity1. The following callback is fired
public ontouch(const String:output[], calleractivatorFloat:delay)
{
     if (
IsValidEdict(caller)) RemoveEdict(caller);

     
// hook is removed for the destroyed caller (entity1), but remain for other hooked
     // entities (i.e. entity2 and entity3) that are not destroyed yet.

     // if the player then touches entity2, then entity2 is removed but entity3 is still hooked.
}

// fired for entity4
public someothercallback(const String:output[], calleractivatorFloat:delay)
{
     
// do something

As for your second question, no, you cannot remove the the declarations and data types; otherwise, the data being passed will be assumed to be integers, and that is not the case here.
ajr1234 is offline