Client Editable

function openInventory(id, password, level)
    local name = "selftrorage" .. id
    local stash = {
        maxweight = config.stash[level].maxweight,
        slots = config.stash[level].slots
    }

    if GetResourceState("tgiann-inventory") == "started" then
        TriggerServerEvent("inventory:server:OpenInventory", "stash", name, stash, { password = password })
    elseif config.framework == "qb" then
        TriggerEvent("inventory:client:SetCurrentStash", name, tgiCore.core.Key)
        TriggerServerEvent("inventory:server:OpenInventory", "stash", name, stash, { password = password })
    elseif config.framework == "esx" then
        local ox_inventory = exports.ox_inventory
        if ox_inventory:openInventory('stash', name) == false then
            TriggerServerEvent('tgiann-self-storage:oxStash', name, stash)
            ox_inventory:openInventory('stash', name)
        end
    end
end

local function notify(text, type, time)
    if not time then time = 5000 end
    sendNui("app-main", "notify", {
        text = text,
        type = type,
        time = time
    })
end

RegisterNetEvent('tgiann-self-storage-v2:notify')
AddEventHandler('tgiann-self-storage-v2:notify', notify)

RegisterNUICallback("notify", function(data, cb)
    notify(data.text, data.type, data.time)
    cb("")
end)

--[[ function playerIsPolice(index)
    local storageData = config.storages[index]
    local isPolice = false
    if storageData.policeCanRaid.active then
        if not PlayerData then PlayerData = tgiCoreExports:getPlayerData() end
        for i = 1, #config.policeJobs do
            if config.policeJobs[i] == PlayerData.job.name and PlayerData.job.grade >= storageData.policeCanRaid.minGrade then
                isPolice = true
                break
            end
        end
    end
    return isPolice
end ]]

function getItemImg(item)
    return item.image or (item.name .. config.itemIMGExtension)
end

Last updated