From e1497e97571ed829bdd5a0ed5e562d87adac11a0 Mon Sep 17 00:00:00 2001 From: MittellBuurman Date: Mon, 11 Nov 2024 14:16:42 +0100 Subject: [PATCH] Fix #535: Map key bind interferes with race editor help Added onClientResourceStart and onClientResourceStop event handlers to listen on the root element. When both the editor resource, and the race resource are active, it unbinds toggleMap from F2 When the editor resource is active, and you stop the race resource, it binds toggleMap back to F2. Since the help menu in Race is only active when the editor is active, this should really be the only time it should either bind or unbind the toggleMap. --- [gameplay]/freeroam/fr_client.lua | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/[gameplay]/freeroam/fr_client.lua b/[gameplay]/freeroam/fr_client.lua index 2cc87a351..2d105e025 100644 --- a/[gameplay]/freeroam/fr_client.lua +++ b/[gameplay]/freeroam/fr_client.lua @@ -2243,11 +2243,21 @@ addEventHandler('onClientResourceStart', resourceRoot, createWindow(wndMain) hideAllWindows() bindKey('f1', 'down', toggleFRWindow) + bindKey('f2', 'down', toggleMap) guiCheckBoxSetSelected(getControl(wndMain, 'jetpack'), isPedWearingJetpack(localPlayer)) guiCheckBoxSetSelected(getControl(wndMain, 'falloff'), canPedBeKnockedOffBike(localPlayer)) end ) +addEventHandler('onClientResourceStart', root, + function(startedResource) + local editorResource, raceResource = getResourceFromName('editor'), getResourceFromName('race') + if (editorResource and raceResource and startedResource == raceResource) then + unbindKey('f2', 'down', toggleMap) + end + end +) + function showWelcomeMap() createWindow(wndSpawnMap) showCursor(true) @@ -2267,7 +2277,6 @@ function toggleMap() showCursor(true) end end -bindKey("f2", "down", toggleMap) function toggleFRWindow() if isWindowOpen(wndMain) then @@ -2355,6 +2364,15 @@ addEventHandler('onClientResourceStop', resourceRoot, end ) +addEventHandler('onClientResourceStop', root, + function(stoppingResource) + local editorResource, raceResource = getResourceFromName('editor'), getResourceFromName('race') + if (editorResource and raceResource and stoppingResource == raceResource) then + bindKey('f2', 'down', toggleMap) + end + end +) + function setVehicleGhost(sourceVehicle,value) local vehicles = getElementsByType("vehicle")