AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Compile Error/Code Help (https://forums.alliedmods.net/showthread.php?t=163142)

Killer12201 07-27-2011 05:45

Compile Error/Code Help
 
Code:

//// pokerank.sma
// C:\Documents and Settings\owner\Desktop\Servers\Compiler\scripting\poker
ank.sma(125) : error 014: invalid statement; not in switch
// C:\Documents and Settings\owner\Desktop\Servers\Compiler\scripting\poker
ank.sma(125) : warning 215: expression has no effect
// C:\Documents and Settings\owner\Desktop\Servers\Compiler\scripting\poker
ank.sma(125) : error 001: expected token: ";", but found ":"
// C:\Documents and Settings\owner\Desktop\Servers\Compiler\scripting\poker
ank.sma(125) : error 029: invalid expression, assumed zero
// C:\Documents and Settings\owner\Desktop\Servers\Compiler\scripting\poker
ank.sma(125) : fatal error 107: too many error messages on one line

I have spent hours searching through line 125 and all the lines above it to find my error. I would appreciate any help somebody can provide because I'm either too tired to find my mistake or just don't know how to find it. Below is the code down to line 126.

http://pastebin.com/YG5L2sdH

SnoW 07-27-2011 05:51

Re: Compile Error/Code Help
 
Code:
switch(menuselection[id])         {                 case MENU_MAIN:                 {                         case 0: pokerank1(id);                         case 1: pokerank2(id);                         case 2: pokerank3(id);                         case 3: pokerank4(id);
Could you explain what are you exactly doing here? If the menuselection[ id ] is MENU_MAIN( a constant ), how could it be 0, 1, 2, 3 as well? Just that your switch is totally wrong for the syntax it is not really logical at all either.

Killer12201 07-27-2011 06:06

Re: Compile Error/Code Help
 
So what should I change it too? I looked in the BF2 menu section at that point to get help with menu's with sub sections. I'm not very good with menu's and got really confused on that part of it.

Edit: That part was supposed to do with this part. The cases were supposed to be the menu items but I'm assuming I did that wrong.

Code:

public pokemenu(id)
{
    new menu = menu_create("\rPoke Rank \wMenu", "menu_handler");
   
    menu_additem(menu, "\r25k Poke Rank \wMenu", "0", 0);
    menu_additem(menu, "\r50k Poke Rank \wMenu", "1", 0);
    menu_additem(menu, "\r75k Poke Rank \wMenu", "2", 0);
    menu_additem(menu, "\r100k Poke Rank \wMenu", "3", 0);
   
    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
   
    menuselection[id]=MENU_MAIN
   
    menu_display(id, menu, 0);
   
    return PLUGIN_CONTINUE;
}


fysiks 07-27-2011 07:01

Re: Compile Error/Code Help
 
You need to use one switch for each set of cases, like this:

PHP Code:

    switch(menuselection[id])
    {
        case 
MENU_MAIN:
        {
            switch(
key)
            {
                case 
0pokerank1(id);
                case 
1pokerank2(id);
                case 
2pokerank3(id);
                case 
3pokerank4(id);
            }
        }
        case 
MENU_POKE1:
        {
            switch(
key)
            {
                case 
0// function
                
case 1// function2
                // ...
            
}
        }
        
// ...
    



Killer12201 07-27-2011 10:00

Re: Compile Error/Code Help
 
Will that fix my error? I understand what your saying but that is after the lines that my error is in. I still can't figure out what is going on

fysiks 07-27-2011 17:43

Re: Compile Error/Code Help
 
Quote:

Originally Posted by Killer12201 (Post 1519647)
Will that fix my error? I understand what your saying but that is after the lines that my error is in. I still can't figure out what is going on

My post will solve your "not in switch" error. The other are likely trivial.

If you want further help, paste the whole code.


All times are GMT -4. The time now is 00:55.

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