Skip to content

Commit

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

local alertSend = false
local public = {}

public.getIsVehicleImmune = getIsVehicleImmune -- to prevent circular-dependency error
public.getIsVehicleCarjackingImmune = getIsVehicleCarjackingImmune -- to prevent circular-dependency error

---Checks if player has vehicle keys
---@param plate string The plate number of the vehicle.
Expand Down
6 changes: 3 additions & 3 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local isBlacklistedWeapon = functions.isBlacklistedWeapon
local getIsVehicleAlwaysUnlocked = functions.getIsVehicleAlwaysUnlocked
local getVehicleByPlate = functions.getVehicleByPlate
local areKeysJobShared = functions.areKeysJobShared
local getIsVehicleImmune = functions.getIsVehicleImmune
local getIsVehicleCarjackingImmune = functions.getIsVehicleCarjackingImmune

-----------------------
---- Variables ----
Expand Down Expand Up @@ -313,7 +313,7 @@ local function watchCarjackingAttempts()
and not IsPedAPlayer(target)
then
local targetveh = GetVehiclePedIsIn(target, false)
local isVehicleImmune = getIsVehicleImmune(targetveh)
local isVehicleImmune = getIsVehicleCarjackingImmune(targetveh)

if not isVehicleImmune
and GetPedInVehicleSeat(targetveh, -1) == target
Expand Down Expand Up @@ -365,7 +365,7 @@ engineBind = lib.addKeybind({
RegisterNetEvent('QBCore:Client:VehicleInfo', function(data)
if not LocalPlayer.state.isLoggedIn and data.event ~= 'Entering' then return end
if getIsVehicleAlwaysUnlocked(data.vehicle) then return end
local isVehicleImmune = getIsVehicleImmune(data.vehicle)
local isVehicleImmune = getIsVehicleCarjackingImmune(data.vehicle)
local driver = GetPedInVehicleSeat(data.vehicle, -1)
local plate = qbx.getVehiclePlate(data.vehicle)

Expand Down
5 changes: 4 additions & 1 deletion server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ end)
---Lock every spawned vehicle
---@param vehicle number The entity number of the vehicle.
AddEventHandler('entityCreated', function (vehicle)
if not vehicle or GetEntityType(vehicle) ~= 2 or GetEntityPopulationType(vehicle) > 5 then return end
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 getIsVehicleAlwaysUnlocked(vehicle)
Expand Down
2 changes: 1 addition & 1 deletion shared/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ end
---Checking vehicle on the immunes list.
---@param vehicle any
---@return boolean? `true` if the vehicle is immune, `nil` otherwise.
function public.getIsVehicleImmune(vehicle)
function public.getIsVehicleCarjackingImmune(vehicle)
return getIsVehicleOnList(vehicle, config.immuneVehicles)
end

Expand Down

0 comments on commit ac78c9a

Please sign in to comment.