Raised This Month: $ Target: $400
 0% 

Reduce code on switch case


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 04-22-2016 , 13:17   Reduce code on switch case
Reply With Quote #1

PHP Code:
public Menu_1_Handler(idMenuitem)
{
    switch(
item)
    {
        ...

        case 
20:
        {
            
Menu_2(id)
            
client_cmd(id"messagemode Test")
            
g_Test[id] = false
        
}
        case 
21:
        {
            
Menu_2(id)
            
client_cmd(id"messagemode Test")
            
g_Test[id] = false
            g_Test2
[id] = true
        
}
        case 
MENU_EXITMenu_0(id)
    }

    
menu_destroy(Menu)

Is there any way i can achieve this whiout having to repeat:
PHP Code:
Menu_2(id)
client_cmd(id"messagemode Test")
g_Test[id] = false 
on both cases?


I know i can do this:
PHP Code:
case 2021
But "case 21" have "g_Test2[id] = true" and "case 20" doesnt.

Last edited by Syturi0; 04-22-2016 at 13:18.
Syturi0 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 04-22-2016 , 13:37   Re: Reduce code on switch case
Reply With Quote #2

Code:
case 20, 21: ... if ( item == 21 )    g_Test2[id] = true
__________________
Black Rose is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 04-22-2016 , 13:37   Re: Reduce code on switch case
Reply With Quote #3

Quote:
Originally Posted by Black Rose View Post
Code:
case 20, 21: ... if ( item == 21 )    g_Test2[id] = true
Thank you!
Syturi0 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 18:34.


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