From 67897dcdcb34d63bf9f784d87e127648681134c0 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 23 Dec 2019 00:24:18 +0000 Subject: [PATCH] Added in key lock --- __resource.lua | 2 +- cl_radar.lua | 50 ++++++++++++++++++++++++++++++++++-------------- config.lua | 4 ++++ docs/version.txt | 2 +- nui/radar.css | 17 +++++++++++++++- nui/radar.html | 4 +++- nui/radar.js | 17 +++++++++++++++- 7 files changed, 77 insertions(+), 19 deletions(-) diff --git a/__resource.lua b/__resource.lua index e7d3c1d..37da14e 100644 --- a/__resource.lua +++ b/__resource.lua @@ -10,7 +10,7 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' name 'Wraith ARS 2X' description 'An advanced radar system for FiveM' author 'WolfKnight' -version 'beta2d' +version 'beta2e' files { "nui/radar.html", diff --git a/cl_radar.lua b/cl_radar.lua index 0919608..fdc7bd1 100644 --- a/cl_radar.lua +++ b/cl_radar.lua @@ -178,7 +178,10 @@ RADAR.vars = -- The wait time for the ray trace system, this changes dynamically based on if the player's vehicle is stationary -- or not - threadWaitTime = 500 + threadWaitTime = 500, + + -- Key lock, when true, prevents any of the radar's key events from working, like the ELS key lock + keyLock = false } -- Speed conversion values @@ -391,6 +394,18 @@ if ( RADAR:IsFastLimitAllowed() ) then end end +function RADAR:ToggleKeyLock() + if ( PLY:VehicleStateValid() ) then + self.vars.keyLock = not self.vars.keyLock + + SendNUIMessage( { _type = "displayKeyLock" } ) + end +end + +function RADAR:GetKeyLockState() + return self.vars.keyLock +end + --[[---------------------------------------------------------------------------------- Radar menu functions @@ -1536,21 +1551,28 @@ function RADAR:RunControlManager() --[[ if ( IsDisabledControlJustPressed( 1, 20 ) ) then self.config.debug_mode = not self.config.debug_mode end ]] - - -- Opens the remote control - if ( IsDisabledControlJustPressed( 1, self.config.remote_control_key ) ) then - self:OpenRemote() - end + + if ( not self:GetKeyLockState() ) then + -- Opens the remote control + if ( IsDisabledControlJustPressed( 1, self.config.remote_control_key ) ) then + self:OpenRemote() + end - -- Locks speed from front antenna - if ( IsDisabledControlJustPressed( 1, self.config.front_lock_key ) ) then - self:LockAntennaSpeed( "front" ) - end + -- Locks speed from front antenna + if ( IsDisabledControlJustPressed( 1, self.config.front_lock_key ) ) then + self:LockAntennaSpeed( "front" ) + end - -- Locks speed from rear antenna - if ( IsDisabledControlJustPressed( 1, self.config.rear_lock_key ) ) then - self:LockAntennaSpeed( "rear" ) - end + -- Locks speed from rear antenna + if ( IsDisabledControlJustPressed( 1, self.config.rear_lock_key ) ) then + self:LockAntennaSpeed( "rear" ) + end + end + + -- Toggles the key lock state + if ( IsDisabledControlJustPressed( 1, self.config.key_lock_key ) ) then + self:ToggleKeyLock() + end -- Shortcut to restart the resource --[[if ( IsDisabledControlJustPressed( 1, 167 ) ) then diff --git a/config.lua b/config.lua index ce6d33f..fe6c1b3 100644 --- a/config.lua +++ b/config.lua @@ -21,6 +21,10 @@ RADAR.config.front_lock_key = 111 -- The default key to lock/unlock the rear antenna is 112 (Numpad 5 - INPUT_VEH_FLY_PITCH_DOWN_ONLY) RADAR.config.rear_lock_key = 112 +-- Radar key lock key +-- The default key to enable/disable the radar key lock is 311 (K - INPUT_REPLAY_SHOWHOTKEY) +RADAR.config.key_lock_key = 311 + -- Radar fast limit locking -- When enabled, the player will be able to define a fast limit within the radar's menu, when a vehicle -- exceeds the fast limit, it will be locked into the fast box. Default setting is disabled to maintain realism diff --git a/docs/version.txt b/docs/version.txt index e85d427..123caeb 100644 --- a/docs/version.txt +++ b/docs/version.txt @@ -1 +1 @@ -beta2d \ No newline at end of file +beta2e \ No newline at end of file diff --git a/nui/radar.css b/nui/radar.css index f45a71e..30a3294 100644 --- a/nui/radar.css +++ b/nui/radar.css @@ -765,4 +765,19 @@ button:focus { outline: none; } #uiSettingsBox .close:active { background-color: rgb( 190, 190, 190 ); padding: 0; - } \ No newline at end of file + } + +#keyLockLabel { + position: absolute; + left: 0; + right: 0; + bottom: 300px; + + text-align: center; + font-size: 30px; + + color: rgb( 200, 200, 200 ); + text-shadow: 3px 2px 5px rgb( 0, 0, 0 ); + + z-index: 4; +} \ No newline at end of file diff --git a/nui/radar.html b/nui/radar.html index 0f617f7..c643d9f 100644 --- a/nui/radar.html +++ b/nui/radar.html @@ -232,7 +232,9 @@ - + + +

Radar key lock toggled

diff --git a/nui/radar.js b/nui/radar.js index 15e6a8c..c17d12f 100644 --- a/nui/radar.js +++ b/nui/radar.js @@ -56,7 +56,9 @@ const elements = increase: $( "#increaseScale" ), decrease: $( "#decreaseScale" ), display: $( "#scaleDisplay" ) - }, + }, + + keyLock: $( "#keyLockLabel" ), patrolSpeed: $( "#patrolSpeed" ), @@ -128,6 +130,7 @@ const dirs = elements.radar.hide(); elements.remote.hide(); elements.uiSettingsBox.hide(); +elements.keyLock.hide(); elements.uiSettingsBtn.click( function() { setUISettingsVisible( true, true ); @@ -320,6 +323,15 @@ function settingUpdate( ants ) } } +function displayKeyLock() +{ + elements.keyLock.fadeIn(); + + setTimeout( function() { + elements.keyLock.fadeOut(); + }, 2000 ); +} + function playAudio( name, vol ) { let audio = new Audio( "sounds/" + audioNames[name] ); @@ -480,6 +492,9 @@ window.addEventListener( "message", function( event ) { break; case "lockAudio": playLockAudio( item.ant, item.dir, item.vol ); + break; + case "displayKeyLock": + displayKeyLock(); break; default: break;