Skip to content

Commit

Permalink
refactor: getIsVehicleBlacklisted to getIsVehicleAlwaysUnlocked
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturMichalak committed Jun 23, 2024
1 parent 140ac46 commit 2185e11
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions client/functions.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local config = require 'config.client'
local functions = require 'shared.functions'
local getIsCloseToCoords = functions.getIsCloseToCoords
local getIsVehicleBlacklisted = functions.getIsVehicleBlacklisted
local getIsVehicleAlwaysUnlocked = functions.getIsVehicleAlwaysUnlocked
local getIsVehicleImmune = functions.getIsVehicleImmune

local alertSend = false
Expand Down Expand Up @@ -32,12 +32,12 @@ end
---Checking vehicle on the blacklist.
---@param vehicle number The entity number of the vehicle.
---@return boolean? `true` if the vehicle is blacklisted, `nil` otherwise.
function public.getIsVehicleBlacklisted(vehicle)
function public.getIsVehicleAlwaysUnlocked(vehicle)
if Entity(vehicle).state.ignoreLocks or GetVehicleClass(vehicle) == 13 then
return true
end

return getIsVehicleBlacklisted(vehicle)
return getIsVehicleAlwaysUnlocked(vehicle)
end

function public.attemptPoliceAlert(type)
Expand Down
8 changes: 4 additions & 4 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local hotwire = functions.hotwire
local lockpickDoor = functions.lockpickDoor
local attemptPoliceAlert = functions.attemptPoliceAlert
local isBlacklistedWeapon = functions.isBlacklistedWeapon
local getIsVehicleBlacklisted = functions.getIsVehicleBlacklisted
local getIsVehicleAlwaysUnlocked = functions.getIsVehicleAlwaysUnlocked
local getVehicleByPlate = functions.getVehicleByPlate
local areKeysJobShared = functions.areKeysJobShared
local getIsVehicleImmune = functions.getIsVehicleImmune
Expand Down Expand Up @@ -73,7 +73,7 @@ end
---@param anim any Aniation
local function setVehicleDoorLock(vehicle, state, anim)
if not vehicle then return end
if not getIsVehicleBlacklisted(vehicle) then
if not getIsVehicleAlwaysUnlocked(vehicle) then
if hasKeys(qbx.getVehiclePlate(vehicle)) or areKeysJobShared(vehicle) then

if anim then
Expand Down Expand Up @@ -181,7 +181,7 @@ local function showHotwiringLabel()
local plate = qbx.getVehiclePlate(cache.vehicle)
if cache.seat == -1
and not hasKeys(plate)
and not getIsVehicleBlacklisted(cache.vehicle)
and not getIsVehicleAlwaysUnlocked(cache.vehicle)
and not areKeysJobShared(cache.vehicle)
then
local vehiclePos = GetOffsetFromEntityInWorldCoords(cache.vehicle, 0.0, 1.0, 0.5)
Expand Down Expand Up @@ -364,7 +364,7 @@ engineBind = lib.addKeybind({

RegisterNetEvent('QBCore:Client:VehicleInfo', function(data)
if not LocalPlayer.state.isLoggedIn and data.event ~= 'Entering' then return end
if getIsVehicleBlacklisted(data.vehicle) then return end
if getIsVehicleAlwaysUnlocked(data.vehicle) then return end
local isVehicleImmune = getIsVehicleImmune(data.vehicle)
local driver = GetPedInVehicleSeat(data.vehicle, -1)
local plate = qbx.getVehiclePlate(data.vehicle)
Expand Down
4 changes: 2 additions & 2 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ local sharedFunctions = require 'shared.functions'
local giveKeys = functions.giveKeys
local addPlayer = functions.addPlayer
local removePlayer = functions.removePlayer
local getIsVehicleBlacklisted = sharedFunctions.getIsVehicleBlacklisted
local getIsVehicleAlwaysUnlocked = sharedFunctions.getIsVehicleAlwaysUnlocked

-----------------------
---- Events ----
Expand Down Expand Up @@ -59,6 +59,6 @@ AddEventHandler('entityCreated', function (vehicle)
if not vehicle or GetEntityType(vehicle) ~= 2 or GetEntityPopulationType(vehicle) > 5 then return end
local isDriver = GetPedInVehicleSeat(vehicle, -1) ~= 0
local isLocked = (config.lockNPCDrivenCars and isDriver) or (config.lockNPCParkedCars and not isDriver)
and GetVehicleType(vehicle) ~= 'bike' and not getIsVehicleBlacklisted(vehicle)
and GetVehicleType(vehicle) ~= 'bike' and not getIsVehicleAlwaysUnlocked(vehicle)
SetVehicleDoorsLocked(vehicle, isLocked and 2 or 1)
end)
2 changes: 1 addition & 1 deletion shared/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end
---Checking vehicle on the blacklist.
---@param vehicle number The entity number of the vehicle.
---@return boolean? `true` if the vehicle is blacklisted, `nil` otherwise.
function public.getIsVehicleBlacklisted(vehicle)
function public.getIsVehicleAlwaysUnlocked(vehicle)
return getIsVehicleOnList(vehicle, config.noLockVehicles)
end

Expand Down

0 comments on commit 2185e11

Please sign in to comment.