diff --git a/__resource.lua b/__resource.lua index 2393818..7214b9e 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 'beta2c' +version 'beta2d' ui_page "nui/radar.html" diff --git a/cl_radar.lua b/cl_radar.lua index 3bf3bd1..b4b52ab 100644 --- a/cl_radar.lua +++ b/cl_radar.lua @@ -93,8 +93,11 @@ RADAR.vars = -- Future feature! -- ["alert"] = true, - -- The volume of the audible beep, follows the JS format (0.0 - 1.0) - ["beep"] = 0.6, + -- The volume of the audible beep + ["beep"] = 0.6, + + -- The volume of the verbal lock confirmation + ["voice"] = 0.6, -- The speed unit used in conversions ["speedType"] = "mph" @@ -108,7 +111,8 @@ RADAR.vars = { displayText = { "¦¦¦", "FAS" }, optionsText = { "On¦", "Off" }, options = { true, false }, optionIndex = 1, settingText = "fastDisplay" }, { displayText = { "¦SL", "SEn" }, optionsText = { "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = 3, settingText = "same" }, { displayText = { "¦OP", "SEn" }, optionsText = { "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = 3, settingText = "opp" }, - { displayText = { "bEE", "P¦¦" }, optionsText = { "Off", "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = 4, settingText = "beep" }, + { displayText = { "bEE", "P¦¦" }, optionsText = { "Off", "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = 4, settingText = "beep" }, + { displayText = { "VOI", "CE¦" }, optionsText = { "Off", "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = 4, settingText = "voice" }, { displayText = { "Uni", "tS¦" }, optionsText = { "USA", "INT" }, options = { "mph", "kmh" }, optionIndex = 1, settingText = "speedType" } }, @@ -883,7 +887,9 @@ function RADAR:SetAntennaSpeedLock( ant, speed, dir, lockType ) self:SetAntennaSpeedIsLocked( ant, true ) -- Send a message to the NUI side to play the beep sound with the current volume setting - SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "beep" ) } ) + SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "beep" ) } ) + + SendNUIMessage( { _type = "lockAudio", ant = ant, dir = dir, vol = RADAR:GetSettingValue( "beep" ) } ) end end @@ -918,12 +924,10 @@ end function RADAR:LockAntennaSpeed( ant ) -- Only lock a speed if the antenna is on and the UI is displayed if ( self:IsPowerOn() and self:GetDisplayState() and not self:GetDisplayHidden() and self:IsAntennaTransmitting( ant ) ) then - -- Check if the antenna already has a speed locked, if it does then reset the lock, otherwise we lock - -- a speed - if ( self:IsAntennaSpeedLocked( ant ) ) then - self:ResetAntennaSpeedLock( ant ) - else - -- Set up a temporary table with 3 nil values, this way if the system isn't able to get a speed or + -- Check if the antenna doesn't have a locked speed, if it doesn't then we lock in the speed, otherwise we + -- reset the lock + if ( not self:IsAntennaSpeedLocked( ant ) ) then + -- Set up a temporary table with 3 nil values, this way if the system isn't able to get a speed or -- direction, the speed lock function won't work local data = { nil, nil, nil } @@ -940,12 +944,10 @@ function RADAR:LockAntennaSpeed( ant ) end -- Lock in the speed data for the antenna - self:SetAntennaSpeedLock( ant, data[1], data[2], data[3] ) + self:SetAntennaSpeedLock( ant, data[1], data[2], data[3] ) + else + self:ResetAntennaSpeedLock( ant ) end - - -- Attempt for fixing speed lock bugging every now and then, doesn't seem to happen as often - -- with this wait in place - -- Citizen.Wait( 10 ) -- Send an NUI message to change the lock label, otherwise we'd have to wait until the next main loop SendNUIMessage( { _type = "antennaLock", ant = ant, state = self:IsAntennaSpeedLocked( ant ) } ) diff --git a/docs/version.txt b/docs/version.txt index f741c92..e85d427 100644 --- a/docs/version.txt +++ b/docs/version.txt @@ -1 +1 @@ -beta2c \ No newline at end of file +beta2d \ No newline at end of file diff --git a/nui/radar.js b/nui/radar.js index 2c49210..15e6a8c 100644 --- a/nui/radar.js +++ b/nui/radar.js @@ -13,10 +13,30 @@ var resourceName; const audioNames = { + // Beeps beep: "beep.ogg", xmit_on: "xmit_on.ogg", xmit_off: "xmit_off.ogg", - done: "done.ogg" + done: "done.ogg", + + // Verbal lock + front: "front.ogg", + rear: "rear.ogg", + closing: "closing.ogg", + away: "away.ogg" +} + +const lockAudio = +{ + front: { + 1: "away", + 2: "closing" + }, + + rear: { + 1: "closing", + 2: "away" + } } // Setup the main const element structure, this way we can easily access elements without having the mess @@ -307,6 +327,18 @@ function playAudio( name, vol ) audio.play(); } +function playLockAudio( ant, dir, vol ) +{ + playAudio( ant, vol ); + + if ( dir > 0 ) + { + setTimeout( function() { + playAudio( lockAudio[ant][dir], vol ); + }, 500 ); + } +} + // This function is used to send data back through to the LUA side function sendData( name, data ) { $.post( "http://" + resourceName + "/" + name, JSON.stringify( data ), function( datab ) { @@ -445,7 +477,10 @@ window.addEventListener( "message", function( event ) { break; case "audio": playAudio( item.name, item.vol ); - break; + break; + case "lockAudio": + playLockAudio( item.ant, item.dir, item.vol ); + break; default: break; }