Raised This Month: $ Target: $400
 0% 

data[6]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Themaze
Junior Member
Join Date: Mar 2017
Old 12-24-2017 , 03:22   data[6]
Reply With Quote #1

Could Someone explain this please?
especially the data[6] iName[64]

Code:
new data[6], iName[64]
 new access, callback
 
 menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
Themaze is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-24-2017 , 04:53   Re: data[6]
Reply With Quote #2

"data" will store item info (third parameter of menu_additem). "iName" will store display text of the item (second parameter of menu_additem).

https://www.amxmodx.org/api/newmenus/menu_item_getinfo
__________________








CrazY. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-24-2017 , 05:18   Re: data[6]
Reply With Quote #3

Check out the tutorial for how to use these things: https://forums.alliedmods.net/showthread.php?t=46364
__________________
fysiks is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 12-24-2017 , 05:41   Re: data[6]
Reply With Quote #4

If data[1] was used, up to 10 items would be possible ( 0 to 9 ).

data[6] allows 10000000 items in a menu, so I think data[2] is best.


NOTE:

If your menu does not discard items, AKA the menu always has the same amount of slots and has no slot content changing, use switch(item+1) instead of data. And you can basically transfer an array with data but it's useless unless again the menu is inconsistent or data stores the client ID if you make a menu that lists players.

Here's an example:

menu_additem(menu, "Hello!", "dab loll");

iName is equal to "Hello!" and data is equal to "dab l" because it doesn't have enough size being equal to 6.

Last edited by eyal282; 12-24-2017 at 05:45.
eyal282 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-24-2017 , 15:16   Re: data[6]
Reply With Quote #5

No, data[] is not related to the number of menu items. The "data" array is for passing data along with the menu item. It can be used for any data that you want passed to the menu handler. Most often, it is used as a string to pass data when there is no intrinsic link between the data and the item index (e.g. when menu items are conditionally displayed) and you want to create more flexible and efficient code in the handler.
__________________
fysiks is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 12-25-2017 , 02:17   Re: data[6]
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
No, data[] is not related to the number of menu items. The "data" array is for passing data along with the menu item. It can be used for any data that you want passed to the menu handler. Most often, it is used as a string to pass data when there is no intrinsic link between the data and the item index (e.g. when menu items are conditionally displayed) and you want to create more flexible and efficient code in the handler.
What I said

I saw this scripting method a lot, data[6] is like a signature of using slot numbersx
eyal282 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 11:17.


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