Raised This Month: $ Target: $400
 0% 

Menus


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 05-17-2012 , 19:26   Re: Menus
Reply With Quote #1

I did?
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 05-17-2012 , 20:02   Re: Menus
Reply With Quote #2

Quote:
Originally Posted by Bilal Pro View Post
I did?
You did, if they press exit.

He means you should at the end of the function.
__________________
Hi.
Kreation is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-17-2012 , 20:41   Re: Menus
Reply With Quote #3

I've got another question. Is there a way for a menu's handler to return a value to its calling function.
For instance.....i want the client to choose a value, then implement the chosen value in the calling function.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-18-2012 , 04:47   Re: Menus
Reply With Quote #4

What function, what value?

Yes, you should destroy the menu since you don't need it after closing it and there's no need to fill the memory with useless things.
__________________
<VeCo> is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 05-18-2012 , 06:50   Re: Menus
Reply With Quote #5

Liverwiz for that you'd use the menu's handler.
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-18-2012 , 09:10   Re: Menus
Reply With Quote #6

I'm trying to prompt the user of the menu (admin) a list of possible players to do an action to, then the proper value for the action.

It'd be most efficient to grab the answers one after another then use the chosen vars in a function that deals with it. Code....

Code:
switch(selection)
	{
		case 1: // set level
		{
			new menu = menu_create("BKF Admin", "mh_BKFAdmin")
			menu_additem(menu, "Set Player Level", "1", ADMIN_KICK)
			menu_additem(menu, "Set Player Frags", "2", ADMIN_KICK)
			menu_additem(menu, "Give Player Frags", "3", ADMIN_KICK)
			menu_additem(menu, "Prune Vault", "4", ADMIN_BAN)
			menu_additem(menu, "Set CVARs", "5", ADMIN_CFG)

			menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
			menu_display(id, menu, 0)

			new playerID = mh_playerSelect(id)
			new level = mh_levelMenu(id)
			new frags = setLevel(playerID, level, ADMIN_GRANT)
			new sz_name[34]
			get_user_name(playerID, sz_name, charsmax(sz_name) )
			client_print_color(id, DontChage, "[BKF] ^3%s ^1has been set with %d frags. (level %d)", sz_name, frags, getLevel(playerID) )
		}
That's a snippet from the main menu's choices. It wasn't finished (as you can tell i CPd a lot) because i was called away from my programming nook. But you can see what i want out of it.
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 05-18-2012 at 09:22. Reason: typo
Liverwiz is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-18-2012 , 09:27   Re: Menus
Reply With Quote #7

D'you mean something like this?

PHP Code:
public MyPlayerMenuid )
{
    new 
iMenu menu_create"\ySelect a player""MyPlayerHandler" );
    
    new 
iPlayers32 ], iNumszName32 ], szInfo];
    
get_playersiPlayersiNum );

    for( new 
iNum ++ )
    {
        
get_user_nameiPlayers], szNamecharsmaxszName ) );
        
num_to_striPlayers], szInfocharsmaxszInfo ) );
        
menu_additemiMenuszNameszInfo);
    }
    
    
menu_displayidiMenu );

And then in your handler you can use the info to refer back to the player's index, and then check if they're still eligible to target for a command?

Btw no need for the double posting - there is an edit button ;)
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 05-18-2012 at 10:16.
hornet is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-18-2012 , 09:43   Re: Menus
Reply With Quote #8

Quote:
Originally Posted by hornet View Post
And then in your handler you can use the info to refer back to the player's index, and then check if they're still eligible to target for a command?
Oh, so like sending the playerID or something as the data to the handler, which will then get the level from the admin and perform calcs from there? I suppose that could work....we shall see!

Quote:
Originally Posted by hornet View Post
Btw no need for the double posting - there is an edit button ;)
They were different purposes for posting to different people. I felt it'd be best to do it that way. I'm quite familiar with the edit button. I use it when its necessary. For instance: i will edit this to see how it compiles when i'm done. ;)
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 05-18-2012 at 09:43.
Liverwiz is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-18-2012 , 09:59   Re: Menus
Reply With Quote #9

Quote:
Originally Posted by Liverwiz View Post
Oh, so like sending the playerID or something as the data to the handler, which will then get the level from the admin and perform calcs from there?
Not the admin level, the player index.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 05-18-2012 , 10:13   Re: Menus
Reply With Quote #10

Like hornet showed in the upper example, you can send data to the Handler by using the third parameter of menu_additem()
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
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 00:19.


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