AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menu Problem (https://forums.alliedmods.net/showthread.php?t=132067)

mysticssjgoku4 07-11-2010 13:49

Menu Problem
 
For some reason all numbers returns fine for LineData, but on the second page, which would be labeled "Number 10" and every line above that are blank. The var LineText is also blank for 10+. Wth?
So my menus looks like

Quote:

NS Achievements 1/7

1. Number 1
2. Number 2
3. Number 3
4. Number 4
5. Number 5
6. Number 6
7. Number 7

#.Back
9.More
0.Exit
Quote:

NS Achievements 2/7

1. Number 8
2. Number 9
3.
4.
5.
6.
7.

8.Back
9.More
0.Exit
Quote:

NS Achievements 3/7

1.
2.
3.
4.
5.
6.
7.

8.Back
9.More
0.Exit
Code:
public help_menu(id,page) {     new title[24];     formatex(title,sizeof(title),"NS Achievements - v%s -",VERSION);             new menu = menu_create(title, "menu_a_main_handler");         for(new i=1; i<=45;i++)     {         new line_text[16];         formatex(line_text,sizeof(line_text),"Number %i",i);                 new line_data[2];         formatex(line_data,sizeof(line_data),"%i",i);                 menu_additem(menu, line_text, line_data);     }     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);     menu_display(id, menu, page); } public menu_a_main_handler(id, menu, item) {     if(item == MENU_EXIT)     {         menu_destroy(menu);         return PLUGIN_HANDLED;     }     new LineText[32],LineData[32], access, callback;     menu_item_getinfo(menu, item, access, LineData, sizeof(LineData), LineText, sizeof(LineText), callback);             client_print(id,print_chat,"Menu: title(%s) data(%s) callback(%d) access(%d)",LineText,LineData,callback,access);     menu_destroy(menu);         return PLUGIN_HANDLED; }

mysticssjgoku4 07-11-2010 15:09

Re: Menu Problem
 
I tried moving the variables outside the loop, didn't help at all.
Then I tried switching from formatex to format, didn't help.
For some reason... sizeof(x) in a loop as in the code above creates an issue. Perhaps a bug?

This works for both line_text and line_data.
Code:
    new line_text[16], line_data[2];     for(new i=1; i<=45;i++)     {         format(line_text,15,"Number %i",i);         format(line_data,1,"%i",i);

This only works for line_data, while line_text is blank.
Code:
    new line_text[16], line_data[2];     for(new i=1; i<=45;i++)     {         format(line_text,sizeof(line_text),"Number %i",i);         format(line_data,sizeof(line_data),"%i",i);

fysiks 07-11-2010 16:30

Re: Menu Problem
 
btw, it should be sizeof() - 1

mysticssjgoku4 07-11-2010 22:27

Re: Menu Problem
 
Quote:

Originally Posted by fysiks (Post 1235764)
btw, it should be sizeof() - 1

Maybe that's why I had an issue.
Anyone know how to make a menu without an items in it with the newer menu system? It wont show up unless I have an item added to it, but I only want text, a back button for main menu, and exit button.

fysiks 07-11-2010 23:35

Re: Menu Problem
 
Look in newmenus.inc, your answer is there.

mysticssjgoku4 07-12-2010 01:20

Re: Menu Problem
 
Quote:

Originally Posted by fysiks (Post 1236259)
Look in newmenus.inc, your answer is there.

How original. I've studied it for hours, I have the exit button, just can't figure out how to have a custom button back button at the bottom that allows you go to a specific function.
Also wont let me show the menu without having options. What is the point of this new menu if I can't have a fully dynamic approach to everything? Perhaps it just was overlooked when they created it.

ConnorMcLeod 07-12-2010 01:36

Re: Menu Problem
 
Just a little thing :

formatex(line_data,sizeof(line_data),"%i",i);

->

num_to_str(i, line_data, charsmax(line_data))

mysticssjgoku4 07-12-2010 02:04

Re: Menu Problem
 
Quote:

Originally Posted by ConnorMcLeod (Post 1236327)
Just a little thing :

formatex(line_data,sizeof(line_data),"%i",i);

->

num_to_str(i, line_data, charsmax(line_data))

Until I see proof num_to_str performs better I prefer formatex. Thank you.

drekes 07-12-2010 03:03

Re: Menu Problem
 
Quote:

Originally Posted by mysticssjgoku4 (Post 1236334)
Until I see proof num_to_str performs better I prefer formatex. Thank you.

If connor says it, that's proof enough for me

mysticssjgoku4 07-12-2010 05:24

Re: Menu Problem
 
Proof > Opinion
Don't care who it is.


All times are GMT -4. The time now is 07:08.

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