mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 00:16:27 +02:00
style: remove trailing spaces
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
|
||||
Wraith ARS 2X
|
||||
Created by WolfKnight
|
||||
|
||||
For discussions, information on future updates, and more, join
|
||||
my Discord: https://discord.gg/fD4e6WD
|
||||
|
||||
|
||||
For discussions, information on future updates, and more, join
|
||||
my Discord: https://discord.gg/fD4e6WD
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2021 WolfKnight
|
||||
@@ -36,34 +36,34 @@ READER = {}
|
||||
Plate reader variables
|
||||
|
||||
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,
|
||||
|
||||
-- Whether or not the plate reader should be hidden, e.g. the display is active but the player then steps
|
||||
-- out of their vehicle
|
||||
hidden = false,
|
||||
|
||||
-- The BOLO plate
|
||||
boloPlate = "",
|
||||
|
||||
-- Cameras, this table contains all of the data needed for operation of the front and rear plate reader
|
||||
-- The BOLO plate
|
||||
boloPlate = "",
|
||||
|
||||
-- Cameras, this table contains all of the data needed for operation of the front and rear plate reader
|
||||
cams = {
|
||||
-- Variables for the front camera
|
||||
["front"] = {
|
||||
plate = "", -- The current plate caught by the reader
|
||||
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
|
||||
["rear"] = {
|
||||
plate = "", -- The current plate caught by the reader
|
||||
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
|
||||
function READER:GetDisplayState()
|
||||
return self.vars.displayed
|
||||
end
|
||||
end
|
||||
|
||||
-- Toggles the display state of the plate reader system
|
||||
function READER:ToggleDisplayState()
|
||||
-- Toggle the display variable
|
||||
self.vars.displayed = not self.vars.displayed
|
||||
-- Toggle the display variable
|
||||
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() } )
|
||||
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 )
|
||||
self.vars.hidden = state
|
||||
end
|
||||
self.vars.hidden = state
|
||||
end
|
||||
|
||||
-- Returns if the display is hidden
|
||||
-- Returns if the display is hidden
|
||||
function READER:GetDisplayHidden()
|
||||
return self.vars.hidden
|
||||
return self.vars.hidden
|
||||
end
|
||||
|
||||
-- Returns the stored plate for the given reader
|
||||
function READER:GetPlate( cam )
|
||||
return self.vars.cams[cam].plate
|
||||
end
|
||||
return self.vars.cams[cam].plate
|
||||
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 )
|
||||
self.vars.cams[cam].plate = plate
|
||||
end
|
||||
self.vars.cams[cam].plate = plate
|
||||
end
|
||||
|
||||
-- Returns the stored plate index for the given reader
|
||||
function READER:GetIndex( cam )
|
||||
return self.vars.cams[cam].index
|
||||
end
|
||||
end
|
||||
|
||||
-- Sets the plate index for the given reader to the given index
|
||||
function READER:SetIndex( cam, index )
|
||||
self.vars.cams[cam].index = index
|
||||
end
|
||||
self.vars.cams[cam].index = index
|
||||
end
|
||||
|
||||
-- Returns the bolo plate
|
||||
function READER:GetBoloPlate()
|
||||
if ( self.vars.boloPlate ~= nil ) then
|
||||
if ( self.vars.boloPlate ~= nil ) then
|
||||
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 )
|
||||
self.vars.boloPlate = plate
|
||||
UTIL:Notify( "BOLO plate set to: ~b~" .. plate )
|
||||
end
|
||||
end
|
||||
|
||||
-- Clears the BOLO plate
|
||||
-- Clears the BOLO plate
|
||||
function READER:ClearBoloPlate()
|
||||
self.vars.boloPlate = nil
|
||||
self.vars.boloPlate = nil
|
||||
UTIL:Notify( "~b~BOLO plate cleared!" )
|
||||
end
|
||||
end
|
||||
|
||||
-- Returns if the given reader is locked
|
||||
function READER:GetCamLocked( cam )
|
||||
return self.vars.cams[cam].locked
|
||||
end
|
||||
end
|
||||
|
||||
-- Locks the given reader
|
||||
function READER:LockCam( cam, playBeep, isBolo )
|
||||
-- Check that plate readers can actually be locked
|
||||
if ( PLY:VehicleStateValid() and self:CanPerformMainTask() ) then
|
||||
-- Toggle the lock state
|
||||
if ( PLY:VehicleStateValid() and self:CanPerformMainTask() ) then
|
||||
-- Toggle the lock state
|
||||
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 } )
|
||||
|
||||
-- Play a beep
|
||||
if ( self:GetCamLocked( cam ) ) then
|
||||
if ( playBeep ) then
|
||||
-- Play a beep
|
||||
if ( self:GetCamLocked( cam ) ) then
|
||||
if ( playBeep ) then
|
||||
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" ) } )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- 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 ) )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Returns if the plate reader system can perform tasks
|
||||
function READER:CanPerformMainTask()
|
||||
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 )
|
||||
if ( relPos == 1 ) then
|
||||
if ( relPos == 1 ) then
|
||||
return "front"
|
||||
elseif ( relPos == -1 ) then
|
||||
elseif ( relPos == -1 ) then
|
||||
return "rear"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
RegisterNetEvent( "wk:togglePlateLock" )
|
||||
AddEventHandler( "wk:togglePlateLock", function( cam, beep, bolo )
|
||||
READER:LockCam( cam, beep, bolo )
|
||||
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 )
|
||||
-- Toggle the display state
|
||||
-- Toggle the display state
|
||||
READER:ToggleDisplayState()
|
||||
cb( "ok" )
|
||||
cb( "ok" )
|
||||
end )
|
||||
|
||||
-- Runs when the "Set BOLO Plate" button is pressed on the plate reader box
|
||||
RegisterNUICallback( "setBoloPlate", function( plate, cb )
|
||||
-- Set the BOLO plate
|
||||
-- Set the BOLO plate
|
||||
READER:SetBoloPlate( plate )
|
||||
cb( "ok" )
|
||||
cb( "ok" )
|
||||
end )
|
||||
|
||||
-- Runs when the "Clear BOLO Plate" button is pressed on the plate reader box
|
||||
RegisterNUICallback( "clearBoloPlate", function( plate, cb )
|
||||
-- Clear the BOLO plate
|
||||
-- Clear the BOLO plate
|
||||
READER:ClearBoloPlate()
|
||||
cb( "ok" )
|
||||
end )
|
||||
|
||||
-- This is the main function that runs and scans all vehicles in front and behind the patrol vehicle
|
||||
function READER:Main()
|
||||
-- Check that the system can actually run
|
||||
if ( PLY:VehicleStateValid() and self:CanPerformMainTask() ) then
|
||||
-- Check that the system can actually run
|
||||
if ( PLY:VehicleStateValid() and self:CanPerformMainTask() ) then
|
||||
-- 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
|
||||
local pos = GetEntityCoords( PLY.veh )
|
||||
|
||||
@@ -217,14 +217,14 @@ function READER:Main()
|
||||
-- Get the end position 50m in front/behind the player's vehicle
|
||||
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 )
|
||||
|
||||
-- Get the plate reader text for front/rear
|
||||
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
|
||||
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
|
||||
local ownH = UTIL:Round( GetEntityHeading( PLY.veh ), 0 )
|
||||
local tarH = UTIL:Round( GetEntityHeading( veh ), 0 )
|
||||
@@ -233,16 +233,16 @@ function READER:Main()
|
||||
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
|
||||
if ( dir > 0 ) then
|
||||
-- Get the licence plate text from the vehicle
|
||||
if ( dir > 0 ) then
|
||||
-- Get the licence plate text from the vehicle
|
||||
local plate = GetVehicleNumberPlateText( veh )
|
||||
|
||||
-- Get the licence plate index from the vehicle
|
||||
-- Get the licence plate index from the vehicle
|
||||
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
|
||||
-- plate and image even though they're the same
|
||||
if ( self:GetPlate( cam ) ~= plate ) then
|
||||
-- plate and image even though they're the same
|
||||
if ( self:GetPlate( cam ) ~= plate ) then
|
||||
-- Set the plate for the current reader
|
||||
self:SetPlate( cam, plate )
|
||||
|
||||
@@ -250,24 +250,24 @@ function READER:Main()
|
||||
self:SetIndex( cam, index )
|
||||
|
||||
-- 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 )
|
||||
end
|
||||
end
|
||||
|
||||
-- Send the plate information to the NUI side to update the UI
|
||||
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 ( ( CONFIG.use_sonorancad and ( UTIL:IsPlayerInVeh( veh ) or IsVehiclePreviouslyOwnedByPlayer( veh ) ) and GetVehicleClass( veh ) ~= 18 ) or not CONFIG.use_sonorancad ) then
|
||||
-- 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
|
||||
-- Trigger the event so developers can hook into the scanner every time a plate is scanned
|
||||
TriggerServerEvent( "wk:onPlateScanned", cam, plate, index )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Main thread
|
||||
Citizen.CreateThread( function()
|
||||
@@ -277,31 +277,31 @@ Citizen.CreateThread( function()
|
||||
|
||||
-- Wait half a second
|
||||
Citizen.Wait( 500 )
|
||||
end
|
||||
end
|
||||
end )
|
||||
|
||||
-- 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
|
||||
-- patrol vehicle
|
||||
-- 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
|
||||
-- patrol vehicle
|
||||
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
|
||||
self:SetDisplayHidden( true )
|
||||
self:SetDisplayHidden( true )
|
||||
SendNUIMessage( { _type = "setReaderDisplayState", state = false } )
|
||||
elseif ( PLY:CanViewRadar() and self:GetDisplayState() and self:GetDisplayHidden() ) then
|
||||
self:SetDisplayHidden( false )
|
||||
self:SetDisplayHidden( false )
|
||||
SendNUIMessage( { _type = "setReaderDisplayState", state = true } )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Runs the display validation check for the radar
|
||||
Citizen.CreateThread( function()
|
||||
Citizen.CreateThread( function()
|
||||
Citizen.Wait( 100 )
|
||||
|
||||
while ( true ) do
|
||||
-- Run the check
|
||||
while ( true ) do
|
||||
-- Run the check
|
||||
READER:RunDisplayValidationCheck()
|
||||
|
||||
-- Wait half a second
|
||||
-- Wait half a second
|
||||
Citizen.Wait( 500 )
|
||||
end
|
||||
end
|
||||
end )
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
Wraith ARS 2X
|
||||
Created by WolfKnight
|
||||
|
||||
For discussions, information on future updates, and more, join
|
||||
my Discord: https://discord.gg/fD4e6WD
|
||||
|
||||
|
||||
For discussions, information on future updates, and more, join
|
||||
my Discord: https://discord.gg/fD4e6WD
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2021 WolfKnight
|
||||
@@ -33,62 +33,62 @@
|
||||
--[[----------------------------------------------------------------------------------
|
||||
Player info variables
|
||||
----------------------------------------------------------------------------------]]--
|
||||
PLY =
|
||||
PLY =
|
||||
{
|
||||
ped = PlayerPedId(),
|
||||
veh = nil,
|
||||
inDriverSeat = false,
|
||||
inPassengerSeat = false,
|
||||
inPassengerSeat = false,
|
||||
vehClassValid = false
|
||||
}
|
||||
|
||||
function PLY:VehicleStateValid()
|
||||
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()
|
||||
return self:VehicleStateValid() and self.inDriverSeat
|
||||
end
|
||||
return self:VehicleStateValid() and self.inDriverSeat
|
||||
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()
|
||||
return self:VehicleStateValid() and self.inPassengerSeat
|
||||
end
|
||||
return self:VehicleStateValid() and self.inPassengerSeat
|
||||
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)
|
||||
function PLY:CanViewRadar()
|
||||
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()
|
||||
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
|
||||
function PLY:GetOtherPed()
|
||||
if ( self:IsDriver() ) then
|
||||
if ( self:IsDriver() ) then
|
||||
return GetPedInVehicleSeat( PLY.veh, 0 )
|
||||
elseif ( self:IsPassenger() ) then
|
||||
return GetPedInVehicleSeat( PLY.veh, -1 )
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- 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
|
||||
-- is valid or not
|
||||
-- is valid or not
|
||||
Citizen.CreateThread( function()
|
||||
while ( true ) do
|
||||
while ( true ) do
|
||||
PLY.ped = PlayerPedId()
|
||||
PLY.veh = GetVehiclePedIsIn( PLY.ped, false )
|
||||
PLY.inDriverSeat = GetPedInVehicleSeat( PLY.veh, -1 ) == PLY.ped
|
||||
PLY.inPassengerSeat = GetPedInVehicleSeat( PLY.veh, 0 ) == PLY.ped
|
||||
PLY.inDriverSeat = GetPedInVehicleSeat( PLY.veh, -1 ) == PLY.ped
|
||||
PLY.inPassengerSeat = GetPedInVehicleSeat( PLY.veh, 0 ) == PLY.ped
|
||||
PLY.vehClassValid = GetVehicleClass( PLY.veh ) == 18
|
||||
|
||||
Citizen.Wait( 500 )
|
||||
end
|
||||
end
|
||||
end )
|
||||
1290
cl_radar.lua
1290
cl_radar.lua
File diff suppressed because it is too large
Load Diff
38
cl_sync.lua
38
cl_sync.lua
@@ -2,10 +2,10 @@
|
||||
|
||||
Wraith ARS 2X
|
||||
Created by WolfKnight
|
||||
|
||||
For discussions, information on future updates, and more, join
|
||||
my Discord: https://discord.gg/fD4e6WD
|
||||
|
||||
|
||||
For discussions, information on future updates, and more, join
|
||||
my Discord: https://discord.gg/fD4e6WD
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2021 WolfKnight
|
||||
@@ -34,35 +34,35 @@ SYNC = {}
|
||||
|
||||
|
||||
--[[----------------------------------------------------------------------------------
|
||||
Sync functions
|
||||
Sync functions
|
||||
----------------------------------------------------------------------------------]]--
|
||||
function SYNC:SyncData( cb )
|
||||
local otherPed = PLY:GetOtherPed()
|
||||
|
||||
if ( otherPed ~= nil and otherPed ~= 0 ) then
|
||||
if ( otherPed ~= nil and otherPed ~= 0 ) then
|
||||
local otherPly = GetPlayerServerId( NetworkGetPlayerIndexFromPed( otherPed ) )
|
||||
|
||||
cb( otherPly )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function SYNC:SendPowerState( state )
|
||||
self:SyncData( function( ply )
|
||||
TriggerServerEvent( "wk_wars2x_sync:sendPowerState", ply, state )
|
||||
end )
|
||||
end
|
||||
end
|
||||
|
||||
function SYNC:SendAntennaPowerState( state, ant )
|
||||
self:SyncData( function( ply )
|
||||
TriggerServerEvent( "wk_wars2x_sync:sendAntennaPowerState", ply, state, ant )
|
||||
end )
|
||||
end
|
||||
end
|
||||
|
||||
function SYNC:SendAntennaMode( ant, mode )
|
||||
self:SyncData( function( ply )
|
||||
TriggerServerEvent( "wk_wars2x_sync:sendAntennaMode", ply, ant, mode )
|
||||
end )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--[[----------------------------------------------------------------------------------
|
||||
@@ -72,35 +72,35 @@ RegisterNetEvent( "wk_wars2x_sync:receivePowerState" )
|
||||
AddEventHandler( "wk_wars2x_sync:receivePowerState", function( state )
|
||||
local power = RADAR:IsPowerOn()
|
||||
|
||||
if ( power ~= state ) then
|
||||
if ( power ~= state ) then
|
||||
Citizen.SetTimeout( 100, function()
|
||||
RADAR:TogglePower()
|
||||
end )
|
||||
end
|
||||
end
|
||||
end )
|
||||
|
||||
RegisterNetEvent( "wk_wars2x_sync:receiveAntennaPowerState" )
|
||||
AddEventHandler( "wk_wars2x_sync:receiveAntennaPowerState", function( state, antenna )
|
||||
local power = RADAR:IsAntennaTransmitting( antenna )
|
||||
|
||||
if ( power ~= state ) then
|
||||
if ( power ~= state ) then
|
||||
RADAR:ToggleAntenna( antenna, function()
|
||||
-- Update the interface with the new antenna transmit state
|
||||
SendNUIMessage( { _type = "antennaXmit", ant = antenna, on = state } )
|
||||
|
||||
|
||||
-- Play some audio specific to the transmit state
|
||||
SendNUIMessage( { _type = "audio", name = state and "xmit_on" or "xmit_off", vol = RADAR:GetSettingValue( "beep" ) } )
|
||||
end )
|
||||
end
|
||||
end
|
||||
end )
|
||||
|
||||
RegisterNetEvent( "wk_wars2x_sync:receiveAntennaMode" )
|
||||
AddEventHandler( "wk_wars2x_sync:receiveAntennaMode", function( antenna, mode )
|
||||
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 } )
|
||||
|
||||
-- Play a beep
|
||||
|
||||
-- Play a beep
|
||||
SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "beep" ) } )
|
||||
end )
|
||||
end )
|
||||
@@ -1,4 +1,4 @@
|
||||
if ( CONFIG.debug ) then
|
||||
if ( CONFIG.debug ) then
|
||||
-- Restart the resource
|
||||
RegisterCommand( "rre", function( source, args, rawCommand )
|
||||
UTIL:Notify( "[DEBUG]: Restarting resource" )
|
||||
|
||||
76
cl_utils.lua
76
cl_utils.lua
@@ -2,10 +2,10 @@
|
||||
|
||||
Wraith ARS 2X
|
||||
Created by WolfKnight
|
||||
|
||||
For discussions, information on future updates, and more, join
|
||||
my Discord: https://discord.gg/fD4e6WD
|
||||
|
||||
|
||||
For discussions, information on future updates, and more, join
|
||||
my Discord: https://discord.gg/fD4e6WD
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2021 WolfKnight
|
||||
@@ -35,49 +35,49 @@ UTIL = {}
|
||||
-- Returns a number to a set number of decimal places
|
||||
function UTIL:Round( num, numDecimalPlaces )
|
||||
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
|
||||
-- takes a speed and returns a formatted speed that can be displayed on the radar
|
||||
-- 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
|
||||
function UTIL:FormatSpeed( speed )
|
||||
-- Return "Err" (Error) if the given speed is outside the 0-999 range
|
||||
if ( speed < 0 or speed > 999 ) then return "Err" end
|
||||
-- Return "Err" (Error) if the given speed is outside the 0-999 range
|
||||
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 pipes = ""
|
||||
|
||||
-- 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 .. "¦"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Return the formatted speed
|
||||
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 )
|
||||
-- Return the min value if the given value is less than the min
|
||||
if ( val < min ) then
|
||||
return min
|
||||
if ( val < min ) then
|
||||
return min
|
||||
-- Return the max value if the given value is larger than the max
|
||||
elseif ( val > max ) then
|
||||
return max
|
||||
end
|
||||
elseif ( val > max ) then
|
||||
return max
|
||||
end
|
||||
|
||||
-- Return the given value if it's between the min and max
|
||||
return val
|
||||
end
|
||||
return val
|
||||
end
|
||||
|
||||
-- Returns if the given table is empty, includes numerical and non-numerical key values
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
-- Credit to Deltanic for this function
|
||||
function UTIL:Values( xs )
|
||||
@@ -96,16 +96,16 @@ function UTIL:GetVehicleInDirection( entFrom, coordFrom, coordTo )
|
||||
return vehicle
|
||||
end
|
||||
|
||||
-- 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
|
||||
-- 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
|
||||
function UTIL:GetEntityRelativeDirection( myAng, tarAng )
|
||||
local angleDiff = math.abs( ( myAng - tarAng + 180 ) % 360 - 180 )
|
||||
|
||||
if ( angleDiff < 45 ) then
|
||||
if ( angleDiff < 45 ) then
|
||||
return 1
|
||||
elseif ( angleDiff > 135 ) then
|
||||
elseif ( angleDiff > 135 ) then
|
||||
return 2
|
||||
end
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
@@ -115,15 +115,15 @@ function UTIL:IsPlayerInVeh( veh )
|
||||
for i = -1, GetVehicleMaxNumberOfPassengers( veh ) + 1, 1 do
|
||||
local ped = GetPedInVehicleSeat( veh, i )
|
||||
|
||||
if ( DoesEntityExist( ped ) ) then
|
||||
if ( IsPedAPlayer( ped ) ) then return true end
|
||||
end
|
||||
end
|
||||
if ( DoesEntityExist( ped ) ) then
|
||||
if ( IsPedAPlayer( ped ) ) then return true end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Your everyday GTA notification function
|
||||
-- Your everyday GTA notification function
|
||||
function UTIL:Notify( text )
|
||||
SetNotificationTextEntry( "STRING" )
|
||||
AddTextComponentSubstringPlayerName( text )
|
||||
@@ -132,7 +132,7 @@ end
|
||||
|
||||
function UTIL:Log( msg )
|
||||
print( "[Wraith ARS 2X]: " .. msg )
|
||||
end
|
||||
end
|
||||
|
||||
function UTIL:DrawDebugText( x, y, scale, centre, text )
|
||||
SetTextFont( 4 )
|
||||
@@ -151,7 +151,7 @@ end
|
||||
|
||||
function UTIL:IsResourceNameValid()
|
||||
return GetCurrentResourceName() == "wk_wars2x"
|
||||
end
|
||||
end
|
||||
|
||||
--[[The MIT License (MIT)
|
||||
|
||||
|
||||
74
config.lua
74
config.lua
@@ -2,10 +2,10 @@
|
||||
|
||||
Wraith ARS 2X
|
||||
Created by WolfKnight
|
||||
|
||||
For discussions, information on future updates, and more, join
|
||||
my Discord: https://discord.gg/fD4e6WD
|
||||
|
||||
|
||||
For discussions, information on future updates, and more, join
|
||||
my Discord: https://discord.gg/fD4e6WD
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2021 WolfKnight
|
||||
@@ -37,39 +37,39 @@ CONFIG = {}
|
||||
CONFIG.debug = true
|
||||
|
||||
-- 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
|
||||
CONFIG.allow_fast_limit = true
|
||||
CONFIG.allow_fast_limit = true
|
||||
|
||||
-- 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.
|
||||
CONFIG.only_lock_players = false
|
||||
-- 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.
|
||||
CONFIG.only_lock_players = false
|
||||
|
||||
-- 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
|
||||
-- open the remote.
|
||||
CONFIG.allow_quick_start_video = true
|
||||
-- When enabled, the player will be asked if they'd like to view the quick start video the first time they
|
||||
-- open the remote.
|
||||
CONFIG.allow_quick_start_video = true
|
||||
|
||||
-- Allow passenger view
|
||||
-- When enabled, the front seat passenger will be able to view the radar and plate reader from their end.
|
||||
CONFIG.allow_passenger_view = true
|
||||
|
||||
-- Allow passenger control
|
||||
-- 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.
|
||||
-- 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.
|
||||
CONFIG.allow_passenger_control = false
|
||||
|
||||
-- Set this to true if you use Sonoran CAD with the WraithV2 plugin
|
||||
CONFIG.use_sonorancad = false
|
||||
-- Set this to true if you use Sonoran CAD with the WraithV2 plugin
|
||||
CONFIG.use_sonorancad = false
|
||||
|
||||
-- Sets the defaults of all keybinds
|
||||
-- These keybinds can be changed by each person in their GTA Settings->Keybinds->FiveM
|
||||
CONFIG.keyDefaults =
|
||||
{
|
||||
-- Remote control key
|
||||
-- Remote control key
|
||||
remote_control = "f5",
|
||||
|
||||
-- Radar key lock key
|
||||
-- Radar key lock key
|
||||
key_lock = "l",
|
||||
|
||||
-- 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
|
||||
-- one of the options listed, the script will not work.
|
||||
CONFIG.menuDefaults =
|
||||
-- one of the options listed, the script will not work.
|
||||
CONFIG.menuDefaults =
|
||||
{
|
||||
-- Should the system calculate and display faster targets
|
||||
-- Options: true or false
|
||||
["fastDisplay"] = true,
|
||||
["fastDisplay"] = true,
|
||||
|
||||
-- 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
|
||||
["same"] = 0.6,
|
||||
["opp"] = 0.6,
|
||||
["same"] = 0.6,
|
||||
["opp"] = 0.6,
|
||||
|
||||
-- The volume of the audible beep
|
||||
-- Options: 0.0, 0.2, 0.4, 0.6, 0.8, 1.0
|
||||
-- The volume of the audible beep
|
||||
-- Options: 0.0, 0.2, 0.4, 0.6, 0.8, 1.0
|
||||
["beep"] = 0.6,
|
||||
|
||||
-- The volume of the verbal lock confirmation
|
||||
-- Options: 0.0, 0.2, 0.4, 0.6, 0.8, 1.0
|
||||
|
||||
-- The volume of the verbal lock confirmation
|
||||
-- Options: 0.0, 0.2, 0.4, 0.6, 0.8, 1.0
|
||||
["voice"] = 0.6,
|
||||
|
||||
-- The volume of the plate reader audio
|
||||
-- Options: 0.0, 0.2, 0.4, 0.6, 0.8, 1.0
|
||||
["plateAudio"] = 0.6,
|
||||
|
||||
-- The volume of the plate reader audio
|
||||
-- Options: 0.0, 0.2, 0.4, 0.6, 0.8, 1.0
|
||||
["plateAudio"] = 0.6,
|
||||
|
||||
-- The speed unit used in conversions
|
||||
-- Options: mph or kmh
|
||||
-- Options: mph or kmh
|
||||
["speedType"] = "mph"
|
||||
}
|
||||
|
||||
@@ -122,12 +122,12 @@ CONFIG.uiDefaults =
|
||||
-- Options: 0.25 - 2.5
|
||||
scale =
|
||||
{
|
||||
radar = 1.0,
|
||||
remote = 1.0,
|
||||
radar = 1.0,
|
||||
remote = 1.0,
|
||||
plateReader = 1.0
|
||||
},
|
||||
},
|
||||
|
||||
-- The safezone size, must be a multiple of 5.
|
||||
-- Options: 0 - 100
|
||||
safezone = 20
|
||||
safezone = 20
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
Wraith ARS 2X
|
||||
Created by WolfKnight
|
||||
|
||||
For discussions, information on future updates, and more, join
|
||||
my Discord: https://discord.gg/fD4e6WD
|
||||
|
||||
|
||||
For discussions, information on future updates, and more, join
|
||||
my Discord: https://discord.gg/fD4e6WD
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2021 WolfKnight
|
||||
@@ -42,9 +42,9 @@ version "beta"
|
||||
|
||||
-- Include the files
|
||||
files {
|
||||
"nui/radar.html",
|
||||
"nui/radar.css",
|
||||
"nui/jquery-3.4.1.min.js",
|
||||
"nui/radar.html",
|
||||
"nui/radar.css",
|
||||
"nui/jquery-3.4.1.min.js",
|
||||
"nui/radar.js",
|
||||
"nui/images/*.png",
|
||||
"nui/images/plates/*.png",
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
Wraith ARS 2X
|
||||
Created by WolfKnight
|
||||
|
||||
For discussions, information on future updates, and more, join
|
||||
my Discord: https://discord.gg/fD4e6WD
|
||||
|
||||
|
||||
For discussions, information on future updates, and more, join
|
||||
my Discord: https://discord.gg/fD4e6WD
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2021 WolfKnight
|
||||
@@ -31,7 +31,7 @@
|
||||
---------------------------------------------------------------------------------------]]--
|
||||
|
||||
-- Branding!
|
||||
local label =
|
||||
local label =
|
||||
[[
|
||||
//
|
||||
|| __ __ _ _ _ _____ _____ ___ __ __
|
||||
@@ -47,37 +47,37 @@ local label =
|
||||
-- Returns the current version set in fxmanifest.lua
|
||||
function GetCurrentVersion()
|
||||
return GetResourceMetadata( GetCurrentResourceName(), "version" )
|
||||
end
|
||||
end
|
||||
|
||||
-- Grabs the latest version number from the web GitHub
|
||||
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 )
|
||||
|
||||
-- Print the branding!
|
||||
print( label )
|
||||
|
||||
-- Get the current resource version
|
||||
-- Get the current resource version
|
||||
local curVer = GetCurrentVersion()
|
||||
|
||||
if ( text ~= nil ) then
|
||||
-- Print out the current and latest version
|
||||
|
||||
if ( text ~= nil ) then
|
||||
-- Print out the current and latest version
|
||||
print( " || Current version: " .. curVer )
|
||||
print( " || Latest recommended version: " .. text .."\n ||" )
|
||||
|
||||
|
||||
-- If the versions are different, print it out
|
||||
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" )
|
||||
else
|
||||
print( " || ^2Wraith ARS 2X is up to date!\n^0 ||\n \\\\\n" )
|
||||
end
|
||||
else
|
||||
else
|
||||
-- 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" )
|
||||
end
|
||||
end
|
||||
|
||||
-- Warn the console if the resource has been renamed, as this will cause issues with the resource's functionality.
|
||||
if ( GetCurrentResourceName() ~= "wk_wars2x" ) then
|
||||
-- Warn the console if the resource has been renamed, as this will cause issues with the resource's functionality.
|
||||
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" )
|
||||
end
|
||||
end
|
||||
end )
|
||||
Reference in New Issue
Block a user