Skip to content

Commit

Permalink
Add aborting auto close task if menu used
Browse files Browse the repository at this point in the history
  • Loading branch information
ArKaNeMaN committed Mar 15, 2023
1 parent 85c4b9b commit 42c0ddd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 5 additions & 1 deletion amxmodx/scripting/VipM-L-GameCMS.sma
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down
11 changes: 5 additions & 6 deletions amxmodx/scripting/VipM-M-WeaponMenu.sma
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 2 additions & 0 deletions amxmodx/scripting/VipM/WeaponMenu/Menus.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

3 comments on commit 42c0ddd

@Nord1cWarr1or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не надо проверять таск перед его удалением

@ArKaNeMaN
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nord1cWarr1or А если очень хочется?)
Ладно, уберу потом такие проверки.

@Nord1cWarr1or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ArKaNeMaN а зачем? Лишний раз дергать

Please sign in to comment.