Raised This Month: $51 Target: $400
 12% 

Solved menu item


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 01-29-2020 , 09:02   menu item
Reply With Quote #1

Menu item selection once selected disable it.
__________________

Last edited by Sanjay Singh; 01-30-2020 at 08:31.
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 01-29-2020 , 09:07   Re: menu item
Reply With Quote #2

This will help you understand :
https://forums.alliedmods.net/showthread.php?t=46364
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 01-29-2020 , 09:11   Re: menu item
Reply With Quote #3

Quote:
Originally Posted by Shadows Adi View Post
tried callback but it didnt worked
__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 01-29-2020 , 11:20   Re: menu item
Reply With Quote #4

Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>

new item_enabled[MAX_PLAYERS+1]

public plugin_init() {
    register_clcmd("say /menu", "gravity_menu")
}

public gravity_menu(id) {
    new item_name[64], disabled_text[20] = " \d[selected]"
    new menu = menu_create("menu name", "gravity_menu_handler")
    format(item_name, charsmax(item_name), "\rgravity%s", item_enabled[id] ?  disabled_text : (""))
    menu_additem(menu, item_name, _, _, menu_makecallback(item_enabled[id] ? "callback_disable" : "callback_ignore"))
    menu_additem(menu, "reset", _, _)
    menu_display(id, menu, 0)
}

public gravity_menu_handler(id, menu, item) {

    switch(item) {
        case MENU_EXIT: {
            menu_destroy(menu)
            return PLUGIN_HANDLED
        }
        case 0: {
            set_user_gravity(id, 0.1)
            item_enabled[id]=1
        }
        case 1: {
            set_user_gravity(id, 1.0)
            item_enabled[id]=0
        }

    }
    menu_destroy(menu)
    gravity_menu(id)
    return PLUGIN_HANDLED
}

public client_connect(id)
    item_enabled[id]=0

public callback_disable() return ITEM_DISABLED

public callback_ignore() return ITEM_ENABLED
//for future reference

The difference between ITEM_ENABLED and ITEM_IGNORE is that if you use ITEM_IGNORE, the menu_additem's 4th parameter "paccess" will supersede it if needed. In other words, will disable the item. ITEM_ENABLED will enable no the item matter what and it is final.
__________________
retired chump

Last edited by DjSoftero; 01-30-2020 at 14:57. Reason: further explanation
DjSoftero is offline
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 01-29-2020 , 14:41   Re: menu item
Reply With Quote #5

Solved @djsoftero thnx
__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 01-30-2020 , 05:13   Re: menu item
Reply With Quote #6

This is a public forum. If you delete a question, this thread no longer benefits anyone. If you want individual help, it's not free from my part.
__________________
retired chump
DjSoftero 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 05:11.


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