Skip to content

Commit

Permalink
feat(inventory): refill bin every 2 hours
Browse files Browse the repository at this point in the history
Former-commit-id: 697d8372d18a3f5eb87fbf301592fc1be1c8c89b
  • Loading branch information
sebastiendeu committed May 20, 2022
1 parent e75afe5 commit 1940c48
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions resources/[soz]/soz-inventory/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,16 @@ RegisterNetEvent("inventory:DropPlayerInventory", function(playerID --[[PlayerDa
end)

--- Loops
local function purgeBinLoop()
for _, inv in pairs(Inventories) do
if inv.datastore and inv.type == "bin" then
Inventory.Remove(inv)
end
end

SetTimeout(2 * 60 * 60 * 1000, purgeBinLoop)
end

local function saveInventories(loop)
for _, inv in pairs(Inventories) do
if not inv.datastore and inv.changed then
Expand All @@ -676,6 +686,7 @@ local function saveInventories(loop)
end

saveInventories(true)
purgeBinLoop()

-- Events
AddEventHandler("onResourceStart", function(resource)
Expand Down

0 comments on commit 1940c48

Please sign in to comment.