From 42c0dddfa9098f91da53f71696647c044a27e542 Mon Sep 17 00:00:00 2001 From: ArKaNeMaN Date: Wed, 15 Mar 2023 07:51:15 +0300 Subject: [PATCH] Add aborting auto close task if menu used --- amxmodx/scripting/VipM-L-GameCMS.sma | 6 +++++- amxmodx/scripting/VipM-M-WeaponMenu.sma | 11 +++++------ amxmodx/scripting/VipM/WeaponMenu/Menus.inc | 2 ++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/amxmodx/scripting/VipM-L-GameCMS.sma b/amxmodx/scripting/VipM-L-GameCMS.sma index c27f938..2af61a8 100644 --- a/amxmodx/scripting/VipM-L-GameCMS.sma +++ b/amxmodx/scripting/VipM-L-GameCMS.sma @@ -7,6 +7,10 @@ #define GCMS_GROUP_NAME_MAX_LEN (MAX_NAME_LENGTH * 2) #endif +#if !defined GCMS_SERVICE_NAME_MAX_LEN + #define GCMS_SERVICE_NAME_MAX_LEN (MAX_STRING_LEN * 2) +#endif + #pragma semicolon 1 #pragma compress 1 @@ -49,7 +53,7 @@ public VipM_OnInitModules() { } @OnServiceCheck(const Trie:Params, const UserId) { - new sServiceName[32]; + new sServiceName[GCMS_SERVICE_NAME_MAX_LEN]; VipM_Params_GetStr(Params, "Service", sServiceName, charsmax(sServiceName)); return cmsapi_service_timeleft(UserId, .srvName=sServiceName, .part=false) > TIME_TRACKING_STOPPED; diff --git a/amxmodx/scripting/VipM-M-WeaponMenu.sma b/amxmodx/scripting/VipM-M-WeaponMenu.sma index 1cabaee..2bdc1f9 100644 --- a/amxmodx/scripting/VipM-M-WeaponMenu.sma +++ b/amxmodx/scripting/VipM-M-WeaponMenu.sma @@ -132,12 +132,11 @@ public VipM_OnInitModules() { show_menu(UserId, 0, ""); } -// TODO: Придумать как лучше использовать... -// AbortAutoCloseMenu(const UserId) { -// if (task_exists(TASK_OFFSET_AUTO_CLOSE + UserId)) { -// remove_task(TASK_OFFSET_AUTO_CLOSE + UserId); -// } -// } +AbortAutoCloseMenu(const UserId) { + if (task_exists(TASK_OFFSET_AUTO_CLOSE + UserId)) { + remove_task(TASK_OFFSET_AUTO_CLOSE + UserId); + } +} @Cmd_SwitchAutoOpen(const UserId) { gUserAutoOpen[UserId] = !gUserAutoOpen[UserId]; diff --git a/amxmodx/scripting/VipM/WeaponMenu/Menus.inc b/amxmodx/scripting/VipM/WeaponMenu/Menus.inc index c20a0d1..c241c39 100644 --- a/amxmodx/scripting/VipM/WeaponMenu/Menus.inc +++ b/amxmodx/scripting/VipM/WeaponMenu/Menus.inc @@ -87,6 +87,8 @@ Menu_WeaponsMenu(const UserId, const MenuId, const Menu[S_WeaponMenu]) { } @MenuHandler_Command(const UserId, const MenuId, const ItemId){ + AbortAutoCloseMenu(UserId); + if (ItemId == MENU_EXIT) { menu_destroy(MenuId); return;