Raised This Month: $32 Target: $400
 8% 

Changing Menu's Globally


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Blackglade
Senior Member
Join Date: Jul 2012
Location: NYC
Old 05-14-2017 , 16:15   Changing Menu's Globally
Reply With Quote #1

I was trying to figure out a way around a problem I'm having and I found it, but now I'm confused as to whether it might cause issues with the handling of global values...


The Problem: I need to find a way to pass some data into a menu when the player opens it up.

The Solution: I decided the best way, since SP doesn't really have anything like this, would be to AddMenuItem an invisible value when the command sm_whatever is run and make sure the menu text is set to ITEMDRAW_NOTEXT.. Then when the player finally selects a value, I will just do GetMenuItem and then RemoveMenuItem.

The Problem (Part 2): Could this potentially create some issues, since I'm declaring all my menu's on OnConfigExecuted and only adding items on the fly? For example if one player opens the menu, but doesn't select a command, the menu item is added, but then never removed since the function is never called. So technically player 1 could open the menu, not select a value, while player 2 opens the menu and selects a value... modifying the menu initially mean't for player 1?

Could something like this happen? Hopefully I explained it well enough!
Blackglade is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 05-14-2017 , 16:18   Re: Changing Menu's Globally
Reply With Quote #2

Quote:
Originally Posted by Blackglade View Post
The Solution: I decided the best way, since SP doesn't really have anything like this, would be to AddMenuItem an invisible value when the command sm_whatever is run and make sure the menu text is set to ITEMDRAW_NOTEXT.. Then when the player finally selects a value, I will just do GetMenuItem and then RemoveMenuItem.
Something like this?
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
Blackglade
Senior Member
Join Date: Jul 2012
Location: NYC
Old 05-14-2017 , 16:27   Re: Changing Menu's Globally
Reply With Quote #3

Quote:
Originally Posted by KissLick View Post
Something like this?
oh snap! the stock is actually really useful... but my problem still remains...

What if two ShowMyMenu's are called and then only one MyMenu_Handler is called (since player 1 opened the menu, but never actually selected an item.. while player 2 opened the menu and did select an item).. the value I put in a cell using:

PushMenuCell(hMenu, "-MySecretValue-", iSecretValue);

is changed twice...
Blackglade is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 05-14-2017 , 16:39   Re: Changing Menu's Globally
Reply With Quote #4

Quote:
Originally Posted by Blackglade View Post
What if two ShowMyMenu's are called and then only one MyMenu_Handler is called (since player 1 opened the menu, but never actually selected an item.. while player 2 opened the menu and did select an item).. the value I put in a cell using:

PushMenuCell(hMenu, "-MySecretValue-", iSecretValue);

is changed twice...
If you create menu once and store it's handle in global variable and then show the menu to multiple clients, you will have same -MySecretValue- all the time. But this is not your case right?

I guess that you have function that creates new menu and shows it to single player, right? If so, that this should work just fine.
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.

Last edited by KissLick; 05-14-2017 at 16:42.
KissLick is offline
Blackglade
Senior Member
Join Date: Jul 2012
Location: NYC
Old 05-14-2017 , 16:49   Re: Changing Menu's Globally
Reply With Quote #5

yeah the issue I'm having is the handle is a global variable... I guess the only way around it is to make it local.
Blackglade is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 05-16-2017 , 18:04   Re: Changing Menu's Globally
Reply With Quote #6

To state the obvious.

If one menu is open and another one displayed. The open has the callback fired with closed args. So you dispose the closing menu handle.
__________________
Neuro Toxin is offline
Reply


Thread Tools
Display Modes

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 12:52.


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