Skip to content

Commit

Permalink
refactor: move vehicle lockStatus check to the server
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed May 12, 2024
1 parent dbb9766 commit 11a5467
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 0 additions & 4 deletions modules/inventory/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ function Inventory.OpenTrunk(entity)

if not door then return end

if GetVehicleDoorLockStatus(entity) > 1 then
return lib.notify({ id = 'vehicle_locked', type = 'error', description = locale('vehicle_locked') })
end

local plate = GetVehicleNumberPlateText(entity)
local invId = 'trunk'..plate
local coords = GetEntityCoords(entity)
Expand Down
11 changes: 11 additions & 0 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,22 @@ local function openInventory(source, invType, data, ignoreSecurityChecks)

if data then
local isDataTable = type(data) == 'table'

if invType == 'stash' then
right = Inventory(data, left)
if right == false then return false end
elseif isDataTable then
if data.netid then
if invType == 'trunk' then
local entity = NetworkGetEntityFromNetworkId(data.netid)
local lockStatus = entity > 0 and GetVehicleDoorLockStatus(entity)

-- 0: no lock; 1: unlocked; 8: boot unlocked
if lockStatus > 1 and lockStatus ~= 8 then
return false, false, 'vehicle_locked'
end
end

data.type = invType
right = Inventory(data)
elseif invType == 'drop' then
Expand Down

0 comments on commit 11a5467

Please sign in to comment.