Add menu_item_setaccess native (#826)

* Add set access.

* Update newmenus.inc

* typo

* Update newmenus.inc
This commit is contained in:
shel 2020-05-29 23:40:35 +04:00 committed by GitHub
parent 1bc342a692
commit b9b4001bf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -1006,6 +1006,20 @@ static cell AMX_NATIVE_CALL menu_item_setcall(AMX *amx, cell *params)
return 1;
}
static cell AMX_NATIVE_CALL menu_item_setaccess(AMX *amx, cell *params)
{
GETMENU(params[1]);
menuitem *pItem = pMenu->GetMenuItem(static_cast<item_t>(params[2]));
if (!pItem)
return 0;
pItem->access = params[3];
return 1;
}
static cell AMX_NATIVE_CALL menu_setprop(AMX *amx, cell *params)
{
GETMENU(params[1]);
@ -1237,6 +1251,7 @@ AMX_NATIVE_INFO g_NewMenuNatives[] =
{"menu_item_getinfo", menu_item_getinfo},
{"menu_makecallback", menu_makecallback},
{"menu_item_setcall", menu_item_setcall},
{"menu_item_setaccess", menu_item_setaccess},
{"menu_item_setcmd", menu_item_setcmd},
{"menu_item_setname", menu_item_setname},
{"menu_destroy", menu_destroy},

View File

@ -257,6 +257,17 @@ native menu_item_setcmd(menu, item, const info[]);
*/
native menu_item_setcall(menu, item, callback=-1);
/**
* Sets an item's access.
*
* @param menu Menu resource identifier.
* @param item Item identifier.
* @param access New access required by the player for access to the item.
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
*/
native menu_item_setaccess(menu, item, access=0);
/**
* Destroys a menu. Player menus will be cancelled (although may still linger
* on the HUD), and future attempts to access the menu resource will result in