mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 08:26:27 +02:00
Added verbal lock confirmation
This commit is contained in:
@@ -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"
|
||||||
|
|
||||||
|
|||||||
32
cl_radar.lua
32
cl_radar.lua
@@ -93,8 +93,11 @@ 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"
|
||||||
@@ -108,7 +111,8 @@ RADAR.vars =
|
|||||||
{ displayText = { "¦¦¦", "FAS" }, optionsText = { "On¦", "Off" }, options = { true, false }, optionIndex = 1, settingText = "fastDisplay" },
|
{ 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 = { "¦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" }
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -883,7 +887,9 @@ function RADAR:SetAntennaSpeedLock( ant, speed, dir, lockType )
|
|||||||
self:SetAntennaSpeedIsLocked( ant, true )
|
self:SetAntennaSpeedIsLocked( ant, true )
|
||||||
|
|
||||||
-- 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,12 +924,10 @@ 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 )
|
-- Set up a temporary table with 3 nil values, this way if the system isn't able to get a speed or
|
||||||
else
|
|
||||||
-- 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 }
|
||||||
|
|
||||||
@@ -940,12 +944,10 @@ function RADAR:LockAntennaSpeed( ant )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- 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 ) } )
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
beta2c
|
beta2d
|
||||||
39
nui/radar.js
39
nui/radar.js
@@ -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 ) {
|
||||||
@@ -445,7 +477,10 @@ window.addEventListener( "message", function( event ) {
|
|||||||
break;
|
break;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user