Skip to content

Commit

Permalink
fix(server): prevent opening other player inventory when it is open
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Apr 24, 2023
1 parent 24a875f commit 8ea808c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ lib.callback.register('ox_inventory:openInventory', function(source, inv, data)
else right = Inventory(data) end

if right then
if right.open or (right.groups and not server.hasGroup(left, right.groups)) then return end
if right.groups and not server.hasGroup(left, right.groups) then return end

local hookPayload = {
source = source,
Expand All @@ -131,7 +131,11 @@ lib.callback.register('ox_inventory:openInventory', function(source, inv, data)

if not TriggerEventHooks('openInventory', hookPayload) then return end

if right.player then right.coords = GetEntityCoords(GetPlayerPed(right.id)) end
if right.player then
if right.open then return end

right.coords = GetEntityCoords(right.player.ped)
end

if right.coords == nil or #(right.coords - GetEntityCoords(GetPlayerPed(source))) < 10 then
Inventory.Open(left, right)
Expand Down

0 comments on commit 8ea808c

Please sign in to comment.