Raised This Month: $ Target: $400
 0% 

double switch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dr.G
Senior Member
Join Date: Nov 2008
Old 05-25-2009 , 11:00   double switch
Reply With Quote #1

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)
 */
}
//////////////////////////////////////////////////////////////////////////////////////////////////// 
__________________
Dr.G is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-25-2009 , 11:09   Re: double switch
Reply With Quote #2

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] = 
        

    }

__________________
Bugsy is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 05-25-2009 , 11:23   Re: double switch
Reply With Quote #3

maybe cuz my drinking this weekend went a bit out of control :)
__________________
Dr.G is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-25-2009 , 11:37   Re: double switch
Reply With Quote #4

Even if you needed to I don't see it being an issue using multiple switches.
__________________
Bugsy is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 05-25-2009 , 12:30   Re: double switch
Reply With Quote #5

thanks bugsy
__________________
Dr.G is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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