AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Entity touch (https://forums.alliedmods.net/showthread.php?t=287811)

Rirre 09-15-2016 15:53

Entity touch
 
I have created a zone (a cube/box) on fun_allinone map all over the spawn area and fwBoxTouch function do not get triggered by any player touching it.
But as soon all of the env_beam's gets triggered/toggled on (they're inside of this cube), then fwBoxTouch is somehow working as it should.
My questions are:
Why isn't it working without the beams triggering it? And how to get it to work as it should without env_beam entitites has to trigger it to work?

PS. I have to use MOVETYPE_NONE and SOLID_TRIGGER since it's supposed to act like a trigger_multiple entity.
Since the doors are within the cube as well.
I have figured out if any other value beside of MOVETYPE_NONE, when one of the doors gets triggered, it will kill/move the box away from it's position.
I have taken a look at the env_beam's keys and keyvalues to try figuring out what's triggering it to work, my guess was pev->dmg, but set_pev(entity, pev_dmg, <any value here>) did not work. So, I'm out of ideas.

Code:
public plugin_init() register_touch("box", "player", "fwBoxTouch") public fwBoxTouch(zone, player) {     if (!pev_valid(zone))         return FMRES_IGNORED     server_print("Test")     return FMRES_IGNORED } public CreateZone(Float:position[3], Float:mins[3], Float:maxs[3]) {     new entity = create_entity("info_target")     set_pev(entity, pev_classname, "box")     DispatchSpawn(entity)     engfunc(EngFunc_SetModel, entity, "models/gib_skull.mdl")     set_pev(entity, pev_solid, SOLID_TRIGGER)     set_pev(entity, pev_movetype, MOVETYPE_NONE)     set_pev(entity, pev_effects, EF_NODRAW)     engfunc(EngFunc_SetOrigin, entity, position)     engfunc(EngFunc_SetSize, entity, mins, maxs)     return entity }

PRoSToTeM@ 09-15-2016 18:01

Re: Entity touch
 
Replace:
PHP Code:

set_pev(entitypev_originposition

to:
PHP Code:

engfunc(EngFunc_SetOriginentityposition

This updates entity origin for the physics engine. (re-links entity)

Another way you can move:
PHP Code:

set_pev(entitypev_originposition

Before:
PHP Code:

engfunc(EngFunc_SetSizeentityminsmaxs

Because SetSize also re-links entity.

Rirre 09-16-2016 00:21

Re: Entity touch
 
That won't fix it. But it's replaced now.

Depresie 09-16-2016 06:33

Re: Entity touch
 
Question, what build of amx do you use ?

PRoSToTeM@ 09-16-2016 07:10

Re: Entity touch
 
This code works for me:
PHP Code:

#include <amxmodx>
#include <engine>
#include <fakemeta>

public plugin_precache() precache_model("models/gib_skull.mdl");

public 
plugin_init() register_touch("box""player""fwBoxTouch"), register_clcmd("say /smth""Smth");

public 
Smth(clientEntIndex) {
    new 
Float:origin[3];
    
pev(clientEntIndexpev_originorigin);
    
CreateZone(originFloat:{-16.0, -16.0, -16.0}, Float:{16.016.016.0});
}

public 
fwBoxTouch(zoneplayer)
{
    if (!
pev_valid(zone))
        return 
FMRES_IGNORED

    server_print
("Test")

    return 
FMRES_IGNORED
}

public 
CreateZone(Float:position[3], Float:mins[3], Float:maxs[3])
{
    new 
entity create_entity("info_target")
    
set_pev(entitypev_classname"box")

    
DispatchSpawn(entity)

    
engfunc(EngFunc_SetModelentity"models/gib_skull.mdl")

    
set_pev(entitypev_solidSOLID_TRIGGER)
    
set_pev(entitypev_movetypeMOVETYPE_NONE)
    
set_pev(entitypev_effectsEF_NODRAW)

    
engfunc(EngFunc_SetOriginentityposition)
    
engfunc(EngFunc_SetSizeentityminsmaxs)

    return 
entity




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

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