From 1c69cd5e2efdfd0bdf37b55d4397a24561909d59 Mon Sep 17 00:00:00 2001 From: Christopher Date: Fri, 16 Apr 2021 09:10:10 +0200 Subject: [PATCH 1/5] keep input --- futile.lua | 32 ++++++++++++++++++++++++++++++++ fxmanifest.lua | 5 +++-- resources/client/cl_main.ts | 4 ++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 futile.lua diff --git a/futile.lua b/futile.lua new file mode 100644 index 0000000..0eb4329 --- /dev/null +++ b/futile.lua @@ -0,0 +1,32 @@ +isPhoneOpen = false + +CreateThread(function() + while true do + Wait(5) + if isPhoneOpen then + DisableControlAction(0, 1, true) -- Look Left/Right + DisableControlAction(0, 2, true) -- Look up/Down + DisableControlAction(0, 16, true) -- Next Weapon + DisableControlAction(0, 17, true) -- Select Previous Weapon + DisableControlAction(0, 22, true) -- Jump + DisableControlAction(0, 24, true) -- Attack + DisableControlAction(0, 25, true) -- Aim + DisableControlAction(0, 37, true) -- Weapon Wheel + else + EnableControlAction(0, 1, true) -- Look Left/Right + EnableControlAction(0, 2, true) -- Look up/Down + EnableControlAction(0, 17, true) -- Select Previous Weapon + EnableControlAction(0, 22, true) -- Jump + EnableControlAction(0, 24, true) -- Attack + EnableControlAction(0, 25, true) -- Aim + EnableControlAction(0, 37, true) -- Weapon Wheel + EnableControlAction(0, 16, true) -- Next Weapon + Wait(1000) + end + end +end) + +RegisterNetEvent('npwd:disableEnableInput') +AddEventHandler('npwd:disableEnableInput', function() + isPhoneOpen = not isPhoneOpen +end) \ No newline at end of file diff --git a/fxmanifest.lua b/fxmanifest.lua index d774a08..6f01192 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -3,8 +3,9 @@ game "gta5" description 'js runtime monkaW' authors { "itschip", "erik-sn", "TasoOneAsia", "kidz", "RockySouthpaw"} -client_script { - 'resources/dist/client/*.client.js' +client_scripts { + 'resources/dist/client/*.client.js', + 'futile.lua' } server_script { diff --git a/resources/client/cl_main.ts b/resources/client/cl_main.ts index 8fadd64..3248f43 100644 --- a/resources/client/cl_main.ts +++ b/resources/client/cl_main.ts @@ -58,6 +58,7 @@ const showPhone = async (): Promise => { sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, true); sendMessage('PHONE', PhoneEvents.SET_TIME, time); SetNuiFocus(true, true); + SetNuiFocusKeepInput(true); }; const hidePhone = async (): Promise => { @@ -65,6 +66,7 @@ const hidePhone = async (): Promise => { sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false); await phoneCloseAnim(); SetNuiFocus(false, false); + SetNuiFocusKeepInput(false); }; /* * * * * * * * * * * * * @@ -104,8 +106,10 @@ async function Phone(): Promise { } if (isPhoneOpen) { await hidePhone(); + emit('npwd:disableEnableInput'); } else { await showPhone(); + emit('npwd:disableEnableInput'); } } From 95ed68dff6262dba14e36fc28f1783cb3d9434a5 Mon Sep 17 00:00:00 2001 From: Darrian Date: Thu, 22 Apr 2021 12:32:10 -0400 Subject: [PATCH 2/5] RFR: Renamed file, adjusted manifest, and refactored code. Renamed the event so its more clear what it does and added a bool to denote when it's being disabled or not. This was attached to `isPhoneOpen` which wasn't reliablly working. Its now done within `showPhone` and `hidePhone`. The wait was changed from `1000` to `100` in the event the phone is opened before the wait is over. Makes it more smooth as there is no longer a small duration where the mouse moves the camera. Removed the enable of control actions as it wasn't needed. --- futile.lua | 32 -------------------------------- fxmanifest.lua | 2 +- resources/client/cl_controls.lua | 24 ++++++++++++++++++++++++ resources/client/cl_main.ts | 4 ++-- 4 files changed, 27 insertions(+), 35 deletions(-) delete mode 100644 futile.lua create mode 100644 resources/client/cl_controls.lua diff --git a/futile.lua b/futile.lua deleted file mode 100644 index 0eb4329..0000000 --- a/futile.lua +++ /dev/null @@ -1,32 +0,0 @@ -isPhoneOpen = false - -CreateThread(function() - while true do - Wait(5) - if isPhoneOpen then - DisableControlAction(0, 1, true) -- Look Left/Right - DisableControlAction(0, 2, true) -- Look up/Down - DisableControlAction(0, 16, true) -- Next Weapon - DisableControlAction(0, 17, true) -- Select Previous Weapon - DisableControlAction(0, 22, true) -- Jump - DisableControlAction(0, 24, true) -- Attack - DisableControlAction(0, 25, true) -- Aim - DisableControlAction(0, 37, true) -- Weapon Wheel - else - EnableControlAction(0, 1, true) -- Look Left/Right - EnableControlAction(0, 2, true) -- Look up/Down - EnableControlAction(0, 17, true) -- Select Previous Weapon - EnableControlAction(0, 22, true) -- Jump - EnableControlAction(0, 24, true) -- Attack - EnableControlAction(0, 25, true) -- Aim - EnableControlAction(0, 37, true) -- Weapon Wheel - EnableControlAction(0, 16, true) -- Next Weapon - Wait(1000) - end - end -end) - -RegisterNetEvent('npwd:disableEnableInput') -AddEventHandler('npwd:disableEnableInput', function() - isPhoneOpen = not isPhoneOpen -end) \ No newline at end of file diff --git a/fxmanifest.lua b/fxmanifest.lua index 6f01192..ecb0d05 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -5,7 +5,7 @@ authors { "itschip", "erik-sn", "TasoOneAsia", "kidz", "RockySouthpaw"} client_scripts { 'resources/dist/client/*.client.js', - 'futile.lua' + 'resources/client/*.lua' } server_script { diff --git a/resources/client/cl_controls.lua b/resources/client/cl_controls.lua new file mode 100644 index 0000000..581691e --- /dev/null +++ b/resources/client/cl_controls.lua @@ -0,0 +1,24 @@ +local disableKeys + +CreateThread(function() + while true do + if disableKeys then + Wait(0) + DisableControlAction(0, 1, true) -- Look Left/Right + DisableControlAction(0, 2, true) -- Look up/Down + DisableControlAction(0, 16, true) -- Next Weapon + DisableControlAction(0, 17, true) -- Select Previous Weapon + DisableControlAction(0, 22, true) -- Jump + DisableControlAction(0, 24, true) -- Attack + DisableControlAction(0, 25, true) -- Aim + DisableControlAction(0, 37, true) -- Weapon Wheel + else + Wait(100) + end + end +end) + +RegisterNetEvent('npwd:disableControlActions') +AddEventHandler('npwd:disableControlActions', function(bool) + disableKeys = bool +end) \ No newline at end of file diff --git a/resources/client/cl_main.ts b/resources/client/cl_main.ts index 3248f43..857fd35 100644 --- a/resources/client/cl_main.ts +++ b/resources/client/cl_main.ts @@ -59,6 +59,7 @@ const showPhone = async (): Promise => { sendMessage('PHONE', PhoneEvents.SET_TIME, time); SetNuiFocus(true, true); SetNuiFocusKeepInput(true); + emit('npwd:disableControlActions', true); }; const hidePhone = async (): Promise => { @@ -67,6 +68,7 @@ const hidePhone = async (): Promise => { await phoneCloseAnim(); SetNuiFocus(false, false); SetNuiFocusKeepInput(false); + emit('npwd:disableControlActions', false); }; /* * * * * * * * * * * * * @@ -106,10 +108,8 @@ async function Phone(): Promise { } if (isPhoneOpen) { await hidePhone(); - emit('npwd:disableEnableInput'); } else { await showPhone(); - emit('npwd:disableEnableInput'); } } From 80d2d5476a6060cd64aac1a814423e405b0fd04c Mon Sep 17 00:00:00 2001 From: Darrian Date: Thu, 22 Apr 2021 12:59:49 -0400 Subject: [PATCH 3/5] Fix: Additional disable controls for vehicles + chat. --- resources/client/cl_controls.lua | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/resources/client/cl_controls.lua b/resources/client/cl_controls.lua index 581691e..272b738 100644 --- a/resources/client/cl_controls.lua +++ b/resources/client/cl_controls.lua @@ -4,14 +4,25 @@ CreateThread(function() while true do if disableKeys then Wait(0) - DisableControlAction(0, 1, true) -- Look Left/Right - DisableControlAction(0, 2, true) -- Look up/Down - DisableControlAction(0, 16, true) -- Next Weapon - DisableControlAction(0, 17, true) -- Select Previous Weapon - DisableControlAction(0, 22, true) -- Jump - DisableControlAction(0, 24, true) -- Attack - DisableControlAction(0, 25, true) -- Aim - DisableControlAction(0, 37, true) -- Weapon Wheel + DisableControlAction(0, 1, true) -- Look Left/Right + DisableControlAction(0, 2, true) -- Look up/Down + DisableControlAction(0, 16, true) -- Next Weapon + DisableControlAction(0, 17, true) -- Select Previous Weapon + DisableControlAction(0, 22, true) -- Jump + DisableControlAction(0, 24, true) -- Attack + DisableControlAction(0, 25, true) -- Aim + DisableControlAction(0, 37, true) -- Weapon Wheel + DisableControlAction(0, 81, true) -- Next Radio (Vehicle) + DisableControlAction(0, 82, true) -- Previous Radio (Vehicle) + DisableControlAction(0, 91, true) -- Passenger Aim (Vehicle) + DisableControlAction(0, 92, true) -- Passenger Attack (Vehicle) + DisableControlAction(0, 99, true) -- Select Next Weapon (Vehicle) + DisableControlAction(0, 106, true) -- Control Override (Vehicle) + DisableControlAction(0, 114, true) -- Fly Attack (Flying) + DisableControlAction(0, 115, true) -- Next Weapon (Flying) + DisableControlAction(0, 122, true) -- Control OVerride (Flying) + DisableControlAction(0, 135, true) -- Control OVerride (Sub) + DisableControlAction(0, 245, true) -- Chat else Wait(100) end From 000151e756e607dd26ab537fe87df428460d4a0e Mon Sep 17 00:00:00 2001 From: Darrian Date: Thu, 22 Apr 2021 13:24:23 -0400 Subject: [PATCH 4/5] Fix: Disable additional controls. --- resources/client/cl_controls.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/resources/client/cl_controls.lua b/resources/client/cl_controls.lua index 272b738..e8f1ef4 100644 --- a/resources/client/cl_controls.lua +++ b/resources/client/cl_controls.lua @@ -4,6 +4,7 @@ CreateThread(function() while true do if disableKeys then Wait(0) + DisableControlAction(0, 0, true) -- Next Camera DisableControlAction(0, 1, true) -- Look Left/Right DisableControlAction(0, 2, true) -- Look up/Down DisableControlAction(0, 16, true) -- Next Weapon @@ -11,7 +12,13 @@ CreateThread(function() DisableControlAction(0, 22, true) -- Jump DisableControlAction(0, 24, true) -- Attack DisableControlAction(0, 25, true) -- Aim + DisableControlAction(0, 26, true) -- Look Behind DisableControlAction(0, 37, true) -- Weapon Wheel + DisableControlAction(0, 44, true) -- Cover + DisableControlAction(0, 47, true) -- Detonate + DisableControlAction(0, 55, true) -- Dive + DisableControlAction(0, 75, true) -- Exit Vehicle + DisableControlAction(0, 76, true) -- Vehicle Handbrake DisableControlAction(0, 81, true) -- Next Radio (Vehicle) DisableControlAction(0, 82, true) -- Previous Radio (Vehicle) DisableControlAction(0, 91, true) -- Passenger Aim (Vehicle) @@ -20,8 +27,10 @@ CreateThread(function() DisableControlAction(0, 106, true) -- Control Override (Vehicle) DisableControlAction(0, 114, true) -- Fly Attack (Flying) DisableControlAction(0, 115, true) -- Next Weapon (Flying) + DisableControlAction(0, 121, true) -- Fly Camera (Flying) DisableControlAction(0, 122, true) -- Control OVerride (Flying) DisableControlAction(0, 135, true) -- Control OVerride (Sub) + DisableControlAction(0, 200, true) -- Pause Menu DisableControlAction(0, 245, true) -- Chat else Wait(100) From d5aaa67c6ca3e570a0dc42e199524dac53329b57 Mon Sep 17 00:00:00 2001 From: Darrian Date: Wed, 12 May 2021 02:38:11 -0400 Subject: [PATCH 5/5] Fix: Removed net event. --- resources/client/cl_controls.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/client/cl_controls.lua b/resources/client/cl_controls.lua index e8f1ef4..bf42d64 100644 --- a/resources/client/cl_controls.lua +++ b/resources/client/cl_controls.lua @@ -38,7 +38,6 @@ CreateThread(function() end end) -RegisterNetEvent('npwd:disableControlActions') AddEventHandler('npwd:disableControlActions', function(bool) disableKeys = bool end) \ No newline at end of file