Raised This Month: $ Target: $400
 0% 

[SOLVED] menu callback trouble


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-04-2013 , 06:25   Re: menu callback trouble
Reply With Quote #8

As a side note, for admin items you don't need to make a callback.
Code:
/**
 * Adds an menu to a menu.
 *
 * @param menu			Menu resource identifier.
 * @param name			Item text to display.
 * @param info			Item info string for internal information.
 * @param paccess		Access required by the player viewing the menu.
 * @param callback		If set to a valid ID from menu_makecallback(), the 
 *						callback will be invoked before drawing the item.
 * @noreturn
 * @error				Invalid menu resource.
 */
native menu_additem(menu, const name[], const info[]="", paccess=0, callback=-1);
Just set paccess variable to ADMIN_ADMIN and it should work.

PHP Code:
menu_additem(DM_Menu"Admin Menu""5"0g_AdminCallback
->

PHP Code:
menu_additem(DM_Menu"Admin Menu""5"ADMIN_ADMIN

2nd tip, you don't need to get item info and ton convert it to an integer to retrieve key, just use item instead :

PHP Code:
    new data[6], szName[64];
    new 
accesscallback;
    
    
menu_item_getinfo(DM_Menuitemaccessdatacharsmax(data), szNamecharsmax(szName), callback);
    
    new 
key str_to_num(data);
    
    switch( 
key )
    {
        case 
1// Change Team Menu 
->

PHP Code:
    switch( item )
    {
        case 
0// Change Team Menu 
item starts at 0 when your code was making key start at 1, this is the only difference.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 01-04-2013 at 06:27.
ConnorMcLeod is offline
 



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 13:44.


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