Raised This Month: $ Target: $400
 0% 

Menu display problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bug
Senior Member
Join Date: Nov 2007
Old 09-12-2009 , 20:23   Menu display problem
Reply With Quote #1

Hello,
I have a menu which displays every alive CT. On my local test server it is working fine, on another server, only the first name in the menu is displayed. First of all, here's the code snippet:
Code:
SubMenu(id)
 {
   new menu = menu_create("\rChoose your opponent:", "submenu_handler");
   
   new iPlayers[32], iNum, playername[32], playerid[2];
   get_players(iPlayers, iNum, "ae", "CT");
   
   if (iNum == 0) {
      client_print(id, print_chat, "[LR] No alive CTs present.");
      menu_destroy(menu);
      return PLUGIN_HANDLED;
   }
   
   for(new i=0;i<iNum;i++) {
      new player=iPlayers[i];
      get_user_name(player, playername, 31);
      num_to_str(player, playerid, 2);
      menu_additem(menu, playername, playerid);
   } 
   
   menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
   menu_display(id, menu, 0);
   return PLUGIN_CONTINUE;
 }
The most important to mention is: The index-IDs are all correct. I work with them later, and there's no problems with it. But the menu displays something like this:

Choose an opponent:
1: Bla123
2:
3:
4:


If you press "3" now, the script continues fine, but you can't see the name, altough you should. So after the first name, the names aren't displayed, and I can't imagine the problem because it is working on a local testserver. What could be wrong on such a procedure?


Maybe the reason is, that the server is really slow/lame, because 6 servers are running on one machine, and the lookup processes via get_user_name takes too long in this loop, so nothing is displayed?!

Last edited by bug; 09-12-2009 at 21:27.
bug is offline
bug
Senior Member
Join Date: Nov 2007
Old 09-12-2009 , 22:47   Re: Menu display problem
Reply With Quote #2

Sorry for the double post, but it seems that it's really the reason that I thought. Now, early in the morning when only less people are playing on the server, this problem doesn't exist.

Shall I make an extra function for:
Code:
      get_user_name(player, playername, 31);
      num_to_str(player, playerid, 2);
      menu_additem(menu, playername, playerid);
Which gets executed via set_task then? Can I use menu_additem for this menu outside this menu-function?

Or shall I only make the get_user_name in an extra function, this function would return the name then, and get's called via set_task?

Last edited by bug; 09-12-2009 at 22:50.
bug is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-12-2009 , 22:48   Re: Menu display problem
Reply With Quote #3

I don't know if this is the problem but it could cause something to go wrong if you have more than 9 slots:

Code:
playerid[2]


Code:
playerid[3]
Oh, and you can move your menu_create() below your iNum check. Then you don't need to destroy it because it will never have been created .
__________________

Last edited by fysiks; 09-12-2009 at 22:50.
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 01:58.


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