AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] switch statement (https://forums.alliedmods.net/showthread.php?t=173722)

avril-lavigne 12-09-2011 13:55

[HELP] switch statement
 
please , how to use switch from 1 to 7 like 1,2,3,4,5,6,7
I know it should .. by default... but whan I use switch(1,7) or (1-7)
it doesnt work. most time it uses last number and repeat it *(7)

here I need to start each case from 1 to 7 every 12 secs

case 1 = 12 sec, than case 2 after next 12 sec
so when I use random_num it works like random..... but I need 1,2,3,4,5,6,7 in a row

PHP Code:

set_task(12.0,"start_task",_,_,_,"b")
       
}
public 
start_task() {  
              
         switch(
random_num(1,7))  
       {                                                       
           case 
1server_cmd("sq_server ^"123123123123^""
           case 
2server_cmd("sq_server ^"123123123123^"")  
           case 
3:server_cmd("sq_server ^"123123123123^"")                             
           case 
4:server_cmd("sq_server ^"123123123123^"")   
           case 
5:server_cmd("sq_server ^"123123123123^""
           case 
6:server_cmd("sq_server ^"123123123123^""
           case 
7:server_cmd("sq_server ^"123123123123^"")
      }      
    



Kidev 12-09-2011 14:11

Re: [HELP] switch statement
 
Use a static variable and increment it each times the function is called. And if the variables is equal to 7, then put it to 0, and etc...

avril-lavigne 12-09-2011 14:14

Re: [HELP] switch statement
 
new "a" = what?

set "a" to 2 in case 1 and set it to 3 in case2??

Kidev 12-09-2011 14:32

Re: [HELP] switch statement
 
PHP Code:

set_task12.0"repeatItBaby"___"b" );

public 
repeatItBaby( )
{
    static 
myVar;
    
myVar = ( myVar >= myVar );
    switch ( 
myVar )
    {
        case 
1:
        case 
2:
        
/* .. */
    
}



avril-lavigne 12-09-2011 16:05

Re: [HELP] switch statement
 
cant compile ,,, and need more .. after 7 --- start from 1 again

Erox902 12-09-2011 16:30

Re: [HELP] switch statement
 
PHP Code:

case .. 7server_cmd("sq_server ^"123123123123^""

Edit
Sorry read first line and posted, read the next, now I'm not sure this will help anyway :?

avril-lavigne 12-09-2011 16:30

Re: [HELP] switch statement
 
thanks I solved it . in another way ...


All times are GMT -4. The time now is 11:45.

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