Raised This Month: $90 Target: $400
 22% 

Solved Passing array to menu_additem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iNvectus
Member
Join Date: Sep 2014
Old 03-14-2019 , 05:42   Passing array to menu_additem
Reply With Quote #1

Greetings. I want to know if it is possible to pass an array to menu_additem.

Example:
PHP Code:
 #include <amxmodx>

 #define MAX_ZONES 25

 
new Float:fOrigin[MAX_ZONES][3];
 new 
g_iZones 5;
 
 public 
plugin_init()
 {
    
register_plugin("Test Menu""1.00""iNvectus");

    
register_clcmd"test","testMenu" );
 }

 public 
testMenuid )
 {
    new 
menu menu_create"\rPick option:""menu_handler" );
    
get_user_origin(idfOrigin[id], 0);

    for(new 
0g_iZonesi++)
        
menu_additem(menu"Test"fOrigin[i], 0);    // Is this possible, if yes, how to handle it in the menu handler?
    
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );
    
menu_displayidmenu);
   
   return 
PLUGIN_HANDLED;
 }
 
 public 
menu_handleridmenuitem )
 {
    if ( 
item == MENU_EXIT ) {
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }
    new 
szData[33];
    new 
_accessitem_callback;

    
menu_item_getinfomenuitem_access, ?, ?, item_callback );

    
menu_destroymenu );
    return 
PLUGIN_HANDLED;
 } 

Last edited by iNvectus; 03-14-2019 at 13:45.
iNvectus is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 03-14-2019 , 11:46   Re: Passing array to menu_additem
Reply With Quote #2

Format a new string with formatex and pass that instead of "Test".
__________________
<VeCo> is offline
iNvectus
Member
Join Date: Sep 2014
Old 03-14-2019 , 12:56   Re: Passing array to menu_additem
Reply With Quote #3

Quote:
Originally Posted by <VeCo> View Post
Format a new string with formatex and pass that instead of "Test".
What I want to do is pass the Origin. The test is just the label for the menu item.
iNvectus is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 03-14-2019 , 13:08   Re: Passing array to menu_additem
Reply With Quote #4

nvm, you'd still need a string, use float_to_str
__________________
<VeCo> is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 03-14-2019 , 13:33   Re: Passing array to menu_additem
Reply With Quote #5

Code:
new szOrigin[33]; formatex(szOrigin, charsmax(szOrigin), "%.1f %.1f %.1f", fOrigin[0], fOrigin[1], fOrigin[2]) menu_additem(menu, "text", szOrigin); ... new szBuffer[33], szOrigin[3][11], Float:fOrigin[3]; menu_item_getinfo(...) parse(szBuffer, szOrigin[0], charsmax(szOrigin[]), szOrigin[1], charsmax(szOrigin[]), szOrigin[2], charsmax(szOrigin[])); fOrigin[0] = str_to_float(szOrigin[0]); fOrigin[1] = str_to_float(szOrigin[1]); fOrigin[2] = str_to_float(szOrigin[2]);

or

Code:
// Global origin variable new Float:g_fOrigin[33][3]; ... get_user_origin(id, g_fOrigin[id], 0);
__________________
Accepting private $$$ plugins requests.

@Steam: crazy770
@Discord: CrazY.#5317

Website | Channel

CrazY. is offline
iNvectus
Member
Join Date: Sep 2014
Old 03-14-2019 , 13:45   Re: Passing array to menu_additem
Reply With Quote #6

Quote:
Originally Posted by CrazY. View Post
Code:
new szOrigin[33]; formatex(szOrigin, charsmax(szOrigin), "%.1f %.1f %.1f", fOrigin[0], fOrigin[1], fOrigin[2]) menu_additem(menu, "text", szOrigin); ... new szBuffer[33], szOrigin[3][11], Float:fOrigin[3]; menu_item_getinfo(...) parse(szBuffer, szOrigin[0], charsmax(szOrigin[]), szOrigin[1], charsmax(szOrigin[]), szOrigin[2], charsmax(szOrigin[])); fOrigin[0] = str_to_float(szOrigin[0]); fOrigin[1] = str_to_float(szOrigin[1]); fOrigin[2] = str_to_float(szOrigin[2]);

or

Code:
// Global origin variable new Float:g_fOrigin[33][3]; ... get_user_origin(id, g_fOrigin[id], 0);
Thank you. That would work like a charm
iNvectus is offline
Old 03-14-2019, 22:00
Bugsy
This message has been deleted by Bugsy. Reason: nvm, misunderstood
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 17:09.


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