Raised This Month: $ Target: $400
 0% 

Menu code gets a warning?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 12-11-2006 , 16:21   Menu code gets a warning?
Reply With Quote #1

Hey everyone, I'm trying to make a menu (I yanked alot of this menu code from another post). My problem is when I compile it gives me a warning.

Here is the warning it gives me...
Quote:
(1113) : warning 203: symbol is never used: "mainMenu"
I don't even have 1113 lines of code!

Here is all the code I use for the menu...
Code:
public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_clcmd("say /menu", "mainMenu");     register_menucmd(register_menuid("menu_mainMenu"), 1023, "menuAction_mainMenu"); } mainMenu(id) {     if(access(id, ADMIN_BAN)) {         new szMenuBody[256];         new key = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9;                 new nLen = format(szMenuBody, 255, "\yMain Menu:^n");                 nLen += format(szMenuBody[nLen], 255-nLen, "^n\w1. Add Start Timer");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w2. Add End Timer");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w3. Remove Start Timer");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w4. Remove End Timer");         nLen += format(szMenuBody[nLen], 255-nLen, "^n^n\w5. Save Position");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w6. Load Position");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w7. Cancel Timed Run");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w8. Give Quad");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w9. Give God");                 nLen += format(szMenuBody[nLen], 255-nLen, "^n^n\w0. Exit");                 show_menu(id, key, menu, -1, "menu_mainMenu");     } else {         new szMenuBody[256];         new key = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5;                 new nLen = format(szMenuBody, 255, "\yMain Menu:^n");                 nLen += format(szMenuBody[nLen], 255-nLen, "^n\w1. Save Position");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w2. Load Position");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w3. Cancel Timed Run");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w4. Give Quad");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w5. Give God");                 nLen += format(szMenuBody[nLen], 255-nLen, "^n^n\w0. Exit");                 show_menu(id, key, menu, -1, "menu_mainMenu");     }         return PLUGIN_HANDLED; } public menuCommand(id, key) {     if(access(id, ADMIN_BAN)) {         switch(key) {             case 0: {                 setStart(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 1: {                 setEnd(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 2: {                 removeStart(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 3: {                 removeEnd(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 4: {                 savePosition(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 5: {                 loadPosition(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 6: {                 cancelTimer(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 7: {                 giveQuad(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 8: {                 set_user_godmode(id, 1);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }         }     } else {         switch(key) {             case 0: {                 savePosition(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 1: {                 loadPosition(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 2: {                 cancelTimer(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 3: {                 giveQuad(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 4: {                 set_user_godmode(id, 1);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }         }     } }

If anyone can help me fix this please do !
hlstriker is offline
dutchmeat
Senior Member
Join Date: Sep 2006
Old 12-11-2006 , 16:25   Re: Menu code gets a warning?
Reply With Quote #2

Code:
mainMenu(id) {



should be:

Code:
public mainMenu(id) {




__________________
before you criticize someone, you should walk a mile in their shoes. that way, when you criticize them, you're a mile away and you have their shoes.

Last edited by dutchmeat; 12-11-2006 at 16:28.
dutchmeat is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 12-11-2006 , 16:48   Re: Menu code gets a warning?
Reply With Quote #3

Wow I feel extremely stupid for not catching that! Anyhow, now that is fixed, I get errors.

Here are the errors...
Quote:
(990) : error 017: undefined symbol "menu"
(1005) : error 017: undefined symbol "menu"
I know it's the variable menu that doesn't exist, but I don't know what to do in place of it. I tried putting "szMenuBody", it compiled fine, but in the game it didn't work.

BTW, here is the code where the errors are, I will comment the error lines.
Code:
public mainMenu(id) {     if(access(id, ADMIN_BAN)) {         new szMenuBody[256];         new key = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9;                 new nLen = format(szMenuBody, 255, "\yMain Menu:^n");                 nLen += format(szMenuBody[nLen], 255-nLen, "^n\w1. Add Start Timer");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w2. Add End Timer");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w3. Remove Start Timer");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w4. Remove End Timer");         nLen += format(szMenuBody[nLen], 255-nLen, "^n^n\w5. Save Position");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w6. Load Position");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w7. Cancel Timed Run");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w8. Give Quad");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w9. Give God");                 nLen += format(szMenuBody[nLen], 255-nLen, "^n^n\w0. Exit");                 show_menu(id, key, menu, -1, "menu_mainMenu"); // ERROR     } else {         new szMenuBody[256];         new key = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5;                 new nLen = format(szMenuBody, 255, "\yMain Menu:^n");                 nLen += format(szMenuBody[nLen], 255-nLen, "^n\w1. Save Position");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w2. Load Position");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w3. Cancel Timed Run");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w4. Give Quad");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w5. Give God");                 nLen += format(szMenuBody[nLen], 255-nLen, "^n^n\w0. Exit");                 show_menu(id, key, menu, -1, "menu_mainMenu"); //ERROR     }         return PLUGIN_HANDLED; }
hlstriker is offline
dutchmeat
Senior Member
Join Date: Sep 2006
Old 12-11-2006 , 16:58   Re: Menu code gets a warning?
Reply With Quote #4

Try this:
make sure you got the menuid right

Code:
public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_clcmd("say /menu", "mainMenu");     register_menucmd(register_menuid("\yMain Menu: "), 1023, "MenuCommand"); menuCommand } public mainMenu(id) {     if(access(id, ADMIN_BAN)) {         new szMenuBody[256];         new key = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9;                 new nLen = format(szMenuBody, 255, "\yMain Menu: ");                 nLen += format(szMenuBody[nLen], 255-nLen, "^n\w1. Add Start Timer");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w2. Add End Timer");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w3. Remove Start Timer");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w4. Remove End Timer");         nLen += format(szMenuBody[nLen], 255-nLen, "^n^n\w5. Save Position");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w6. Load Position");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w7. Cancel Timed Run");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w8. Give Quad");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w9. Give God");                 nLen += format(szMenuBody[nLen], 255-nLen, "^n^n\w0. Exit");                 show_menu(id, key, szMenuBody, -1, "menu_mainMenu");     } else {         new szMenuBody[256];         new key = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5;                 new nLen = format(szMenuBody, 255, "\yMain Menu:^n");                 nLen += format(szMenuBody[nLen], 255-nLen, "^n\w1. Save Position");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w2. Load Position");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w3. Cancel Timed Run");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w4. Give Quad");         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w5. Give God");                 nLen += format(szMenuBody[nLen], 255-nLen, "^n^n\w0. Exit");                 show_menu(id, key, szMenuBody, -1,);     }         return PLUGIN_HANDLED; } public menuCommand(id, key) {     if(access(id, ADMIN_BAN)) {         switch(key) {             case 0: {                 setStart(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 1: {                 setEnd(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 2: {                 removeStart(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 3: {                 removeEnd(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 4: {                 savePosition(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 5: {                 loadPosition(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 6: {                 cancelTimer(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 7: {                 giveQuad(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 8: {                 set_user_godmode(id, 1);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }         }     } else {         switch(key) {             case 0: {                 savePosition(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 1: {                 loadPosition(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 2: {                 cancelTimer(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 3: {                 giveQuad(id);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }             case 4: {                 set_user_godmode(id, 1);                 client_cmd(id, "speak ^"csm/menuselect.wav^"");                 }         }     } }
__________________
before you criticize someone, you should walk a mile in their shoes. that way, when you criticize them, you're a mile away and you have their shoes.
dutchmeat is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 12-11-2006 , 17:27   Re: Menu code gets a warning?
Reply With Quote #5

I tried that and still none of the menu numbers will work. The menu shows up, but none of the numbers will do anything.
hlstriker is offline
dutchmeat
Senior Member
Join Date: Sep 2006
Old 12-11-2006 , 17:51   Re: Menu code gets a warning?
Reply With Quote #6

then post the whole plugin
__________________
before you criticize someone, you should walk a mile in their shoes. that way, when you criticize them, you're a mile away and you have their shoes.
dutchmeat is offline
schnitzelmaker
Senior Member
Join Date: Apr 2006
Location: HERE
Old 12-11-2006 , 18:00   Re: Menu code gets a warning?
Reply With Quote #7

3 things:

1:remove/change
Code:
new nLen = format(szMenuBody, 255, "\yMain Menu:^n");
to
Code:
new nLen = format(szMenuBody, 255, "Main Menu: ^n");

2:change "\yMain Menu: " to "Main Menu: ",i thing he dont can get menuid by special chars.

3:as i know are quotes not needed
Code:
client_cmd(id, "speak ^"csm/menuselect.wav^"");
->
Code:
client_cmd(id, "speak csm/menuselect.wav");

At last test the menu by using a client_print message:client_print(id,print_chat,"you have pressed key %d",key)
__________________
schnitzelmaker is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 12-11-2006 , 18:13   Re: Menu code gets a warning?
Reply With Quote #8

Things I would change: (in boldface)

Code:
public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR);
    register_clcmd("say /menu", "mainMenu");
    register_menucmd(register_menuid("\yMain Menu: "), 1023, "MenuCommand");
menuCommand
}
public mainMenu(id) {
    if(access(id, ADMIN_BAN)) {
        new szMenuBody[256];
        new key = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9;
        
        new nLen = format(szMenuBody, 255, "\yMain Menu: ");
        
        nLen += format(szMenuBody[nLen], 255-nLen, "^n\w1. Add Start Timer");
        nLen += format(szMenuBody[nLen], 255-nLen, "^n\w2. Add End Timer");
        nLen += format(szMenuBody[nLen], 255-nLen, "^n\w3. Remove Start Timer");
        nLen += format(szMenuBody[nLen], 255-nLen, "^n\w4. Remove End Timer");
        nLen += format(szMenuBody[nLen], 255-nLen, "^n^n\w5. Save Position");
        nLen += format(szMenuBody[nLen], 255-nLen, "^n\w6. Load Position");
        nLen += format(szMenuBody[nLen], 255-nLen, "^n\w7. Cancel Timed Run");
        nLen += format(szMenuBody[nLen], 255-nLen, "^n\w8. Give Quad");
        nLen += format(szMenuBody[nLen], 255-nLen, "^n\w9. Give God");
        
        nLen += format(szMenuBody[nLen], 255-nLen, "^n^n\w0. Exit");
        
        show_menu(id, key, szMenuBody, -1, "menu_mainMenu");
    } else {
        new szMenuBody[256];
        new key = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5;
        
        new nLen = format(szMenuBody, 255, "\yMain Menu:^n");
        
        nLen += format(szMenuBody[nLen], 255-nLen, "^n\w1. Save Position");
        nLen += format(szMenuBody[nLen], 255-nLen, "^n\w2. Load Position");
        nLen += format(szMenuBody[nLen], 255-nLen, "^n\w3. Cancel Timed Run");
        nLen += format(szMenuBody[nLen], 255-nLen, "^n\w4. Give Quad");
        nLen += format(szMenuBody[nLen], 255-nLen, "^n\w5. Give God");
        
        nLen += format(szMenuBody[nLen], 255-nLen, "^n^n\w0. Exit");
        
        show_menu(id, key, szMenuBody, -1,);
    }
    
    return PLUGIN_HANDLED;
}
1. Remove menuCommand
2. Remove "menu_mainMenu"
3. Remove ,
stupok 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 06:49.


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