Skip to content

Commit 316f536

Browse files
Fix freecam mouse & key input by ignoring it when MTA window not focused (#402)
Using new https://wiki.multitheftauto.com/wiki/IsMTAWindowFocused since 1.5.9 r21313
1 parent 15fbc95 commit 316f536

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

[editor]/freecam/freecam.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ function getKeyState(key)
4646
if isMTAWindowActive() then
4747
return false
4848
end
49+
if not isMTAWindowFocused() then
50+
return false
51+
end
4952
if key == "lshift" or key == "lalt" or key == "arrow_u" or key == "arrow_d" or key == "arrow_l" or key == "arrow_r" then
5053
return mta_getKeyState(key)
5154
end
@@ -217,7 +220,7 @@ local function freecamMouse (cX,cY,aX,aY)
217220
--ignore mouse movement if the cursor or MTA window is on
218221
--and do not resume it until at least 5 frames after it is toggled off
219222
--(prevents cursor mousemove data from reaching this handler)
220-
if isCursorShowing() or isMTAWindowActive() then
223+
if isCursorShowing() or isMTAWindowActive() or (not isMTAWindowFocused()) then
221224
mouseFrameDelay = 5
222225
return
223226
elseif mouseFrameDelay > 0 then

[editor]/freecam/meta.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<meta>
22
<info author="eAi, QA Team" description="This resource provides a 'free' controllable camera to 'fly' around the map with" version="1.1" />
3+
<min_mta_version client="1.5.9-9.21313.0"/>
34
<script src="freecam.lua" type="client" />
45
<script src="freecam_server.lua" type="server" />
56
<!-- server functions -->

0 commit comments

Comments
 (0)