Skip to content

Commit e62bc54

Browse files
Fix #535: Map key bind interferes with race editor help (#573)
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.
1 parent 2b3bc10 commit e62bc54

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

[gameplay]/freeroam/fr_client.lua

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2243,11 +2243,21 @@ addEventHandler('onClientResourceStart', resourceRoot,
22432243
createWindow(wndMain)
22442244
hideAllWindows()
22452245
bindKey('f1', 'down', toggleFRWindow)
2246+
bindKey('f2', 'down', toggleMap)
22462247
guiCheckBoxSetSelected(getControl(wndMain, 'jetpack'), isPedWearingJetpack(localPlayer))
22472248
guiCheckBoxSetSelected(getControl(wndMain, 'falloff'), canPedBeKnockedOffBike(localPlayer))
22482249
end
22492250
)
22502251

2252+
addEventHandler('onClientResourceStart', root,
2253+
function(startedResource)
2254+
local editorResource, raceResource = getResourceFromName('editor'), getResourceFromName('race')
2255+
if (editorResource and raceResource and startedResource == raceResource) then
2256+
unbindKey('f2', 'down', toggleMap)
2257+
end
2258+
end
2259+
)
2260+
22512261
function showWelcomeMap()
22522262
createWindow(wndSpawnMap)
22532263
showCursor(true)
@@ -2267,7 +2277,6 @@ function toggleMap()
22672277
showCursor(true)
22682278
end
22692279
end
2270-
bindKey("f2", "down", toggleMap)
22712280

22722281
function toggleFRWindow()
22732282
if isWindowOpen(wndMain) then
@@ -2355,6 +2364,15 @@ addEventHandler('onClientResourceStop', resourceRoot,
23552364
end
23562365
)
23572366

2367+
addEventHandler('onClientResourceStop', root,
2368+
function(stoppingResource)
2369+
local editorResource, raceResource = getResourceFromName('editor'), getResourceFromName('race')
2370+
if (editorResource and raceResource and stoppingResource == raceResource) then
2371+
bindKey('f2', 'down', toggleMap)
2372+
end
2373+
end
2374+
)
2375+
23582376
function setVehicleGhost(sourceVehicle,value)
23592377

23602378
local vehicles = getElementsByType("vehicle")

0 commit comments

Comments
 (0)