Raised This Month: $ Target: $400
 0% 

Send data to menu?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 03-16-2009 , 09:07   Send data to menu?
Reply With Quote #1

Is there an easy way? Or a way at all? :/
Spunky is offline
Send a message via AIM to Spunky
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 03-16-2009 , 09:33   Re: Send data to menu?
Reply With Quote #2

To menu... Are you meaning to the menu handler function or what?
SnoW is offline
Send a message via MSN to SnoW
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 03-16-2009 , 09:34   Re: Send data to menu?
Reply With Quote #3

Yeah, what else would I mean?
Spunky is offline
Send a message via AIM to Spunky
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 03-16-2009 , 12:08   Re: Send data to menu?
Reply With Quote #4

Quote:
Originally Posted by Spunky View Post
Yeah, what else would I mean?
Who knows?
But aye. There's no way, since it can't be passed in menu_display. So... Probably you'll use global variable.
SnoW is offline
Send a message via MSN to SnoW
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-16-2009 , 14:05   Re: Send data to menu?
Reply With Quote #5

If you are using the new menu system you can do it.
Put data as the third parameter in menu_additem

Then you can retrieve the data in the menu_handler like:
Code:
    //now lets create some variables that will give us information about the menu and the item that was pressed/chosen
    new data[6], iName[64]
    new access, callback
    //heres the function that will give us that information (since it doesnt magicaly appear)
    menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 03-16-2009 , 14:13   Re: Send data to menu?
Reply With Quote #6

Aye, but if you need to use the infos for regonizing the items in the handler, it isn't possible to get what part in the string is the item's info and what that one, if you would add them both.
SnoW is offline
Send a message via MSN to SnoW
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-16-2009 , 14:15   Re: Send data to menu?
Reply With Quote #7

Could simply make the data[] = "01otherdata"
all the way to "99otherdata"

str_to_num will still get the number correctly. Then you can just do data[2] to get the other data.

Edit: Even if you didn't want to use exactly that, you could seperate the data by an identifier.
formatex(data, len, "%d|%s", num, extra_data);

Then use strtok(data, Left, 20, Right, 20, '|');
And use str_to_num(Left) and then you have the extra data in Right

Last edited by Emp`; 03-16-2009 at 14:19.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 03-16-2009 , 14:21   Re: Send data to menu?
Reply With Quote #8

Quote:
Originally Posted by Emp` View Post
...seperate the data by an identifier...
Didn't thinking using only numbers, but identifier's right, didn't think about it. Still this will soon sound like it's easier to only use the global variable.
SnoW is offline
Send a message via MSN to SnoW
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 03-16-2009 , 16:21   Re: Send data to menu?
Reply With Quote #9

Seems like way too much trouble. Besides, I thought of just using a global variable right after posting here. Still, interesting to know that you can do it.
Spunky is offline
Send a message via AIM to Spunky
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-16-2009 , 17:09   Re: Send data to menu?
Reply With Quote #10

Actually, you can use the data originally like Emp` said without identifiers.
The "item" parameter in the handling function shows the item number that you did.

Code:
public menu_handler(id, menu, item) {     if( item == MENU_EXIT ) return;         new key = (item % 7) + 1;     new page = (item / 7) + 1;         // key = 1-7     // page = 1-(total pages) }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 08:58.


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