From 11a546777fb3dd9fb320dcac56af329f9c2bc7f2 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Mon, 13 May 2024 06:04:07 +1000 Subject: [PATCH] refactor: move vehicle lockStatus check to the server --- modules/inventory/client.lua | 4 ---- server.lua | 11 +++++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/inventory/client.lua b/modules/inventory/client.lua index 0b5183300..3328688db 100644 --- a/modules/inventory/client.lua +++ b/modules/inventory/client.lua @@ -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) diff --git a/server.lua b/server.lua index 327ce20d7..499d5de71 100644 --- a/server.lua +++ b/server.lua @@ -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