AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Custom entities (https://forums.alliedmods.net/showthread.php?t=155527)

bibu 04-23-2011 09:55

Custom entities
 
I have in a map a trigger entity called "info_open". So I wanted to hook the touch like this:

PHP Code:

register_touch("info_open""player""Forward_InfoTouch"

PHP Code:

public Forward_InfoTouch(iEntityid)
{
    if(
IsUserAlive(id))
    {
        
#if defined DEBUG
        
client_print(idprint_chat"%s Debug: Info entity touch."PLUGIN)
        
#endif
    
}


And yes, I am alive and the size of the entity is enough big.

SonicSonedit 04-23-2011 10:45

Re: Custom entities
 
Quote:

I have in a map a trigger entity called "info_open". So I wanted to hook the touch like this:
Did you spawn it manually via AMXX or did you place it on a map in hammer editor?

bibu 04-23-2011 10:47

Re: Custom entities
 
Quote:

Originally Posted by SonicSonedit (Post 1456064)
did you place it on a map in hammer editor?

Exactly. When I open it with BSP Viewer, the entitiy is successfully spawned.

Arkshine 04-23-2011 10:50

Re: Custom entities
 
register_touch should work. So, I can guess only either IsUserAlive is wrong, or you don't touch your entity (meaning, touch not detected or size problem)

SonicSonedit 04-23-2011 11:05

Re: Custom entities
 
Arkshine is right.
Anyway, try this
PHP Code:

 public Forward_InfoTouch(iEntityid)
        
client_print(0print_chat"%s Debug: Info entity touch - Entity: %d, id: %d "PLUGINiEntityid

and see what happens.

tuty 04-23-2011 15:30

Re: Custom entities
 
i tried sometime with trigger entities, but seems engine won't detect trigger entities on toucn for example

PHP Code:

register_touch"trigger_hurt""player""dsadas" 


xPaw 04-23-2011 16:19

Re: Custom entities
 
Quote:

Originally Posted by tuty (Post 1456226)
i tried sometime with trigger entities, but seems engine won't detect trigger entities on toucn for example

PHP Code:

register_touch"trigger_hurt""player""dsadas" 


Touching triggers work fine.

ConnorMcLeod 04-23-2011 16:19

Re: Custom entities
 
How can the engine create a "info_open" entity ?

xPaw 04-23-2011 16:22

Re: Custom entities
 
Quote:

Originally Posted by ConnorMcLeod (Post 1456252)
How can the engine create a "info_open" entity ?

They can exist on map, but engine deletes them upon loading because they are not valid. You have to hook it in pfn_keyvalue, and check "classname", and then create new entity with something like info_target, and then setting pev_classname.

bibu 04-23-2011 16:33

Re: Custom entities
 
Quote:

Originally Posted by xPaw (Post 1456256)
They can exist on map, but engine deletes them upon loading because they are not valid. You have to hook it in pfn_keyvalue, and check "classname", and then create new entity with something like info_target, and then setting pev_classname.

Exactly, that's why it doesn't work then. Could you help me more with that?


All times are GMT -4. The time now is 19:45.

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