AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Player doesn't touch a SOLID_TRIGGER entity (https://forums.alliedmods.net/showthread.php?t=320905)

bLacK-bLooD 01-14-2020 14:56

Player doesn't touch a SOLID_TRIGGER entity
 
Hi, I have an entity (a sprite) and it is setup like this:


PHP Code:

new iEntity create_entity("func_button");
entity_set_int(iEntityEV_INT_solidSOLID_TRIGGER);
entity_set_int(iEntityEV_INT_movetypeMOVETYPE_NONE);
entity_set_model(iEntityg_szTimerSprites[iType]);
entity_set_size(iEntityFloat:{-16.0, -128.00.0}, Float:{16.0128.0128.0}); 

When I try to hook a touch, however, the player never seems to touch the entity. The code for it is:

PHP Code:

register_touch("player","*","hook_touch");
public 
hook_touch(playerentity) {
    new 
classname[32];

    
entity_get_string(entityEV_SZ_classnameclassname31);

    
console_print(player"Class name touched: %s"classname);


I never get my entity touch, even though I walk through it. If I change the EV_INT_solid to SOLID_BBOX, it works just fine.

Any ideas why this is happening?

Thank you!

georgik57 01-14-2020 18:46

Re: Player doesn't touch a SOLID_TRIGGER entity
 
Long shot but try spawning it(dllfunc_spawn). Just a guess but might solve your problem.

Bugsy 01-14-2020 19:16

Re: Player doesn't touch a SOLID_TRIGGER entity
 
Try this:
PHP Code:

new iEntity create_entity("func_button")
    
if( !
iEntity )
    
set_fail_state"Error creating entity" );
    
entity_set_int(iEntityEV_INT_movetypeMOVETYPE_NONE);
entity_set_model(iEntityg_szTimerSprites[iType]);
entity_set_size(iEntityFloat:{-16.0, -128.00.0}, Float:{16.0128.0128.0}); 
dllfuncDLLFunc_Spawn iEntity );
entity_set_int(iEntityEV_INT_solidSOLID_TRIGGER); 


JocAnis 01-14-2020 22:07

Re: Player doesn't touch a SOLID_TRIGGER entity
 
I had been using sprite entity with solid_trigger as you need, but with fakemetas detection for touch:
Code:

public pfn_touch( ent1, id )
{                 
          new classname[ 32 ], name[ 32 ]
          entity_get_string( ent1, EV_SZ_classname, classname, 31 )
                   
          if( equal( classname, "your_ent_classname" ) )
          {

If this matters: i put solid_trigger atribute after all others (like bugsy's example) and it didnt require dllfunc_spawn func calling

fl0werD 01-15-2020 11:00

Re: Player doesn't touch a SOLID_TRIGGER entity
 
Just set not MOVETYPE_NONE.

bLacK-bLooD 01-15-2020 11:49

Re: Player doesn't touch a SOLID_TRIGGER entity
 
Quote:

Originally Posted by JocAnis (Post 2680331)
I had been using sprite entity with solid_trigger as you need, but with fakemetas detection for touch:
Code:

public pfn_touch( ent1, id )
{                 
          new classname[ 32 ], name[ 32 ]
          entity_get_string( ent1, EV_SZ_classname, classname, 31 )
                   
          if( equal( classname, "your_ent_classname" ) )
          {

If this matters: i put solid_trigger atribute after all others (like bugsy's example) and it didnt require dllfunc_spawn func calling

This worked, thank you!

HamletEagle 01-16-2020 04:17

Re: Player doesn't touch a SOLID_TRIGGER entity
 
Detecing touch is the same with both engine and fakemeta so this is not the issue. However you should use engine in order to catch only the touches you need, not all of them.


All times are GMT -4. The time now is 02:50.

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