Added verbal lock confirmation

This commit is contained in:
Dan
2019-12-20 17:24:49 +00:00
parent 6ae4d53d65
commit 9c90f16993
4 changed files with 56 additions and 19 deletions

View File

@@ -10,7 +10,7 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
name 'Wraith ARS 2X' name 'Wraith ARS 2X'
description 'An advanced radar system for FiveM' description 'An advanced radar system for FiveM'
author 'WolfKnight' author 'WolfKnight'
version 'beta2c' version 'beta2d'
ui_page "nui/radar.html" ui_page "nui/radar.html"

View File

@@ -93,9 +93,12 @@ RADAR.vars =
-- Future feature! -- Future feature!
-- ["alert"] = true, -- ["alert"] = true,
-- The volume of the audible beep, follows the JS format (0.0 - 1.0) -- The volume of the audible beep
["beep"] = 0.6, ["beep"] = 0.6,
-- The volume of the verbal lock confirmation
["voice"] = 0.6,
-- The speed unit used in conversions -- The speed unit used in conversions
["speedType"] = "mph" ["speedType"] = "mph"
}, },
@@ -109,6 +112,7 @@ RADAR.vars =
{ 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 = { "¦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 = { "¦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" } { displayText = { "Uni", "tS¦" }, optionsText = { "USA", "INT" }, options = { "mph", "kmh" }, optionIndex = 1, settingText = "speedType" }
}, },
@@ -884,6 +888,8 @@ function RADAR:SetAntennaSpeedLock( ant, speed, dir, lockType )
-- Send a message to the NUI side to play the beep sound with the current volume setting -- 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
end end
@@ -918,11 +924,9 @@ end
function RADAR:LockAntennaSpeed( ant ) function RADAR:LockAntennaSpeed( ant )
-- Only lock a speed if the antenna is on and the UI is displayed -- 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 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 -- Check if the antenna doesn't have a locked speed, if it doesn't then we lock in the speed, otherwise we
-- a speed -- reset the lock
if ( self:IsAntennaSpeedLocked( ant ) ) then if ( not 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 -- 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 -- direction, the speed lock function won't work
local data = { nil, nil, nil } local data = { nil, nil, nil }
@@ -941,12 +945,10 @@ function RADAR:LockAntennaSpeed( ant )
-- Lock in the speed data for the antenna -- 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 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 -- 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 ) } ) SendNUIMessage( { _type = "antennaLock", ant = ant, state = self:IsAntennaSpeedLocked( ant ) } )
SendNUIMessage( { _type = "antennaFast", ant = ant, state = self:ShouldFastBeDisplayed( ant ) } ) SendNUIMessage( { _type = "antennaFast", ant = ant, state = self:ShouldFastBeDisplayed( ant ) } )

View File

@@ -1 +1 @@
beta2c beta2d

View File

@@ -13,10 +13,30 @@ var resourceName;
const audioNames = const audioNames =
{ {
// Beeps
beep: "beep.ogg", beep: "beep.ogg",
xmit_on: "xmit_on.ogg", xmit_on: "xmit_on.ogg",
xmit_off: "xmit_off.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 // 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(); 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 // This function is used to send data back through to the LUA side
function sendData( name, data ) { function sendData( name, data ) {
$.post( "http://" + resourceName + "/" + name, JSON.stringify( data ), function( datab ) { $.post( "http://" + resourceName + "/" + name, JSON.stringify( data ), function( datab ) {
@@ -446,6 +478,9 @@ window.addEventListener( "message", function( event ) {
case "audio": case "audio":
playAudio( item.name, item.vol ); playAudio( item.name, item.vol );
break; break;
case "lockAudio":
playLockAudio( item.ant, item.dir, item.vol );
break;
default: default:
break; break;
} }