The menu doesn't update for every player
Hi I just created a menu with all the players connected and the points each one has got. I created some code so when you have the menu opened, it updates the points each player has, but when more than 1 player opens the menu, it doesn't work for every one.
PHP Code:
|
Re: The menu doesn't update for every player
What is that?! Please look at a tutorial which shows how to make a menu, because your code doesn't make any sense at all. First of all you're creating the menu with a global variable, so every player will recreate it when opened.
|
Re: The menu doesn't update for every player
I created a global variable to call menu in the function "menucreator", to make it update. And please stop being so rude I'm trying to learn l3l
|
Re: The menu doesn't update for every player
Of course you should be able to learn without being talked down to. I see what you wanted to create with the code. And you're not so far away from it being complete.
The thing with updating player menus is that they can change at any time. And you don't want to press the wrong player by mistake. I would use an old menu in this case. Otherwise you can't update it without setting the page to the first again. The whole point of the new menu style is that you create it once and get a feedback when completed. That's not what you are after. You're trying to create a more dynamic menu. You need to consider players leaving, and others taking their place with a new UID. A perfect menu would take all of these things into account. I made an example that you can test alone. It will simulate players and them leaving. I made comments throughout so you'd be able to understand what's going on. When you're done testing, replace all the functions that end with _debug with the original ones. Unfortunately these things might appear complicated to a beginner so I don't think I would've been able to nudge you in the right direction. That's why I created the whole thing instead. If you have questions, please ask.
main plugin
debug.inc
|
Re: The menu doesn't update for every player
Dear sir, I have a question. Maybe a bit off-topic.. makes me curious on this
PHP Code:
PHP Code:
|
Re: The menu doesn't update for every player
Searching is very helpful, try it.
|
Re: The menu doesn't update for every player
It's 1023 in this case because that's how menu works. You provide a bitsum for keys that you want to be available in your menu (0-9). Take a look here: http://amxmodx.org/api/amxconst#menu-keys
So, if you want your menu to have only keys 1 and 3, you would pass (MENU_KEY_1 | MENU_KEY_3) to register_menucmd(). 1023 is the sum of all 10, meaning all keys are available. In "client" arrays you want 33 because in a 33 long array indices go from 0 to 32, and players use indices 1 to 32. You could set length to 32 but then you would have to substract 1 from client index every time you want to access that array, or otherwise you would go out of bounds. 4 bytes of memory spent is nothing compared to that useless calculation. This question has also been answered multiple times on this forum. As for other arrays, unless it's a limit in the game (like name's max length which is 32), it's just that people like working with such numbers. |
All times are GMT -4. The time now is 11:09. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.