style: remove trailing spaces

This commit is contained in:
Dan
2021-03-02 10:14:21 +00:00
parent 9e346aa0f3
commit 508f94684e
9 changed files with 890 additions and 890 deletions

View File

@@ -2,10 +2,10 @@
Wraith ARS 2X Wraith ARS 2X
Created by WolfKnight Created by WolfKnight
For discussions, information on future updates, and more, join For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD my Discord: https://discord.gg/fD4e6WD
MIT License MIT License
Copyright (c) 2020-2021 WolfKnight Copyright (c) 2020-2021 WolfKnight
@@ -36,34 +36,34 @@ READER = {}
Plate reader variables Plate reader variables
NOTE - This is not a config, do not touch anything unless you know what NOTE - This is not a config, do not touch anything unless you know what
you are actually doing. you are actually doing.
----------------------------------------------------------------------------------]]-- ----------------------------------------------------------------------------------]]--
READER.vars = READER.vars =
{ {
-- Whether or not the plate reader's UI is visible -- Whether or not the plate reader's UI is visible
displayed = false, displayed = false,
-- Whether or not the plate reader should be hidden, e.g. the display is active but the player then steps -- Whether or not the plate reader should be hidden, e.g. the display is active but the player then steps
-- out of their vehicle -- out of their vehicle
hidden = false, hidden = false,
-- The BOLO plate -- The BOLO plate
boloPlate = "", boloPlate = "",
-- Cameras, this table contains all of the data needed for operation of the front and rear plate reader -- Cameras, this table contains all of the data needed for operation of the front and rear plate reader
cams = { cams = {
-- Variables for the front camera -- Variables for the front camera
["front"] = { ["front"] = {
plate = "", -- The current plate caught by the reader plate = "", -- The current plate caught by the reader
index = "", -- The index of the current plate index = "", -- The index of the current plate
locked = false -- If the reader is locked locked = false -- If the reader is locked
}, },
-- Variables for the rear camera -- Variables for the rear camera
["rear"] = { ["rear"] = {
plate = "", -- The current plate caught by the reader plate = "", -- The current plate caught by the reader
index = "", -- The index of the current plate index = "", -- The index of the current plate
locked = false -- If the reader is locked locked = false -- If the reader is locked
} }
} }
} }
@@ -71,143 +71,143 @@ READER.vars =
-- Gets the display state -- Gets the display state
function READER:GetDisplayState() function READER:GetDisplayState()
return self.vars.displayed return self.vars.displayed
end end
-- Toggles the display state of the plate reader system -- Toggles the display state of the plate reader system
function READER:ToggleDisplayState() function READER:ToggleDisplayState()
-- Toggle the display variable -- Toggle the display variable
self.vars.displayed = not self.vars.displayed self.vars.displayed = not self.vars.displayed
-- Send the toggle message to the NUI side -- Send the toggle message to the NUI side
SendNUIMessage( { _type = "setReaderDisplayState", state = self:GetDisplayState() } ) SendNUIMessage( { _type = "setReaderDisplayState", state = self:GetDisplayState() } )
end end
-- Sets the display's hidden state to the given state -- Sets the display's hidden state to the given state
function READER:SetDisplayHidden( state ) function READER:SetDisplayHidden( state )
self.vars.hidden = state self.vars.hidden = state
end end
-- Returns if the display is hidden -- Returns if the display is hidden
function READER:GetDisplayHidden() function READER:GetDisplayHidden()
return self.vars.hidden return self.vars.hidden
end end
-- Returns the stored plate for the given reader -- Returns the stored plate for the given reader
function READER:GetPlate( cam ) function READER:GetPlate( cam )
return self.vars.cams[cam].plate return self.vars.cams[cam].plate
end end
-- Sets the plate for the given reader to the given plate -- Sets the plate for the given reader to the given plate
function READER:SetPlate( cam, plate ) function READER:SetPlate( cam, plate )
self.vars.cams[cam].plate = plate self.vars.cams[cam].plate = plate
end end
-- Returns the stored plate index for the given reader -- Returns the stored plate index for the given reader
function READER:GetIndex( cam ) function READER:GetIndex( cam )
return self.vars.cams[cam].index return self.vars.cams[cam].index
end end
-- Sets the plate index for the given reader to the given index -- Sets the plate index for the given reader to the given index
function READER:SetIndex( cam, index ) function READER:SetIndex( cam, index )
self.vars.cams[cam].index = index self.vars.cams[cam].index = index
end end
-- Returns the bolo plate -- Returns the bolo plate
function READER:GetBoloPlate() function READER:GetBoloPlate()
if ( self.vars.boloPlate ~= nil ) then if ( self.vars.boloPlate ~= nil ) then
return self.vars.boloPlate return self.vars.boloPlate
end end
end end
-- Sets the bolo plate to the given plate -- Sets the bolo plate to the given plate
function READER:SetBoloPlate( plate ) function READER:SetBoloPlate( plate )
self.vars.boloPlate = plate self.vars.boloPlate = plate
UTIL:Notify( "BOLO plate set to: ~b~" .. plate ) UTIL:Notify( "BOLO plate set to: ~b~" .. plate )
end end
-- Clears the BOLO plate -- Clears the BOLO plate
function READER:ClearBoloPlate() function READER:ClearBoloPlate()
self.vars.boloPlate = nil self.vars.boloPlate = nil
UTIL:Notify( "~b~BOLO plate cleared!" ) UTIL:Notify( "~b~BOLO plate cleared!" )
end end
-- Returns if the given reader is locked -- Returns if the given reader is locked
function READER:GetCamLocked( cam ) function READER:GetCamLocked( cam )
return self.vars.cams[cam].locked return self.vars.cams[cam].locked
end end
-- Locks the given reader -- Locks the given reader
function READER:LockCam( cam, playBeep, isBolo ) function READER:LockCam( cam, playBeep, isBolo )
-- Check that plate readers can actually be locked -- Check that plate readers can actually be locked
if ( PLY:VehicleStateValid() and self:CanPerformMainTask() ) then if ( PLY:VehicleStateValid() and self:CanPerformMainTask() ) then
-- Toggle the lock state -- Toggle the lock state
self.vars.cams[cam].locked = not self.vars.cams[cam].locked self.vars.cams[cam].locked = not self.vars.cams[cam].locked
-- Tell the NUI side to show/hide the lock icon -- Tell the NUI side to show/hide the lock icon
SendNUIMessage( { _type = "lockPlate", cam = cam, state = self:GetCamLocked( cam ), isBolo = isBolo } ) SendNUIMessage( { _type = "lockPlate", cam = cam, state = self:GetCamLocked( cam ), isBolo = isBolo } )
-- Play a beep -- Play a beep
if ( self:GetCamLocked( cam ) ) then if ( self:GetCamLocked( cam ) ) then
if ( playBeep ) then if ( playBeep ) then
SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "plateAudio" ) } ) SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "plateAudio" ) } )
end end
if ( isBolo ) then if ( isBolo ) then
SendNUIMessage( { _type = "audio", name = "plate_hit", vol = RADAR:GetSettingValue( "plateAudio" ) } ) SendNUIMessage( { _type = "audio", name = "plate_hit", vol = RADAR:GetSettingValue( "plateAudio" ) } )
end end
-- Trigger an event so developers can hook into the scanner every time a plate is locked -- Trigger an event so developers can hook into the scanner every time a plate is locked
TriggerServerEvent( "wk:onPlateLocked", cam, self:GetPlate( cam ), self:GetIndex( cam ) ) TriggerServerEvent( "wk:onPlateLocked", cam, self:GetPlate( cam ), self:GetIndex( cam ) )
end end
end end
end end
-- Returns if the plate reader system can perform tasks -- Returns if the plate reader system can perform tasks
function READER:CanPerformMainTask() function READER:CanPerformMainTask()
return self.vars.displayed and not self.vars.hidden return self.vars.displayed and not self.vars.hidden
end end
-- Returns if the given relative position value is for front or rear -- Returns if the given relative position value is for front or rear
function READER:GetCamFromNum( relPos ) function READER:GetCamFromNum( relPos )
if ( relPos == 1 ) then if ( relPos == 1 ) then
return "front" return "front"
elseif ( relPos == -1 ) then elseif ( relPos == -1 ) then
return "rear" return "rear"
end end
end end
RegisterNetEvent( "wk:togglePlateLock" ) RegisterNetEvent( "wk:togglePlateLock" )
AddEventHandler( "wk:togglePlateLock", function( cam, beep, bolo ) AddEventHandler( "wk:togglePlateLock", function( cam, beep, bolo )
READER:LockCam( cam, beep, bolo ) READER:LockCam( cam, beep, bolo )
end ) end )
-- Runs when the "Toggle Display" button is pressed on the plate reder box -- Runs when the "Toggle Display" button is pressed on the plate reder box
RegisterNUICallback( "togglePlateReaderDisplay", function( data, cb ) RegisterNUICallback( "togglePlateReaderDisplay", function( data, cb )
-- Toggle the display state -- Toggle the display state
READER:ToggleDisplayState() READER:ToggleDisplayState()
cb( "ok" ) cb( "ok" )
end ) end )
-- Runs when the "Set BOLO Plate" button is pressed on the plate reader box -- Runs when the "Set BOLO Plate" button is pressed on the plate reader box
RegisterNUICallback( "setBoloPlate", function( plate, cb ) RegisterNUICallback( "setBoloPlate", function( plate, cb )
-- Set the BOLO plate -- Set the BOLO plate
READER:SetBoloPlate( plate ) READER:SetBoloPlate( plate )
cb( "ok" ) cb( "ok" )
end ) end )
-- Runs when the "Clear BOLO Plate" button is pressed on the plate reader box -- Runs when the "Clear BOLO Plate" button is pressed on the plate reader box
RegisterNUICallback( "clearBoloPlate", function( plate, cb ) RegisterNUICallback( "clearBoloPlate", function( plate, cb )
-- Clear the BOLO plate -- Clear the BOLO plate
READER:ClearBoloPlate() READER:ClearBoloPlate()
cb( "ok" ) cb( "ok" )
end ) end )
-- This is the main function that runs and scans all vehicles in front and behind the patrol vehicle -- This is the main function that runs and scans all vehicles in front and behind the patrol vehicle
function READER:Main() function READER:Main()
-- Check that the system can actually run -- Check that the system can actually run
if ( PLY:VehicleStateValid() and self:CanPerformMainTask() ) then if ( PLY:VehicleStateValid() and self:CanPerformMainTask() ) then
-- Loop through front (1) and rear (-1) -- Loop through front (1) and rear (-1)
for i = 1, -1, -2 do for i = 1, -1, -2 do
-- Get the world position of the player's vehicle -- Get the world position of the player's vehicle
local pos = GetEntityCoords( PLY.veh ) local pos = GetEntityCoords( PLY.veh )
@@ -217,14 +217,14 @@ function READER:Main()
-- Get the end position 50m in front/behind the player's vehicle -- Get the end position 50m in front/behind the player's vehicle
local offset = GetOffsetFromEntityInWorldCoords( PLY.veh, -2.5, ( 50.0 * i ), 0.0 ) local offset = GetOffsetFromEntityInWorldCoords( PLY.veh, -2.5, ( 50.0 * i ), 0.0 )
-- Run the ray trace to get a vehicle -- Run the ray trace to get a vehicle
local veh = UTIL:GetVehicleInDirection( PLY.veh, start, offset ) local veh = UTIL:GetVehicleInDirection( PLY.veh, start, offset )
-- Get the plate reader text for front/rear -- Get the plate reader text for front/rear
local cam = self:GetCamFromNum( i ) local cam = self:GetCamFromNum( i )
-- Only proceed to read a plate if the hit entity is a valid vehicle and the current camera isn't locked -- Only proceed to read a plate if the hit entity is a valid vehicle and the current camera isn't locked
if ( DoesEntityExist( veh ) and IsEntityAVehicle( veh ) and not self:GetCamLocked( cam ) ) then if ( DoesEntityExist( veh ) and IsEntityAVehicle( veh ) and not self:GetCamLocked( cam ) ) then
-- Get the heading of the player's vehicle and the hit vehicle -- Get the heading of the player's vehicle and the hit vehicle
local ownH = UTIL:Round( GetEntityHeading( PLY.veh ), 0 ) local ownH = UTIL:Round( GetEntityHeading( PLY.veh ), 0 )
local tarH = UTIL:Round( GetEntityHeading( veh ), 0 ) local tarH = UTIL:Round( GetEntityHeading( veh ), 0 )
@@ -233,16 +233,16 @@ function READER:Main()
local dir = UTIL:GetEntityRelativeDirection( ownH, tarH ) local dir = UTIL:GetEntityRelativeDirection( ownH, tarH )
-- Only run the rest of the plate check code if we can see the front or rear of the vehicle -- Only run the rest of the plate check code if we can see the front or rear of the vehicle
if ( dir > 0 ) then if ( dir > 0 ) then
-- Get the licence plate text from the vehicle -- Get the licence plate text from the vehicle
local plate = GetVehicleNumberPlateText( veh ) local plate = GetVehicleNumberPlateText( veh )
-- Get the licence plate index from the vehicle -- Get the licence plate index from the vehicle
local index = GetVehicleNumberPlateTextIndex( veh ) local index = GetVehicleNumberPlateTextIndex( veh )
-- Only update the stored plate if it's different, otherwise we'd keep sending a NUI message to update the displayed -- Only update the stored plate if it's different, otherwise we'd keep sending a NUI message to update the displayed
-- plate and image even though they're the same -- plate and image even though they're the same
if ( self:GetPlate( cam ) ~= plate ) then if ( self:GetPlate( cam ) ~= plate ) then
-- Set the plate for the current reader -- Set the plate for the current reader
self:SetPlate( cam, plate ) self:SetPlate( cam, plate )
@@ -250,24 +250,24 @@ function READER:Main()
self:SetIndex( cam, index ) self:SetIndex( cam, index )
-- Automatically lock the plate if the scanned plate matches the BOLO -- Automatically lock the plate if the scanned plate matches the BOLO
if ( plate == self:GetBoloPlate() ) then if ( plate == self:GetBoloPlate() ) then
self:LockCam( cam, false, true ) self:LockCam( cam, false, true )
end end
-- Send the plate information to the NUI side to update the UI -- Send the plate information to the NUI side to update the UI
SendNUIMessage( { _type = "changePlate", cam = cam, plate = plate, index = index } ) SendNUIMessage( { _type = "changePlate", cam = cam, plate = plate, index = index } )
-- If we use Sonoran CAD, reduce the plate events to just player's vehicle, otherwise life as normal -- If we use Sonoran CAD, reduce the plate events to just player's vehicle, otherwise life as normal
if ( ( CONFIG.use_sonorancad and ( UTIL:IsPlayerInVeh( veh ) or IsVehiclePreviouslyOwnedByPlayer( veh ) ) and GetVehicleClass( veh ) ~= 18 ) or not CONFIG.use_sonorancad ) then if ( ( CONFIG.use_sonorancad and ( UTIL:IsPlayerInVeh( veh ) or IsVehiclePreviouslyOwnedByPlayer( veh ) ) and GetVehicleClass( veh ) ~= 18 ) or not CONFIG.use_sonorancad ) then
-- Trigger the event so developers can hook into the scanner every time a plate is scanned -- Trigger the event so developers can hook into the scanner every time a plate is scanned
TriggerServerEvent( "wk:onPlateScanned", cam, plate, index ) TriggerServerEvent( "wk:onPlateScanned", cam, plate, index )
end end
end end
end end
end end
end end
end end
end end
-- Main thread -- Main thread
Citizen.CreateThread( function() Citizen.CreateThread( function()
@@ -277,31 +277,31 @@ Citizen.CreateThread( function()
-- Wait half a second -- Wait half a second
Citizen.Wait( 500 ) Citizen.Wait( 500 )
end end
end ) end )
-- This function is pretty much straight from WraithRS, it does the job so I didn't see the point in not -- This function is pretty much straight from WraithRS, it does the job so I didn't see the point in not
-- using it. Hides the radar UI when certain criteria is met, e.g. in pause menu or stepped out ot the -- using it. Hides the radar UI when certain criteria is met, e.g. in pause menu or stepped out ot the
-- patrol vehicle -- patrol vehicle
function READER:RunDisplayValidationCheck() function READER:RunDisplayValidationCheck()
if ( ( ( PLY.veh == 0 or ( PLY.veh > 0 and not PLY.vehClassValid ) ) and self:GetDisplayState() and not self:GetDisplayHidden() ) or IsPauseMenuActive() and self:GetDisplayState() ) then if ( ( ( PLY.veh == 0 or ( PLY.veh > 0 and not PLY.vehClassValid ) ) and self:GetDisplayState() and not self:GetDisplayHidden() ) or IsPauseMenuActive() and self:GetDisplayState() ) then
self:SetDisplayHidden( true ) self:SetDisplayHidden( true )
SendNUIMessage( { _type = "setReaderDisplayState", state = false } ) SendNUIMessage( { _type = "setReaderDisplayState", state = false } )
elseif ( PLY:CanViewRadar() and self:GetDisplayState() and self:GetDisplayHidden() ) then elseif ( PLY:CanViewRadar() and self:GetDisplayState() and self:GetDisplayHidden() ) then
self:SetDisplayHidden( false ) self:SetDisplayHidden( false )
SendNUIMessage( { _type = "setReaderDisplayState", state = true } ) SendNUIMessage( { _type = "setReaderDisplayState", state = true } )
end end
end end
-- Runs the display validation check for the radar -- Runs the display validation check for the radar
Citizen.CreateThread( function() Citizen.CreateThread( function()
Citizen.Wait( 100 ) Citizen.Wait( 100 )
while ( true ) do while ( true ) do
-- Run the check -- Run the check
READER:RunDisplayValidationCheck() READER:RunDisplayValidationCheck()
-- Wait half a second -- Wait half a second
Citizen.Wait( 500 ) Citizen.Wait( 500 )
end end
end ) end )

View File

@@ -2,10 +2,10 @@
Wraith ARS 2X Wraith ARS 2X
Created by WolfKnight Created by WolfKnight
For discussions, information on future updates, and more, join For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD my Discord: https://discord.gg/fD4e6WD
MIT License MIT License
Copyright (c) 2020-2021 WolfKnight Copyright (c) 2020-2021 WolfKnight
@@ -33,62 +33,62 @@
--[[---------------------------------------------------------------------------------- --[[----------------------------------------------------------------------------------
Player info variables Player info variables
----------------------------------------------------------------------------------]]-- ----------------------------------------------------------------------------------]]--
PLY = PLY =
{ {
ped = PlayerPedId(), ped = PlayerPedId(),
veh = nil, veh = nil,
inDriverSeat = false, inDriverSeat = false,
inPassengerSeat = false, inPassengerSeat = false,
vehClassValid = false vehClassValid = false
} }
function PLY:VehicleStateValid() function PLY:VehicleStateValid()
return DoesEntityExist( self.veh ) and self.veh > 0 and self.vehClassValid return DoesEntityExist( self.veh ) and self.veh > 0 and self.vehClassValid
end end
-- Used to check if the player is in a position where the radar should be allowed operation -- Used to check if the player is in a position where the radar should be allowed operation
function PLY:IsDriver() function PLY:IsDriver()
return self:VehicleStateValid() and self.inDriverSeat return self:VehicleStateValid() and self.inDriverSeat
end end
-- Returns if the player is in the front passenger seat of an emergency vehicle -- Returns if the player is in the front passenger seat of an emergency vehicle
function PLY:IsPassenger() function PLY:IsPassenger()
return self:VehicleStateValid() and self.inPassengerSeat return self:VehicleStateValid() and self.inPassengerSeat
end end
-- Returns if the player can view the radar, ensures their vehicle state is valid and that they are a driver or -- Returns if the player can view the radar, ensures their vehicle state is valid and that they are a driver or
-- a passenger (where valid) -- a passenger (where valid)
function PLY:CanViewRadar() function PLY:CanViewRadar()
return self:IsDriver() or ( self:IsPassenger() and RADAR:IsPassengerViewAllowed() ) return self:IsDriver() or ( self:IsPassenger() and RADAR:IsPassengerViewAllowed() )
end end
-- Returns if the player is allowed to control the radar from the passenger seat -- Returns if the player is allowed to control the radar from the passenger seat
function PLY:CanControlRadar() function PLY:CanControlRadar()
return self:IsDriver() or ( self:IsPassenger() and RADAR:IsPassengerControlAllowed() ) return self:IsDriver() or ( self:IsPassenger() and RADAR:IsPassengerControlAllowed() )
end end
-- Returns the ped in the opposite seat to the player, e.g. if we're the passenger, then return the driver -- Returns the ped in the opposite seat to the player, e.g. if we're the passenger, then return the driver
function PLY:GetOtherPed() function PLY:GetOtherPed()
if ( self:IsDriver() ) then if ( self:IsDriver() ) then
return GetPedInVehicleSeat( PLY.veh, 0 ) return GetPedInVehicleSeat( PLY.veh, 0 )
elseif ( self:IsPassenger() ) then elseif ( self:IsPassenger() ) then
return GetPedInVehicleSeat( PLY.veh, -1 ) return GetPedInVehicleSeat( PLY.veh, -1 )
end end
return nil return nil
end end
-- The main purpose of this thread is to update the information about the local player, including their -- The main purpose of this thread is to update the information about the local player, including their
-- ped id, the vehicle id (if they're in one), whether they're in a driver seat, and if the vehicle's class -- ped id, the vehicle id (if they're in one), whether they're in a driver seat, and if the vehicle's class
-- is valid or not -- is valid or not
Citizen.CreateThread( function() Citizen.CreateThread( function()
while ( true ) do while ( true ) do
PLY.ped = PlayerPedId() PLY.ped = PlayerPedId()
PLY.veh = GetVehiclePedIsIn( PLY.ped, false ) PLY.veh = GetVehiclePedIsIn( PLY.ped, false )
PLY.inDriverSeat = GetPedInVehicleSeat( PLY.veh, -1 ) == PLY.ped PLY.inDriverSeat = GetPedInVehicleSeat( PLY.veh, -1 ) == PLY.ped
PLY.inPassengerSeat = GetPedInVehicleSeat( PLY.veh, 0 ) == PLY.ped PLY.inPassengerSeat = GetPedInVehicleSeat( PLY.veh, 0 ) == PLY.ped
PLY.vehClassValid = GetVehicleClass( PLY.veh ) == 18 PLY.vehClassValid = GetVehicleClass( PLY.veh ) == 18
Citizen.Wait( 500 ) Citizen.Wait( 500 )
end end
end ) end )

File diff suppressed because it is too large Load Diff

View File

@@ -2,10 +2,10 @@
Wraith ARS 2X Wraith ARS 2X
Created by WolfKnight Created by WolfKnight
For discussions, information on future updates, and more, join For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD my Discord: https://discord.gg/fD4e6WD
MIT License MIT License
Copyright (c) 2020-2021 WolfKnight Copyright (c) 2020-2021 WolfKnight
@@ -34,35 +34,35 @@ SYNC = {}
--[[---------------------------------------------------------------------------------- --[[----------------------------------------------------------------------------------
Sync functions Sync functions
----------------------------------------------------------------------------------]]-- ----------------------------------------------------------------------------------]]--
function SYNC:SyncData( cb ) function SYNC:SyncData( cb )
local otherPed = PLY:GetOtherPed() local otherPed = PLY:GetOtherPed()
if ( otherPed ~= nil and otherPed ~= 0 ) then if ( otherPed ~= nil and otherPed ~= 0 ) then
local otherPly = GetPlayerServerId( NetworkGetPlayerIndexFromPed( otherPed ) ) local otherPly = GetPlayerServerId( NetworkGetPlayerIndexFromPed( otherPed ) )
cb( otherPly ) cb( otherPly )
end end
end end
function SYNC:SendPowerState( state ) function SYNC:SendPowerState( state )
self:SyncData( function( ply ) self:SyncData( function( ply )
TriggerServerEvent( "wk_wars2x_sync:sendPowerState", ply, state ) TriggerServerEvent( "wk_wars2x_sync:sendPowerState", ply, state )
end ) end )
end end
function SYNC:SendAntennaPowerState( state, ant ) function SYNC:SendAntennaPowerState( state, ant )
self:SyncData( function( ply ) self:SyncData( function( ply )
TriggerServerEvent( "wk_wars2x_sync:sendAntennaPowerState", ply, state, ant ) TriggerServerEvent( "wk_wars2x_sync:sendAntennaPowerState", ply, state, ant )
end ) end )
end end
function SYNC:SendAntennaMode( ant, mode ) function SYNC:SendAntennaMode( ant, mode )
self:SyncData( function( ply ) self:SyncData( function( ply )
TriggerServerEvent( "wk_wars2x_sync:sendAntennaMode", ply, ant, mode ) TriggerServerEvent( "wk_wars2x_sync:sendAntennaMode", ply, ant, mode )
end ) end )
end end
--[[---------------------------------------------------------------------------------- --[[----------------------------------------------------------------------------------
@@ -72,35 +72,35 @@ RegisterNetEvent( "wk_wars2x_sync:receivePowerState" )
AddEventHandler( "wk_wars2x_sync:receivePowerState", function( state ) AddEventHandler( "wk_wars2x_sync:receivePowerState", function( state )
local power = RADAR:IsPowerOn() local power = RADAR:IsPowerOn()
if ( power ~= state ) then if ( power ~= state ) then
Citizen.SetTimeout( 100, function() Citizen.SetTimeout( 100, function()
RADAR:TogglePower() RADAR:TogglePower()
end ) end )
end end
end ) end )
RegisterNetEvent( "wk_wars2x_sync:receiveAntennaPowerState" ) RegisterNetEvent( "wk_wars2x_sync:receiveAntennaPowerState" )
AddEventHandler( "wk_wars2x_sync:receiveAntennaPowerState", function( state, antenna ) AddEventHandler( "wk_wars2x_sync:receiveAntennaPowerState", function( state, antenna )
local power = RADAR:IsAntennaTransmitting( antenna ) local power = RADAR:IsAntennaTransmitting( antenna )
if ( power ~= state ) then if ( power ~= state ) then
RADAR:ToggleAntenna( antenna, function() RADAR:ToggleAntenna( antenna, function()
-- Update the interface with the new antenna transmit state -- Update the interface with the new antenna transmit state
SendNUIMessage( { _type = "antennaXmit", ant = antenna, on = state } ) SendNUIMessage( { _type = "antennaXmit", ant = antenna, on = state } )
-- Play some audio specific to the transmit state -- Play some audio specific to the transmit state
SendNUIMessage( { _type = "audio", name = state and "xmit_on" or "xmit_off", vol = RADAR:GetSettingValue( "beep" ) } ) SendNUIMessage( { _type = "audio", name = state and "xmit_on" or "xmit_off", vol = RADAR:GetSettingValue( "beep" ) } )
end ) end )
end end
end ) end )
RegisterNetEvent( "wk_wars2x_sync:receiveAntennaMode" ) RegisterNetEvent( "wk_wars2x_sync:receiveAntennaMode" )
AddEventHandler( "wk_wars2x_sync:receiveAntennaMode", function( antenna, mode ) AddEventHandler( "wk_wars2x_sync:receiveAntennaMode", function( antenna, mode )
RADAR:SetAntennaMode( antenna, mode, function() RADAR:SetAntennaMode( antenna, mode, function()
-- Update the interface with the new mode -- Update the interface with the new mode
SendNUIMessage( { _type = "antennaMode", ant = antenna, mode = mode } ) SendNUIMessage( { _type = "antennaMode", ant = antenna, mode = mode } )
-- Play a beep -- Play a beep
SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "beep" ) } ) SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "beep" ) } )
end ) end )
end ) end )

View File

@@ -1,4 +1,4 @@
if ( CONFIG.debug ) then if ( CONFIG.debug ) then
-- Restart the resource -- Restart the resource
RegisterCommand( "rre", function( source, args, rawCommand ) RegisterCommand( "rre", function( source, args, rawCommand )
UTIL:Notify( "[DEBUG]: Restarting resource" ) UTIL:Notify( "[DEBUG]: Restarting resource" )

View File

@@ -2,10 +2,10 @@
Wraith ARS 2X Wraith ARS 2X
Created by WolfKnight Created by WolfKnight
For discussions, information on future updates, and more, join For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD my Discord: https://discord.gg/fD4e6WD
MIT License MIT License
Copyright (c) 2020-2021 WolfKnight Copyright (c) 2020-2021 WolfKnight
@@ -35,49 +35,49 @@ UTIL = {}
-- Returns a number to a set number of decimal places -- Returns a number to a set number of decimal places
function UTIL:Round( num, numDecimalPlaces ) function UTIL:Round( num, numDecimalPlaces )
return tonumber( string.format( "%." .. ( numDecimalPlaces or 0 ) .. "f", num ) ) return tonumber( string.format( "%." .. ( numDecimalPlaces or 0 ) .. "f", num ) )
end end
-- The custom font used for the digital displays have the ¦ symbol as an empty character, this function -- The custom font used for the digital displays have the ¦ symbol as an empty character, this function
-- takes a speed and returns a formatted speed that can be displayed on the radar -- takes a speed and returns a formatted speed that can be displayed on the radar
function UTIL:FormatSpeed( speed ) function UTIL:FormatSpeed( speed )
-- Return "Err" (Error) if the given speed is outside the 0-999 range -- Return "Err" (Error) if the given speed is outside the 0-999 range
if ( speed < 0 or speed > 999 ) then return "Err" end if ( speed < 0 or speed > 999 ) then return "Err" end
-- Convert the speed to a string -- Convert the speed to a string
local text = tostring( speed ) local text = tostring( speed )
local pipes = "" local pipes = ""
-- Create a string of pipes (¦) for the number of spaces -- Create a string of pipes (¦) for the number of spaces
for i = 1, 3 - string.len( text ) do for i = 1, 3 - string.len( text ) do
pipes = pipes .. "¦" pipes = pipes .. "¦"
end end
-- Return the formatted speed -- Return the formatted speed
return pipes .. text return pipes .. text
end end
-- Returns a clamped numerical value based on the given parameters -- Returns a clamped numerical value based on the given parameters
function UTIL:Clamp( val, min, max ) function UTIL:Clamp( val, min, max )
-- Return the min value if the given value is less than the min -- Return the min value if the given value is less than the min
if ( val < min ) then if ( val < min ) then
return min return min
-- Return the max value if the given value is larger than the max -- Return the max value if the given value is larger than the max
elseif ( val > max ) then elseif ( val > max ) then
return max return max
end end
-- Return the given value if it's between the min and max -- Return the given value if it's between the min and max
return val return val
end end
-- Returns if the given table is empty, includes numerical and non-numerical key values -- Returns if the given table is empty, includes numerical and non-numerical key values
function UTIL:IsTableEmpty( t ) function UTIL:IsTableEmpty( t )
local c = 0 local c = 0
for _ in pairs( t ) do c = c + 1 end for _ in pairs( t ) do c = c + 1 end
return c == 0 return c == 0
end end
-- Credit to Deltanic for this function -- Credit to Deltanic for this function
function UTIL:Values( xs ) function UTIL:Values( xs )
@@ -96,16 +96,16 @@ function UTIL:GetVehicleInDirection( entFrom, coordFrom, coordTo )
return vehicle return vehicle
end end
-- Returns if a target vehicle is coming towards or going away from the patrol vehicle, it has a range -- Returns if a target vehicle is coming towards or going away from the patrol vehicle, it has a range
-- so if a vehicle is sideways compared to the patrol vehicle, the directional arrows won't light up -- so if a vehicle is sideways compared to the patrol vehicle, the directional arrows won't light up
function UTIL:GetEntityRelativeDirection( myAng, tarAng ) function UTIL:GetEntityRelativeDirection( myAng, tarAng )
local angleDiff = math.abs( ( myAng - tarAng + 180 ) % 360 - 180 ) local angleDiff = math.abs( ( myAng - tarAng + 180 ) % 360 - 180 )
if ( angleDiff < 45 ) then if ( angleDiff < 45 ) then
return 1 return 1
elseif ( angleDiff > 135 ) then elseif ( angleDiff > 135 ) then
return 2 return 2
end end
return 0 return 0
end end
@@ -115,15 +115,15 @@ function UTIL:IsPlayerInVeh( veh )
for i = -1, GetVehicleMaxNumberOfPassengers( veh ) + 1, 1 do for i = -1, GetVehicleMaxNumberOfPassengers( veh ) + 1, 1 do
local ped = GetPedInVehicleSeat( veh, i ) local ped = GetPedInVehicleSeat( veh, i )
if ( DoesEntityExist( ped ) ) then if ( DoesEntityExist( ped ) ) then
if ( IsPedAPlayer( ped ) ) then return true end if ( IsPedAPlayer( ped ) ) then return true end
end end
end end
return false return false
end end
-- Your everyday GTA notification function -- Your everyday GTA notification function
function UTIL:Notify( text ) function UTIL:Notify( text )
SetNotificationTextEntry( "STRING" ) SetNotificationTextEntry( "STRING" )
AddTextComponentSubstringPlayerName( text ) AddTextComponentSubstringPlayerName( text )
@@ -132,7 +132,7 @@ end
function UTIL:Log( msg ) function UTIL:Log( msg )
print( "[Wraith ARS 2X]: " .. msg ) print( "[Wraith ARS 2X]: " .. msg )
end end
function UTIL:DrawDebugText( x, y, scale, centre, text ) function UTIL:DrawDebugText( x, y, scale, centre, text )
SetTextFont( 4 ) SetTextFont( 4 )
@@ -151,7 +151,7 @@ end
function UTIL:IsResourceNameValid() function UTIL:IsResourceNameValid()
return GetCurrentResourceName() == "wk_wars2x" return GetCurrentResourceName() == "wk_wars2x"
end end
--[[The MIT License (MIT) --[[The MIT License (MIT)

View File

@@ -2,10 +2,10 @@
Wraith ARS 2X Wraith ARS 2X
Created by WolfKnight Created by WolfKnight
For discussions, information on future updates, and more, join For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD my Discord: https://discord.gg/fD4e6WD
MIT License MIT License
Copyright (c) 2020-2021 WolfKnight Copyright (c) 2020-2021 WolfKnight
@@ -37,39 +37,39 @@ CONFIG = {}
CONFIG.debug = true CONFIG.debug = true
-- Radar fast limit locking -- Radar fast limit locking
-- When enabled, the player will be able to define a fast limit within the radar's menu, when a vehicle -- 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 -- exceeds the fast limit, it will be locked into the fast box. Default setting is disabled to maintain realism
CONFIG.allow_fast_limit = true CONFIG.allow_fast_limit = true
-- Radar only lock playersw with auto fast locking -- Radar only lock playersw with auto fast locking
-- When enabled, the radar will only automatically lock a speed if the caught vehicle has a real player in it. -- When enabled, the radar will only automatically lock a speed if the caught vehicle has a real player in it.
CONFIG.only_lock_players = false CONFIG.only_lock_players = false
-- In-game first time quick start video -- In-game first time quick start video
-- When enabled, the player will be asked if they'd like to view the quick start video the first time they -- When enabled, the player will be asked if they'd like to view the quick start video the first time they
-- open the remote. -- open the remote.
CONFIG.allow_quick_start_video = true CONFIG.allow_quick_start_video = true
-- Allow passenger view -- Allow passenger view
-- When enabled, the front seat passenger will be able to view the radar and plate reader from their end. -- When enabled, the front seat passenger will be able to view the radar and plate reader from their end.
CONFIG.allow_passenger_view = true CONFIG.allow_passenger_view = true
-- Allow passenger control -- Allow passenger control
-- Dependent on CONFIG.allow_passenger_view. When enabled, the front seat passenger will be able to open the -- Dependent on CONFIG.allow_passenger_view. When enabled, the front seat passenger will be able to open the
-- radar remote and control the radar and plate reader for themself and the driver. -- radar remote and control the radar and plate reader for themself and the driver.
CONFIG.allow_passenger_control = false CONFIG.allow_passenger_control = false
-- Set this to true if you use Sonoran CAD with the WraithV2 plugin -- Set this to true if you use Sonoran CAD with the WraithV2 plugin
CONFIG.use_sonorancad = false CONFIG.use_sonorancad = false
-- Sets the defaults of all keybinds -- Sets the defaults of all keybinds
-- These keybinds can be changed by each person in their GTA Settings->Keybinds->FiveM -- These keybinds can be changed by each person in their GTA Settings->Keybinds->FiveM
CONFIG.keyDefaults = CONFIG.keyDefaults =
{ {
-- Remote control key -- Remote control key
remote_control = "f5", remote_control = "f5",
-- Radar key lock key -- Radar key lock key
key_lock = "l", key_lock = "l",
-- Radar front antenna lock/unlock Key -- Radar front antenna lock/unlock Key
@@ -86,32 +86,32 @@ CONFIG.keyDefaults =
} }
-- Here you can change the default values for the operator menu, do note, if any of these values are not -- Here you can change the default values for the operator menu, do note, if any of these values are not
-- one of the options listed, the script will not work. -- one of the options listed, the script will not work.
CONFIG.menuDefaults = CONFIG.menuDefaults =
{ {
-- Should the system calculate and display faster targets -- Should the system calculate and display faster targets
-- Options: true or false -- Options: true or false
["fastDisplay"] = true, ["fastDisplay"] = true,
-- Sensitivity for each radar mode, this changes how far the antennas will detect vehicles -- Sensitivity for each radar mode, this changes how far the antennas will detect vehicles
-- Options: 0.2, 0.4, 0.6, 0.8, 1.0 -- Options: 0.2, 0.4, 0.6, 0.8, 1.0
["same"] = 0.6, ["same"] = 0.6,
["opp"] = 0.6, ["opp"] = 0.6,
-- The volume of the audible beep -- The volume of the audible beep
-- Options: 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 -- Options: 0.0, 0.2, 0.4, 0.6, 0.8, 1.0
["beep"] = 0.6, ["beep"] = 0.6,
-- The volume of the verbal lock confirmation -- The volume of the verbal lock confirmation
-- Options: 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 -- Options: 0.0, 0.2, 0.4, 0.6, 0.8, 1.0
["voice"] = 0.6, ["voice"] = 0.6,
-- The volume of the plate reader audio -- The volume of the plate reader audio
-- Options: 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 -- Options: 0.0, 0.2, 0.4, 0.6, 0.8, 1.0
["plateAudio"] = 0.6, ["plateAudio"] = 0.6,
-- The speed unit used in conversions -- The speed unit used in conversions
-- Options: mph or kmh -- Options: mph or kmh
["speedType"] = "mph" ["speedType"] = "mph"
} }
@@ -122,12 +122,12 @@ CONFIG.uiDefaults =
-- Options: 0.25 - 2.5 -- Options: 0.25 - 2.5
scale = scale =
{ {
radar = 1.0, radar = 1.0,
remote = 1.0, remote = 1.0,
plateReader = 1.0 plateReader = 1.0
}, },
-- The safezone size, must be a multiple of 5. -- The safezone size, must be a multiple of 5.
-- Options: 0 - 100 -- Options: 0 - 100
safezone = 20 safezone = 20
} }

View File

@@ -2,10 +2,10 @@
Wraith ARS 2X Wraith ARS 2X
Created by WolfKnight Created by WolfKnight
For discussions, information on future updates, and more, join For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD my Discord: https://discord.gg/fD4e6WD
MIT License MIT License
Copyright (c) 2020-2021 WolfKnight Copyright (c) 2020-2021 WolfKnight
@@ -42,9 +42,9 @@ version "beta"
-- Include the files -- Include the files
files { files {
"nui/radar.html", "nui/radar.html",
"nui/radar.css", "nui/radar.css",
"nui/jquery-3.4.1.min.js", "nui/jquery-3.4.1.min.js",
"nui/radar.js", "nui/radar.js",
"nui/images/*.png", "nui/images/*.png",
"nui/images/plates/*.png", "nui/images/plates/*.png",

View File

@@ -2,10 +2,10 @@
Wraith ARS 2X Wraith ARS 2X
Created by WolfKnight Created by WolfKnight
For discussions, information on future updates, and more, join For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD my Discord: https://discord.gg/fD4e6WD
MIT License MIT License
Copyright (c) 2020-2021 WolfKnight Copyright (c) 2020-2021 WolfKnight
@@ -31,7 +31,7 @@
---------------------------------------------------------------------------------------]]-- ---------------------------------------------------------------------------------------]]--
-- Branding! -- Branding!
local label = local label =
[[ [[
// //
|| __ __ _ _ _ _____ _____ ___ __ __ || __ __ _ _ _ _____ _____ ___ __ __
@@ -47,37 +47,37 @@ local label =
-- Returns the current version set in fxmanifest.lua -- Returns the current version set in fxmanifest.lua
function GetCurrentVersion() function GetCurrentVersion()
return GetResourceMetadata( GetCurrentResourceName(), "version" ) return GetResourceMetadata( GetCurrentResourceName(), "version" )
end end
-- Grabs the latest version number from the web GitHub -- Grabs the latest version number from the web GitHub
PerformHttpRequest( "https://wolfknight98.github.io/wk_wars2x_web/version.txt", function( err, text, headers ) PerformHttpRequest( "https://wolfknight98.github.io/wk_wars2x_web/version.txt", function( err, text, headers )
-- Wait to reduce spam -- Wait to reduce spam
Citizen.Wait( 2000 ) Citizen.Wait( 2000 )
-- Print the branding! -- Print the branding!
print( label ) print( label )
-- Get the current resource version -- Get the current resource version
local curVer = GetCurrentVersion() local curVer = GetCurrentVersion()
if ( text ~= nil ) then if ( text ~= nil ) then
-- Print out the current and latest version -- Print out the current and latest version
print( " || Current version: " .. curVer ) print( " || Current version: " .. curVer )
print( " || Latest recommended version: " .. text .."\n ||" ) print( " || Latest recommended version: " .. text .."\n ||" )
-- If the versions are different, print it out -- If the versions are different, print it out
if ( text ~= curVer ) then if ( text ~= curVer ) then
print( " || ^1Your Wraith ARS 2X version is outdated, visit the FiveM forum post to get the latest version.\n^0 \\\\\n" ) print( " || ^1Your Wraith ARS 2X version is outdated, visit the FiveM forum post to get the latest version.\n^0 \\\\\n" )
else else
print( " || ^2Wraith ARS 2X is up to date!\n^0 ||\n \\\\\n" ) print( " || ^2Wraith ARS 2X is up to date!\n^0 ||\n \\\\\n" )
end end
else else
-- In case the version can not be requested, print out an error message -- In case the version can not be requested, print out an error message
print( " || ^1There was an error getting the latest version information, if the issue persists contact WolfKnight#8586 on Discord.\n^0 ||\n \\\\\n" ) print( " || ^1There was an error getting the latest version information, if the issue persists contact WolfKnight#8586 on Discord.\n^0 ||\n \\\\\n" )
end end
-- Warn the console if the resource has been renamed, as this will cause issues with the resource's functionality. -- Warn the console if the resource has been renamed, as this will cause issues with the resource's functionality.
if ( GetCurrentResourceName() ~= "wk_wars2x" ) then if ( GetCurrentResourceName() ~= "wk_wars2x" ) then
print( "^1ERROR: Resource name is not wk_wars2x, expect there to be issues with the resource. To ensure there are no issues, please leave the resource name as wk_wars2x^0\n\n" ) print( "^1ERROR: Resource name is not wk_wars2x, expect there to be issues with the resource. To ensure there are no issues, please leave the resource name as wk_wars2x^0\n\n" )
end end
end ) end )