Skip to content
This repository was archived by the owner on Apr 28, 2026. It is now read-only.

Commit 2163cf5

Browse files
fix(client): allow searching inventory for players with police job or target with canSteal (#35)
1 parent 29b32e0 commit 2163cf5

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

client.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ function client.openInventory(inv, data)
178178

179179
local targetCoords = targetPed and GetEntityCoords(targetPed)
180180

181-
if not targetCoords or #(targetCoords - GetEntityCoords(playerPed)) > 1.8 or not (client.hasGroup(shared.police) or not Player(serverId).state.canSteal) then
181+
if not targetCoords or #(targetCoords - GetEntityCoords(playerPed)) > 1.8 or (not client.hasGroup(shared.police) and not Player(serverId).state.canSteal) then
182182
return lib.notify({ id = 'inventory_right_access', type = 'error', description = locale('inventory_right_access') })
183183
end
184184
end
@@ -1376,7 +1376,7 @@ RegisterNetEvent('ox_inventory:setPlayerInventory', function(currentDrops, inven
13761376
local ped = GetPlayerPed(id)
13771377
local pedCoords = GetEntityCoords(ped)
13781378

1379-
if not id or #(playerCoords - pedCoords) > maxDistance or not (client.hasGroup(shared.police) or not Player(currentInventory.id).state.canSteal) then
1379+
if not id or #(playerCoords - pedCoords) > maxDistance or (not client.hasGroup(shared.police) and not Player(currentInventory.id).state.canSteal) then
13801380
client.closeInventory()
13811381
lib.notify({ id = 'inventory_lost_access', type = 'error', description = locale('inventory_lost_access') })
13821382
else

server.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,18 @@ lib.callback.register('ox_inventory:openInventory', function(source, invType, da
290290
if invType == 'player' and source ~= data then
291291
local serverId = type(data) == 'table' and data.id or data
292292

293-
if source == serverId or type(serverId) ~= 'number' or not Player(serverId).state.canSteal then return end
293+
if source == serverId or type(serverId) ~= 'number' then return end
294+
295+
local left = Inventory(source)
296+
if not left then return end
297+
298+
local isPolice = server.hasGroup(left, shared.police)
299+
local isTargetStealable = Player(serverId).state.canSteal
300+
301+
if not isPolice and not isTargetStealable then return end
294302
end
295303

296-
return openInventory(source, invType, data)
304+
return openInventory(source, invType, data)
297305
end)
298306

299307
---@param netId number

0 commit comments

Comments
 (0)