Raised This Month: $ Target: $400
 0% 

a simple question / case('X'):


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SpokY
Senior Member
Join Date: Feb 2009
Location: Darmstadt
Old 08-07-2010 , 09:26   a simple question / case('X'):
Reply With Quote #1

Hello,
when i use the case('1'): till case('9'): it works fine to compile but when i use case('8'): till case('12'): he says me en error :

Code:
/groups/amxmodx/tmp3/text43obsz.sma(940) : warning 213: tag mismatch
/groups/amxmodx/tmp3/text43obsz.sma(1743) : error 027: invalid character constant
/groups/amxmodx/tmp3/text43obsz.sma(1743) : warning 215: expression has no effect
/groups/amxmodx/tmp3/text43obsz.sma(1743) : error 001: expected token: ";", but found ":"
/groups/amxmodx/tmp3/text43obsz.sma(1748) : error 014: invalid statement; not in switch
/groups/amxmodx/tmp3/text43obsz.sma(1748) : error 027: invalid character constant
/groups/amxmodx/tmp3/text43obsz.sma(1748) : warning 215: expression has no effect
/groups/amxmodx/tmp3/text43obsz.sma(1748) : error 001: expected token: ";", but found ":"
BUT THIS ERROR IS ONLY WHEN I USE case('8'): till case('12'): why?
How i can fix it?

Thanks a lot !!!
__________________
xtream.eSports Weil's einfach nur Geil ist !
www.xtream-esports.com
SpokY is offline
Send a message via ICQ to SpokY Send a message via MSN to SpokY
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 08-07-2010 , 09:35   Re: a simple question / case('X'):
Reply With Quote #2

Show code, case is not a function, don't place ( and ) after it.

I am assuming you're using switch().
Code:
switch(variable)
{
     case 1: // variable is 1
     case 2..5: // variable is between 2 and 5
     default: // variable is none of above
}
If you use '8' it will be considered 8 as string, use that if you're checking a string.

Code:
new szText[] = "abc123"

switch(szText[0]) // "a"
{
      case 'a': // this will trigger
}

switch(szText[4]) // "2"
{
      case 2: // this won't trigger
      case '2': // this one will trigger
}
__________________
Hunter-Digital is offline
SpokY
Senior Member
Join Date: Feb 2009
Location: Darmstadt
Old 08-07-2010 , 09:42   Re: a simple question / case('X'):
Reply With Quote #3

Thanks for the fast answer but i didnt understand you..
here is a part of the code :

Code:
    formatex(menuname, charsmax(menuname), "%L", LANG_SERVER, "JBE_MENU_LASTREQ")
    menu = menu_create(menuname, "lastrequest_select")

    formatex(option, charsmax(option), "%L", LANG_SERVER, "JBE_MENU_LASTREQ_OPT1")
    menu_additem(menu, option, "1", 0)

    formatex(option, charsmax(option), "%L", LANG_SERVER, "JBE_MENU_LASTREQ_OPT2")
    menu_additem(menu, option, "2", 0)

    formatex(option, charsmax(option), "%L", LANG_SERVER, "JBE_MENU_LASTREQ_OPT3")
    menu_additem(menu, option, "3", 0)

    formatex(option, charsmax(option), "%L", LANG_SERVER, "JBE_MENU_LASTREQ_OPT8")
    menu_additem(menu, option, "8", 0)

    formatex(option, charsmax(option), "%L", LANG_SERVER, "JBE_MENU_LASTREQ_OPT9")
    menu_additem(menu, option, "9", 0)

    formatex(option, charsmax(option), "%L", LANG_SERVER, "JBE_MENU_LASTREQ_OPT10")
    menu_additem(menu, option, "10", 0)

    formatex(option, charsmax(option), "%L", LANG_SERVER, "JBE_MENU_LASTREQ_OPT11")
    menu_additem(menu, option, "11", 0)

    formatex(option, charsmax(option), "%L", LANG_SERVER, "JBE_MENU_LASTREQ_OPT12")
    menu_additem(menu, option, "12", 0)
an here the other part :

Code:
        case('8'):
        {
            formatex(option, charsmax(option), "%L", LANG_SERVER, "JBE_MENU_LASTREQ_SEL8", dst)
            player_hudmessage(0, 6, 3.0, {0, 255, 0}, option)
        }
        case('9'):
        {
            formatex(option, charsmax(option), "%L", LANG_SERVER, "JBE_MENU_LASTREQ_SEL9", dst)
            player_hudmessage(0, 6, 3.0, {0, 255, 0}, option)
        }
        case('10'):
        {
            formatex(option, charsmax(option), "%L", LANG_SERVER, "JBE_MENU_LASTREQ_SEL10", dst)
            player_hudmessage(0, 6, 3.0, {0, 255, 0}, option)
        }
        case('11'):
        {
            formatex(option, charsmax(option), "%L", LANG_SERVER, "JBE_MENU_LASTREQ_SEL11", dst)
            player_hudmessage(0, 6, 3.0, {0, 255, 0}, option)
        }
        case('12'):
        {
            formatex(option, charsmax(option), "%L", LANG_SERVER, "JBE_MENU_LASTREQ_SEL12", dst)
            player_hudmessage(0, 6, 3.0, {0, 255, 0}, option)
        }
__________________
xtream.eSports Weil's einfach nur Geil ist !
www.xtream-esports.com
SpokY is offline
Send a message via ICQ to SpokY Send a message via MSN to SpokY
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 08-07-2010 , 09:48   Re: a simple question / case('X'):
Reply With Quote #4

Pff, what a waste of 5 minutes...

Read my post again, case is not a function and you MUST NOT add ( and ) to it, see my examples.
__________________
Hunter-Digital is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 08-07-2010 , 10:32   Re: a simple question / case('X'):
Reply With Quote #5

That's not the problem, your problem is case '12'.
Case receives a cell value, and '12' is a string with two cells.

Also, ' is used for chars only, you have to use " for strings.
Seta00 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-07-2010 , 13:22   Re: a simple question / case('X'):
Reply With Quote #6

You will need to do it like it is shown in the new menus tutorial.
__________________
fysiks 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 00:17.


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