Skip to content

Commit 700db47

Browse files
committed
Close all menus on resource stop.
All menus will be automatically closed when this resource is being stopped, this is to prevent the UI prompts getting stuck on the screen in RedM.
1 parent f73a7f3 commit 700db47

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

MenuAPI/MenuController.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ private async Task ProcessMainButtons()
319319
// Cancel / Go Back
320320
else if (
321321
#if FIVEM
322-
Game.IsDisabledControlJustReleased(0, Control.PhoneCancel)
322+
Game.IsDisabledControlJustReleased(0, Control.PhoneCancel)
323323
#endif
324324
#if REDM
325325
Call<bool>(IS_DISABLED_CONTROL_JUST_RELEASED, 0, Control.FrontendCancel)
@@ -332,7 +332,7 @@ private async Task ProcessMainButtons()
332332
}
333333
else if (
334334
#if FIVEM
335-
Game.IsDisabledControlJustReleased(0, Control.PhoneCancel)
335+
Game.IsDisabledControlJustReleased(0, Control.PhoneCancel)
336336
#endif
337337
#if REDM
338338
Call<bool>(IS_DISABLED_CONTROL_JUST_RELEASED, 0, Control.CellphoneCancel)
@@ -1051,5 +1051,19 @@ private static void DisposeInstructionalButtonsScaleform()
10511051
}
10521052
}
10531053
#endif
1054+
1055+
/// <summary>
1056+
/// Prevent the UI prompts getting stuck on screen if this resource is ever to be restarted while someone has any menu's open.
1057+
/// </summary>
1058+
/// <param name="name"></param>
1059+
[EventHandler("onResourceStop")]
1060+
private static void OnResourceStop(string name)
1061+
{
1062+
if (name == GetCurrentResourceName())
1063+
{
1064+
Debug.WriteLine($"^3[WARNING] [{name}] Closing all menus because this resource is being stopped, to prevent the UI Prompts getting stuck.^7");
1065+
CloseAllMenus();
1066+
}
1067+
}
10541068
}
10551069
}

0 commit comments

Comments
 (0)