AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Invalid menu id (https://forums.alliedmods.net/showthread.php?t=74241)

atomen 07-14-2008 16:00

Invalid menu id
 
Hi !

I got errors with my plugins, and it's invalid menu id.
I can't find any information about the error.

I guess it's because its wrong id "selected". For example you want
to show a menu, the id is 3 but for some reason 'menu_display' sends id 0.

So I want to know exactly how to fix the error, or what's making it and
what the error means. I'm sure it's different from plugin to plugin.

But just a definiton of it and what's creating it. If I need to post my
script and show just ask.
Quote:

Invalid menu id 0(3)
[AMXX] Run time error 10: native error (native "menu_display")
[AMXX] [0] menus.inl::cpm_menu (line 126)
[AMXX] [1] menus.inl::point_handler (line 94)

atomen 07-15-2008 06:34

Re: Invalid menu id
 
I'll post the code to make it clearer :
Code:
public cpm_menu(id) {     if(TotalModels > 0)     {         if(fm_get_user_team(id) == CS_TEAM_CT)             menu_display(id, menu_id_model_ct, 0);         else if(fm_get_user_team(id) == CS_TEAM_T)             menu_display(id, menu_id_model_t, 0); // This is where the error is     }     return 1; }
Code:
public point_handler(id, menu, item) {     if(item == MENU_EXIT)     {         menu_destroy(menu);         return 1;     }     new data[6], name[64];     new access, callback;     menu_item_getinfo(menu, item, access, data, 5, name, 63, callback);     new key = str_to_num(data);     switch(key)     {         case 1: show_points(id);         case 2: db_handle(id);         case 3:         {             if(!get_status(id, 1))                 vip_handle(id);             else if(get_status(id, 1))                 vip_menu(id);         }         case 4: cpm_menu(id); // This is where the second error is         case 5:         {             if(!get_status(id, 3))                 mr_handle(id);             else if(get_status(id, 3))                 mr_menu(id);         }         case 6:         {             if(!get_status(id, 4))                 vmr_handle(id);             if(get_status(id, 4))                 vmr_menu(id);         }         case 7: sam_handle(id);         case 8: cm_handle(id);     }     menu_destroy(menu);     return 1; }

jim_yang 07-15-2008 09:56

Re: Invalid menu id
 
did you destroy the menu_id_model_t ?

atomen 07-15-2008 10:29

Re: Invalid menu id
 
The menu works the first time, but if I try to use it again the menu locks and the error occurs even if I choose menu option 0 (exit).
Code:
  public cpm_models(id, menu, item) {     if(item == MENU_EXIT || !is_user_connected(id))     {         menu_destroy(menu); // Here         return 1;     }     new model_name[41];     new access, callback;     menu_item_getinfo(menu, item, access, model_name, 40, "", 0, callback);     log_ps("Model Name : %s", model_name);     cpm_handle(id, model_name);     menu_destroy(menu); // Here     return 1; }

jim_yang 07-15-2008 21:30

Re: Invalid menu id
 
I don't know where you created your model menu, but it seems they are created at plugin start. I assume menu_id_model_t is a global variable
when you destroy the menu, menu_id gone. which means you need to create the menu again when you need it.
So if the model menu is global (static), do not destroy it

atomen 07-16-2008 04:41

Re: Invalid menu id
 
It's ok, I got help from Emp and fixed the menu.
I fixed it the same way as you posted.

I created the menu non-global.


All times are GMT -4. The time now is 05:36.

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