double switch
would it be wrong to do this double switch in a touch func.
PHP Code:
register_touch(PLAYER, PLAYER, "func_touch")
PHP Code:
public func_touch(id, other) { if(get_pcvar_num(p_enable) && is_on_team[id] == is_on_team[other]) { entity_set_int(id, EV_INT_solid, SOLID_NOT) entity_set_int(other, EV_INT_solid, SOLID_NOT) switch(task_is_running[id]) { case 0: { set_task(0.2, "btn", id) task_is_running[id] = 1 } } switch(task_is_running[other]) { case 0: { set_task(0.2, "btn", other) task_is_running[other] = 1 } } } }
or how else to handle it?
This is the full code:
PHP Code:
//////////////////////////////////////////////////////////////////////////////////////////////////// #include <amxmodx> #include <engine> #include <dodx> //////////////////////////////////////////////////////////////////////////////////////////////////// #define P "DoD None Solid Mates" #define V "v1.0 by Dr.G" #define A "AMXX DoD Team" //////////////////////////////////////////////////////////////////////////////////////////////////// new const PLAYER[] = "player" ; new p_enable, is_on_team[33], task_is_running[33] //////////////////////////////////////////////////////////////////////////////////////////////////// public plugin_init() { register_plugin(P, V, A) register_cvar("dod_nsm_stats", V, FCVAR_SERVER|FCVAR_SPONLY) p_enable = register_cvar("dod_nsm","1") register_touch(PLAYER, PLAYER, "func_touch") } //////////////////////////////////////////////////////////////////////////////////////////////////// public dod_client_changeteam(id, team, oldteam) { is_on_team[id] = team if(is_on_team[id] == 3) is_on_team[id] = 0 } //////////////////////////////////////////////////////////////////////////////////////////////////// public func_touch(id, other) { if(get_pcvar_num(p_enable) && is_on_team[id] == is_on_team[other]) { entity_set_int(id, EV_INT_solid, SOLID_NOT) entity_set_int(other, EV_INT_solid, SOLID_NOT) switch(task_is_running[id]) { case 0: { set_task(0.2, "btn", id) task_is_running[id] = 1 } } switch(task_is_running[other]) { case 0: { set_task(0.2, "btn", other) task_is_running[other] = 1 } } } } //////////////////////////////////////////////////////////////////////////////////////////////////// public btn(id) { task_is_running[id] = 0 entity_set_int(id, EV_INT_solid, SOLID_BBOX) /* new name[32] get_user_name(id, name, 31) client_print(0, 3, "--> %s is solid", name) */ } ////////////////////////////////////////////////////////////////////////////////////////////////////
|