AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   double switch (https://forums.alliedmods.net/showthread.php?t=93180)

Dr.G 05-25-2009 11:00

double switch
 
would it be wrong to do this double switch in a touch func.


PHP Code:

register_touch(PLAYERPLAYER"func_touch"

PHP Code:

public func_touch(idother)
{
 if(
get_pcvar_num(p_enable) && is_on_team[id] == is_on_team[other]) 
 {
  
entity_set_int(idEV_INT_solidSOLID_NOT
  
entity_set_int(otherEV_INT_solidSOLID_NOT)
 
  switch(
task_is_running[id]) 
  { 
   case 
0
   { 
    
set_task(0.2"btn"id
    
task_is_running[id] = 
   
}
  }
  switch(
task_is_running[other]) 
  { 
   case 
0
   { 
    
set_task(0.2"btn"other
    
task_is_running[other] = 
   

  } 
 }


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_enableis_on_team[33], task_is_running[33]
////////////////////////////////////////////////////////////////////////////////////////////////////
public plugin_init() 
{
 
register_plugin(PVA
 
register_cvar("dod_nsm_stats"VFCVAR_SERVER|FCVAR_SPONLY)
 
 
p_enable register_cvar("dod_nsm","1")
 
 
register_touch(PLAYERPLAYER"func_touch"
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public dod_client_changeteam(idteamoldteam

 
is_on_team[id] = team 
 
 
if(is_on_team[id] == 3
  
is_on_team[id] = 
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public func_touch(idother)
{
 if(
get_pcvar_num(p_enable) && is_on_team[id] == is_on_team[other]) 
 {
  
entity_set_int(idEV_INT_solidSOLID_NOT
  
entity_set_int(otherEV_INT_solidSOLID_NOT)
 
  switch(
task_is_running[id]) 
  { 
   case 
0
   { 
    
set_task(0.2"btn"id
    
task_is_running[id] = 
   
}
  }
  switch(
task_is_running[other]) 
  { 
   case 
0
   { 
    
set_task(0.2"btn"other
    
task_is_running[other] = 
   

  } 
 }
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public btn(id

 
task_is_running[id] = 
 entity_set_int
(idEV_INT_solidSOLID_BBOX)
 
/*
 new name[32]
 get_user_name(id, name, 31)
 client_print(0, 3, "--> %s is solid", name)
 */
}
//////////////////////////////////////////////////////////////////////////////////////////////////// 


Bugsy 05-25-2009 11:09

Re: double switch
 
Why use a switch when only checking for a single value of 0?

PHP Code:

public func_touch(idother)
{
    if(
get_pcvar_num(p_enable) && is_on_team[id] == is_on_team[other]) 
    {
        
entity_set_int(idEV_INT_solidSOLID_NOT
        
entity_set_int(otherEV_INT_solidSOLID_NOT)
    
        if ( !
task_is_running[id] ) 
        { 
            
set_task(0.2"btn"id
            
task_is_running[id] = 
        
}
        
        if ( !
task_is_running[other] ) 
        { 
            
set_task(0.2"btn"other
            
task_is_running[other] = 
        

    }



Dr.G 05-25-2009 11:23

Re: double switch
 
maybe cuz my drinking this weekend went a bit out of control :)

Bugsy 05-25-2009 11:37

Re: double switch
 
Even if you needed to I don't see it being an issue using multiple switches.

Dr.G 05-25-2009 12:30

Re: double switch
 
thanks bugsy


All times are GMT -4. The time now is 01:30.

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