Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local status = 2
- local wait_time = 0
- local get_available_chest = function()
- local backend_items = Managers.backend:get_interface("items")
- local all_items = backend_items:get_all_backend_items()
- for backend_id, item in pairs(all_items) do
- local data = item.data
- local RemainingUses = item.RemainingUses or 0
- local item_type = data and data.item_type or ""
- if item_type == "loot_chest" and RemainingUses > 0 then
- return backend_id, RemainingUses
- end
- end
- return nil
- end
- local open_next_chest = function()
- local backend_id, total = get_available_chest()
- if backend_id then
- -- Open Chest
- local backend_loot = Managers.backend:get_interface("loot")
- --backend_loot:open_loot_chest("witch_hunter", backend_id)
- --backend_loot:open_loot_chest("bright_wizard", backend_id)
- --backend_loot:open_loot_chest("dwarf_ranger", backend_id)
- backend_loot:open_loot_chest("wood_elf", backend_id)
- --backend_loot:open_loot_chest("empire_soldier", backend_id)
- -- Debug
- EchoConsole("Open box " .. tostring(backend_id) .. " - " .. tostring(total))
- return true
- else
- Mods.exec("loadfile", "salvage_low")
- end
- return false
- end
- Mods.hook.set("", "BackendInterfaceLootPlayfab.loot_chest_rewards_request_cb", function(func, self, id, result)
- func(self, id, result)
- status = 2
- end)
- Mods.hook.set("", "MatchmakingManager.update", function(func, self, dt, t)
- safe_pcall(function()
- if status == 0 then
- if open_next_chest() then
- status = 1
- end
- elseif status == 2 then
- wait_time = t
- status = 3
- elseif status == 3 then
- if wait_time + 1 < t then
- status = 0
- end
- end
- end)
- return func(self, dt, t)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement