View Single Post
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 04-26-2024 , 03:50   Re: Edit this plugin
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
The problem is that you're misunderstanding how the "paccess" parameter in menu_additem() works. A value of 1 for this parameter allows anybody with immunity to access that item. The values that are intended to be used in this parameter are found in amxconst.inc here. You can see that the admin immunity flag (ADMIN_IMMUNITY) is a value of 1.

To do what you want, you're actually looking for callbacks. Callbacks are used to determine if you want an item enabled or disabled when this menu is shown to the player. So, in this case, you want "paccess" to always be zero and then create your callback:

PHP Code:
public showMyMenu(id)
{
    new 
menu menu_create()
    new 
cbLevelCheck menu_makecallback("cbLevelCheck")

    
menu_additem(menu"Name(1)""Info"0cbLevelCheck)
    .
    .
    .
    
menu_additem(menu"Name(n)""Info"0cbLevelCheck)
    
menu_display(idmenu0)
}

public 
cbLevelCheck(idmenuitem)
{
    
// Use any logic here to determine if the item should be enabled or disabled
    
if( iLevel[id] >= item )
    {
        return 
ITEM_ENABLED
    
}

    return 
ITEM_DISABLED

You can take a look at the New Menus Tutorial to learn more neat features.

P.S. You need to make your title descriptive (it's a rule here) so that people can have a general idea of what your post is about without having to read the entire post.



I think you should probably do some testing first (e.g. learn how the menu_additem() function works). Also, you didn't even attempt to answer his question. At least explain that nothing you're posting has anything to do with the actual question.

Also, "if( iLevel[id] > 0 )" and "if(iLevel[id])" are two very different functionality.
I will try to do it that way. Also, I promise to be more descriptive the next time. Thank you very much for the help!
JuanitoAlimana is offline