- Added a server export to toggle plate lock on a client
- Removed old and redundant code
- Added the licence to the top of every file
- Added a small section at the bottom of config.lua to set the default UI element scale, as well as the safezone
- Changed the height of the UI settings box to stop the slider and close button from overlapping
- Added the ability to disable server console messages
- Formatted all code to tab size 4!
This commit is contained in:
Dan
2020-03-05 19:40:37 +00:00
parent d028d35c58
commit d491dc50e4
11 changed files with 1569 additions and 1203 deletions

View File

@@ -1,9 +1,34 @@
--[[-----------------------------------------------------------------------
--[[---------------------------------------------------------------------------------------
Wraith ARS 2X
Created by WolfKnight
-----------------------------------------------------------------------]]--
For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD
MIT License
Copyright (c) 2020 WolfKnight
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---------------------------------------------------------------------------------------]]--
READER = {}
@@ -104,7 +129,7 @@ function READER:GetCamLocked( cam )
end
-- Locks the given reader
function READER:LockCam( cam, playAudio, isBolo )
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
@@ -115,11 +140,16 @@ function READER:LockCam( cam, playAudio, isBolo )
-- Play a beep
if ( self:GetCamLocked( cam ) ) then
if ( playAudio ) then
if ( playBeep ) then
SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "plateAudio" ) } )
end
TriggerEvent( "wk:onPlateLocked", cam, self:GetPlate( cam ), self:GetIndex( cam ) )
if ( isBolo ) then
SendNUIMessage( { _type = "audio", name = "plate_hit", vol = RADAR:GetSettingValue( "plateAudio" ) } )
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
@@ -138,6 +168,11 @@ function READER:GetCamFromNum( relPos )
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
RegisterNUICallback( "togglePlateReaderDisplay", function()
-- Toggle the display state
@@ -162,7 +197,7 @@ function READER:Main()
-- Get a start position 5m in front/behind the player's vehicle
local start = GetOffsetFromEntityInWorldCoords( PLY.veh, 0.0, ( 5.0 * i ), 0.0 )
-- Get the end position 40m 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 )
-- Run the ray trace to get a vehicle
@@ -201,14 +236,14 @@ function READER:Main()
if ( plate == self:GetBoloPlate() ) then
self:LockCam( cam, false, true )
SendNUIMessage( { _type = "audio", name = "plate_hit", vol = RADAR:GetSettingValue( "plateAudio" ) } )
-- SendNUIMessage( { _type = "audio", name = "plate_hit", vol = RADAR:GetSettingValue( "plateAudio" ) } )
end
-- Send the plate information to the NUI side to update the UI
SendNUIMessage( { _type = "changePlate", cam = cam, plate = plate, index = index } )
-- Trigger the event so developers can hook into the scanner
TriggerEvent( "wk:onPlateScanned", cam, plate, index )
-- 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

View File

@@ -1,9 +1,34 @@
--[[----------------------------------------------------------------------------------
--[[---------------------------------------------------------------------------------------
Wraith ARS 2X
Created by WolfKnight
----------------------------------------------------------------------------------]]--
For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD
MIT License
Copyright (c) 2020 WolfKnight
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---------------------------------------------------------------------------------------]]--
-- Cache some of the main Lua functions and libraries
local next = next
@@ -23,7 +48,7 @@ Citizen.SetTimeout( 1000, function()
local name = GetCurrentResourceName()
-- Print a little message in the client's console
print( "WK_WARS2X: Sending resource name (" .. name .. ") to JavaScript side." )
print( "[wk_wars2x]: Sending resource name (" .. name .. ") to JavaScript side." )
-- Send a message through the NUI system to the JavaScript file to give the name of the resource
SendNUIMessage( { _type = "updatePathName", pathName = name } )
@@ -51,6 +76,12 @@ AddEventHandler( "wk:loadUiData", function( data )
SendNUIMessage( { _type = "loadUiSettings", data = data } )
end )
RegisterNetEvent( "wk:setUiDefaults" )
AddEventHandler( "wk:setUiDefaults", function()
SendNUIMessage( { _type = "setUiDefaults", data = CONFIG.uiDefaults } )
end )
--[[----------------------------------------------------------------------------------
Player info variables
----------------------------------------------------------------------------------]]--
@@ -158,6 +189,7 @@ RADAR.vars =
lockedType = nil -- The locked type, 1 = strongest, 2 = fastest
},
-- Variables for the rear antenna
[ "rear" ] = {
xmit = false, -- Whether the antenna is transmitting or in hold
mode = 0, -- Current antenna mode, 0 = none, 1 = same, 2 = opp, 3 = same and opp
@@ -377,28 +409,6 @@ function RADAR:OpenRemote()
end
end
-- Updates the operator menu option indexes, as the default menu values can be changed in the config, we
-- need to update the indexes otherwise the menu will display the wrong values
function RADAR:UpdateOptionIndexes()
-- Iterate through each of the internal settings
for k, v in pairs( self.vars.settings ) do
-- Iterate through all of the menu options
for i, t in pairs( self.vars.menuOptions ) do
-- If the current menu option is the same as the current setting
if ( t.settingText == k ) then
-- Iterate through the option values of the current menu option
for oi, ov in pairs( t.options ) do
-- If the value of the current option set in the config matches the current value of
-- the option value, then we update the option index variable
if ( v == ov ) then
t.optionIndex = oi
end
end
end
end
end
end
-- Returns if the fast limit option should be available for the radar
function RADAR:IsFastLimitAllowed()
return CONFIG.allow_fast_limit
@@ -594,6 +604,28 @@ function RADAR:SendMenuUpdate()
SendNUIMessage( { _type = "menu", text = self:GetMenuOptionDisplayText(), option = self:GetMenuOptionText() } )
end
-- Updates the operator menu option indexes, as the default menu values can be changed in the config, we
-- need to update the indexes otherwise the menu will display the wrong values
function RADAR:UpdateOptionIndexes()
-- Iterate through each of the internal settings
for k, v in pairs( self.vars.settings ) do
-- Iterate through all of the menu options
for i, t in pairs( self.vars.menuOptions ) do
-- If the current menu option is the same as the current setting
if ( t.settingText == k ) then
-- Iterate through the option values of the current menu option
for oi, ov in pairs( t.options ) do
-- If the value of the current option set in the config matches the current value of
-- the option value, then we update the option index variable
if ( v == ov ) then
t.optionIndex = oi
end
end
end
end
end
end
--[[----------------------------------------------------------------------------------
Radar basics functions
@@ -1110,28 +1142,6 @@ function RADAR:InsertCapturedVehicleData( t, rt )
end
end
--[[
These need to be changed so a ray type can be set too, otherwise in its current state, messes up vehicle
detection.
-- Sets the given value to true in the temp vehicles table, it is a test system used to reduce ray traces
-- on vehicles that have already been hit by another trace. Currently not implemented fully, as it doesn't
-- check for ray traces of different types, e.g. same or opp.
function RADAR:HasVehicleAlreadyBeenHit( key )
return self.vars.tempVehicleIDs[key]
end
-- Returns if a vehicle has already been hit by a ray trace
function RADAR:SetVehicleHasBeenHit( key )
self.vars.tempVehicleIDs[key] = true
end
-- Resets the temporary vehicle ids table
function RADAR:ResetTempVehicleIDs()
self.vars.tempVehicleIDs = {}
end
]]
--[[----------------------------------------------------------------------------------
Radar dynamic sphere radius functions
@@ -1600,8 +1610,6 @@ function RADAR:Main()
-- Send the update to the NUI side
SendNUIMessage( { _type = "update", speed = data.patrolSpeed, antennas = data.antennas } )
-- self:ResetTempVehicleIDs()
end
end
@@ -1723,11 +1731,6 @@ function RunControlManager()
RADAR:ToggleFullKeyboard()
end
end
-- Shortcut to restart the resource
--[[ if ( IsDisabledControlJustPressed( 1, 167 ) ) then
ExecuteCommand( "restart wk_wars2x" )
end ]]
end
-- Control manager

View File

@@ -1,9 +1,34 @@
--[[-----------------------------------------------------------------------
--[[---------------------------------------------------------------------------------------
Wraith ARS 2X
Created by WolfKnight
-----------------------------------------------------------------------]]--
For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD
MIT License
Copyright (c) 2020 WolfKnight
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---------------------------------------------------------------------------------------]]--
UTIL = {}

View File

@@ -1,9 +1,34 @@
--[[------------------------------------------------------------------------
--[[---------------------------------------------------------------------------------------
Wraith ARS 2X
Created by WolfKnight
------------------------------------------------------------------------]]--
For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD
MIT License
Copyright (c) 2020 WolfKnight
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---------------------------------------------------------------------------------------]]--
-- Do not touch this
CONFIG = {}
@@ -96,3 +121,20 @@ CONFIG.menuDefaults =
-- Options: mph or kmh
["speedType"] = "mph"
}
-- Here you can change the default scale of the UI elements, as well as the safezone size
CONFIG.uiDefaults =
{
-- The default scale of the UI elements.
-- Options: 0.25 - 2.5
scale =
{
radar = 1.5,
remote = 1.5,
plateReader = 1.5
},
-- The safezone size, must be a multiple of 5.
-- Options: 0 - 100
safezone = 20
}

View File

@@ -1,9 +1,34 @@
--[[-----------------------------------------------------------------------
--[[---------------------------------------------------------------------------------------
Wraith ARS 2X
Created by WolfKnight
-----------------------------------------------------------------------]]--
For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD
MIT License
Copyright (c) 2020 WolfKnight
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---------------------------------------------------------------------------------------]]--
-- Define the FX Server version and game type
fx_version "adamant"
@@ -13,7 +38,7 @@ game "gta5"
name "Wraith ARS 2X"
description "Police radar and plate reader system for FiveM"
author "WolfKnight"
version "pre-release"
version "1.0.0"
-- Include the files
files {
@@ -34,6 +59,8 @@ ui_page "nui/radar.html"
-- Run the server scripts
server_script "sv_version_check.lua"
server_script "sv_saving.lua"
server_script "sv_exports.lua"
server_export "TogglePlateLock"
-- Run the client scripts
client_script "config.lua"

View File

@@ -1,3 +1,35 @@
/*-----------------------------------------------------------------------------------------
Wraith ARS 2X
Created by WolfKnight
For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD
MIT License
Copyright (c) 2020 WolfKnight
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-----------------------------------------------------------------------------------------*/
@font-face {
font-family: "Seg-7";
src: url( "fonts/Segment7Standard.otf" );
@@ -247,7 +279,10 @@ button:focus { outline: none; }
border: 2px solid rgb( 0, 0, 0 );
margin: auto 0;
/* If you would like your strong target window to be solid rather than have a gradient, swap the comment for the 2 lines below */
background-color: rgb( 61, 18, 0 );
/* background: linear-gradient( to bottom, rgb( 52, 13, 1 ), rgb( 57, 16, 0 ) 40%, rgb( 65, 25, 4 ) 85% ); */
}
#radar .speeds_container .display p {
grid-row-start: 1;
@@ -266,7 +301,10 @@ button:focus { outline: none; }
#radar .speeds_container .fast {
height: 60px;
/* If you would like your fast target window to be solid rather than have a gradient, swap the comment for the 2 lines below */
background-color: rgb( 50, 0, 0 );
/* background: linear-gradient( to bottom, rgb( 40, 0, 0 ), rgb( 45, 0, 0 ) 40%, rgb( 50, 0, 0 ) 85% ); */
}
#radar .speeds_container .fast p {
font-size: 60px;
@@ -326,6 +364,7 @@ button:focus { outline: none; }
}
#radar .patrol_and_logo_container .display {
/* If you would like your patrol speed window to be solid rather than have a gradient, swap the comment for the 2 lines below */
background-color: rgb( 0, 57, 35 );
/* background: linear-gradient( to bottom, rgb( 0, 40, 29 ), rgb( 0, 46, 32 ) 40%, rgb( 1, 64, 27 ) 85% ); */
}
@@ -820,7 +859,7 @@ button:focus { outline: none; }
#uiSettingsBox {
width: 250px;
height: 375px;
height: 400px;
position: absolute;
margin: auto;

View File

@@ -1,3 +1,35 @@
<!-----------------------------------------------------------------------------------------
Wraith ARS 2X
Created by WolfKnight
For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD
MIT License
Copyright (c) 2020 WolfKnight
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------------------>
<!DOCTYPE html>
<html>
@@ -275,7 +307,6 @@
</div>
<!-- Load JavaScript files -->
<!-- <script src="nui://game/ui/jquery.js"></script> -->
<script src="jquery-3.4.1.min.js"></script>
<script src="radar.js"></script>
</body>

View File

@@ -1,12 +1,34 @@
/*-------------------------------------------------------------------------
/*-----------------------------------------------------------------------------------------
Wraith ARS 2X
Created by WolfKnight
This JS file takes inspiration from RandomSean's RS9000 JS file, so
thanks to him!
For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD
-------------------------------------------------------------------------*/
MIT License
Copyright (c) 2020 WolfKnight
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-----------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------
Variables
@@ -644,26 +666,55 @@ function sendSaveData()
}
// Loads the UI settings
function loadUiSettings( data )
function loadUiSettings( data, isSave )
{
// Iterate through "remote", "radar" and "plateReader"
for ( let setting of [ "remote", "radar", "plateReader" ] )
{
let ele = elements[setting];
if ( isSave ) {
// Iterate through the settings
for ( let i of [ "left", "top" ] )
{
// Update the position of the current element
elements[setting].css( i, data[setting][i] );
ele.css( i, data[setting][i] );
}
// Set the scale and update the display
setScaleAndDisplay( elements[setting], data[setting].scale, elements[setting + "Scaling"].display );
setScaleAndDisplay( ele, data[setting].scale, elements[setting + "Scaling"].display );
} else {
// Set the scale and update the display
setScaleAndDisplay( ele, data.scale[setting], elements[setting + "Scaling"].display );
// Get the scaled width and height of the current element
let w = ( ele.outerWidth() * data.scale[setting] );
let h = ( ele.outerHeight() * data.scale[setting] );
// The position of the element then needs to be updated.
switch ( setting ) {
case "remote":
ele.css( "left", "calc( 50% - " + w / 2 + "px )" );
ele.css( "top", "calc( 50% - " + h / 2 + "px )" );
break;
case "radar":
ele.css( "left", "calc( ( 100% - " + data.safezone + "px ) - " + w + "px )" );
ele.css( "top", "calc( ( 100% - " + data.safezone + "px ) - " + h + "px )" );
break;
case "plateReader":
ele.css( "left", "calc( ( 100% - " + data.safezone + "px ) - " + w + "px )" );
ele.css( "top", "calc( 50% - " + h / 2 + "px )" );
break;
default:
break;
}
}
}
// Update the remote, radar and reader scale variables
remoteScale = data.remote.scale;
radarScale = data.radar.scale;
readerScale = data.plateReader.scale;
remoteScale = isSave ? data.remote.scale : data.scale.remote;
radarScale = isSave ? data.radar.scale : data.scale.radar;
readerScale = isSave ? data.plateReader.scale : data.scale.plateReader;
// Set the safezone and update the display
elements.safezoneSlider.val( data.safezone );
@@ -1002,7 +1053,10 @@ window.addEventListener( "message", function( event ) {
resourceName = item.pathName
break;
case "loadUiSettings":
loadUiSettings( item.data );
loadUiSettings( item.data, true );
break;
case "setUiDefaults":
loadUiSettings( item.data, false );
break;
case "displayKeyLock":
displayKeyLock( item.state );

50
sv_exports.lua Normal file
View File

@@ -0,0 +1,50 @@
--[[---------------------------------------------------------------------------------------
Wraith ARS 2X
Created by WolfKnight
For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD
MIT License
Copyright (c) 2020 WolfKnight
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---------------------------------------------------------------------------------------]]--
-- Although there is only one export at the moment, more may be added down the line.
--[[---------------------------------------------------------------------------------------
Locks the designated plate reader camera for the given client.
Parameters:
clientId:
The id of the client
cam:
The camera to lock, either "front" or "rear"
beepAudio:
Play an audible beep, either true or false
boloAudio:
Play the bolo lock sound, either true or false
---------------------------------------------------------------------------------------]]--
function TogglePlateLock( clientId, cam, beepAudio, boloAudio )
TriggerClientEvent( "wk:togglePlateLock", clientId, cam, beepAudio, boloAudio )
end

View File

@@ -1,9 +1,34 @@
--[[-----------------------------------------------------------------------
--[[---------------------------------------------------------------------------------------
Wraith ARS 2X
Created by WolfKnight
-----------------------------------------------------------------------]]--
For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD
MIT License
Copyright (c) 2020 WolfKnight
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---------------------------------------------------------------------------------------]]--
local DATASAVE = {}
DATASAVE.dir = "saves"
@@ -19,6 +44,9 @@ DATASAVE.dir = "saves"
-- - ip
DATASAVE.idType = "license"
-- Whether or not to print messages
DATASAVE.printMessages = true
-- Saves the data for the given player into the saves folder within the resource
function DATASAVE:SavePlayerData( src, data )
-- Get the player's identifier
@@ -115,8 +143,10 @@ end
-- Prints the given message with the resource name attached
function DATASAVE:Print( msg )
if ( self.printMessages ) then
print( "^3[wk_wars2x] ^0" .. msg .. "^0" )
end
end
-- Serverside event for saving a player's UI data
RegisterServerEvent( "wk:saveUiData" )
@@ -146,5 +176,8 @@ AddEventHandler( "wk:getUiData", function()
else
-- When player's first use the radar, they won't have saved UI data
DATASAVE:Print( "Player " .. GetPlayerName( source ) .. " (ID: " .. source .. ") doesn't have a UI settings file." )
-- Tell the system to load the UI defaults for the client
TriggerClientEvent( "wk:setUiDefaults", source )
end
end )

View File

@@ -1,9 +1,34 @@
--[[-----------------------------------------------------------------------
--[[---------------------------------------------------------------------------------------
Wraith ARS 2X
Created by WolfKnight
-----------------------------------------------------------------------]]--
For discussions, information on future updates, and more, join
my Discord: https://discord.gg/fD4e6WD
MIT License
Copyright (c) 2020 WolfKnight
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---------------------------------------------------------------------------------------]]--
-- Branding!
local label =
@@ -15,6 +40,8 @@ local label =
|| \ \/ \/ / '__/ _` | | __| '_ \ / /\ \ | _ / \___ \ / / > <
|| \ /\ /| | | (_| | | |_| | | | / ____ \| | \ \ ____) | / /_ / . \
|| \/ \/ |_| \__,_|_|\__|_| |_| /_/ \_\_| \_\_____/ |____/_/ \_\
||
|| Created by WolfKnight
||]]
-- Returns the current version set in fxmanifest.lua