AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Player touches my entity - how to detect? (https://forums.alliedmods.net/showthread.php?t=100788)

Sn!ff3r 08-18-2009 00:08

Player touches my entity - how to detect?
 
All right, code:

PHP Code:

public myent(id){
    
    static 
Float:origin[3]
    
pev(idpev_originorigin)
    
    static 
ent
    ent 
engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
    
    if(!
ent)
        return
    
    
set_pev(entpev_classname"myent")
    
    
engfunc(EngFunc_SetModelentMYMODEL)
    
    static 
Float:MinBox[3]
    static 
Float:MaxBox[3]
    for(new 
aa<3a++) {
        
MinBox[a] = -1.0
        MaxBox
[a] = 1.0
    
}
    
engfunc(EngFunc_SetSizeentMinBoxMaxBox)
    
engfunc(EngFunc_SetOriginentorigin)
    
    
set_pev(entpev_solidSOLID_SLIDEBOX)
    
set_pev(entpev_movetypeMOVETYPE_TOSS)
    
set_pev(entpev_ownerid)
    
    static 
Float:global_Time
    global_get
(glb_timeglobal_Time)
    
set_pev(entpev_nextthinkglobal_Time 1.0)


PHP Code:

RegisterHam(Ham_Touch"info_target""touched"1

But not works. I see my entity, but no action when I touch it. Why ?

ConnorMcLeod 08-18-2009 00:23

Re: Player touches my entity - how to detect?
 
register_touch("myent", "player", "YourFunction")


Then you won't have to filter through info_target and through toucher ents.
If nothing is triggered, see your ent properties.


set_pev(ent, pev_owner, id) MAY prevent id from touching it for example.

Hunter-Digital 08-18-2009 00:54

Re: Player touches my entity - how to detect?
 
You also need to spawn the entity for the touch to trigger.

Sn!ff3r 08-18-2009 00:55

Re: Player touches my entity - how to detect?
 
SOLID_SLIDEBOX -> SOLID_TRIGGER solved problem.

Quote:

You also need to spawn the entity for the touch to trigger.
False.


All times are GMT -4. The time now is 15:09.

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