ed
This commit is contained in:
		
							parent
							
								
									032ec698d8
								
							
						
					
					
						commit
						1010f8fc79
					
				
					 49 changed files with 5818 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
if GetResourceState('es_extended') == 'started' then return end
 | 
			
		||||
if GetResourceState('qb-core') == 'started' then return end
 | 
			
		||||
 | 
			
		||||
print("You are not using a supported framework, it will be required to make edits to the bridge files.")
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
if GetResourceState('es_extended') == 'started' then return end
 | 
			
		||||
if GetResourceState('qb-core') == 'started' then return end
 | 
			
		||||
 | 
			
		||||
print("You are not using a supported framework, it will be required to make edits to the bridge files.")
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
if GetResourceState('es_extended') ~= 'started' then return end
 | 
			
		||||
 | 
			
		||||
ESX = exports.es_extended:getSharedObject()
 | 
			
		||||
 | 
			
		||||
function ShowNotification(text)
 | 
			
		||||
	ESX.ShowNotification(text)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function GetPlayersInArea(coords, radius)
 | 
			
		||||
    local coords = coords or GetEntityCoords(PlayerPedId())
 | 
			
		||||
    local radius = radius or 3.0
 | 
			
		||||
    local list = ESX.Game.GetPlayersInArea(coords, radius)
 | 
			
		||||
    local players = {}
 | 
			
		||||
    for _, player in pairs(list) do 
 | 
			
		||||
        if player ~= PlayerId() then
 | 
			
		||||
            players[#players + 1] = player
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
    return players
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
RegisterNetEvent(GetCurrentResourceName()..":showNotification", function(text)
 | 
			
		||||
    ShowNotification(text)
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
RegisterNetEvent('esx:playerLoaded')
 | 
			
		||||
AddEventHandler('esx:playerLoaded',function(xPlayer, isNew, skin)
 | 
			
		||||
    TriggerServerEvent("pickle_consumables:initializePlayer")
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
RegisterNetEvent("pickle_consumables:executeStatus", function(status, value)
 | 
			
		||||
    if value >= 0 then
 | 
			
		||||
        TriggerEvent('esx_status:add', status, value)
 | 
			
		||||
    else
 | 
			
		||||
        TriggerEvent('esx_status:remove', status, value)
 | 
			
		||||
    end
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
-- Inventory Fallback
 | 
			
		||||
 | 
			
		||||
CreateThread(function()
 | 
			
		||||
    Wait(100)
 | 
			
		||||
    if InitializeInventory then return InitializeInventory() end -- Already loaded through inventory folder.
 | 
			
		||||
    print("The only supported inventory for ESX is ox_inventory and qs-inventory, if you would like to port to a different inventory, please use the example shown in the inventory folder.")
 | 
			
		||||
end)
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,76 @@
 | 
			
		|||
if GetResourceState('es_extended') ~= 'started' then return end
 | 
			
		||||
 | 
			
		||||
RegisterUsableItem = nil
 | 
			
		||||
Framework = "ESX"
 | 
			
		||||
ESX = exports.es_extended:getSharedObject()
 | 
			
		||||
 | 
			
		||||
function ShowNotification(target, text)
 | 
			
		||||
	TriggerClientEvent(GetCurrentResourceName()..":showNotification", target, text)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function GetIdentifier(source)
 | 
			
		||||
    local xPlayer = ESX.GetPlayerFromId(source)
 | 
			
		||||
    return xPlayer.identifier
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function SetPlayerMetadata(source, key, data)
 | 
			
		||||
    -- No player metadata in ESX.
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function AddMoney(source, count)
 | 
			
		||||
    local xPlayer = ESX.GetPlayerFromId(source)
 | 
			
		||||
    xPlayer.addMoney(count)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function RemoveMoney(source, count)
 | 
			
		||||
    local xPlayer = ESX.GetPlayerFromId(source)
 | 
			
		||||
    xPlayer.removeMoney(count)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function GetMoney(source)
 | 
			
		||||
    local xPlayer = ESX.GetPlayerFromId(source)
 | 
			
		||||
    return xPlayer.getMoney()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function CheckPermission(source, permission)
 | 
			
		||||
    local xPlayer = ESX.GetPlayerFromId(source)
 | 
			
		||||
    local name = xPlayer.job.name
 | 
			
		||||
    local rank = xPlayer.job.grade
 | 
			
		||||
    local group = xPlayer.getGroup()
 | 
			
		||||
    if permission.jobs[name] and permission.jobs[name] <= rank then 
 | 
			
		||||
        return true
 | 
			
		||||
    end
 | 
			
		||||
    for i=1, #permission.groups do 
 | 
			
		||||
        if group == permission.groups[i] then 
 | 
			
		||||
            return true 
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Status
 | 
			
		||||
 | 
			
		||||
function ExecuteStatus(source, statuses)
 | 
			
		||||
    local xPlayer = ESX.GetPlayerFromId(source)
 | 
			
		||||
    for k,v in pairs(statuses) do 
 | 
			
		||||
        if Config.MaxValues[k] then
 | 
			
		||||
            local value = (0.01 * v) * Config.MaxValues[k]
 | 
			
		||||
            TriggerClientEvent("pickle_consumables:executeStatus", source, k, value)
 | 
			
		||||
        else
 | 
			
		||||
            Config.ExternalStatus(source, k, v)
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
-- Inventory Fallback
 | 
			
		||||
 | 
			
		||||
CreateThread(function()
 | 
			
		||||
    Wait(100)
 | 
			
		||||
    if not UsableItem then 
 | 
			
		||||
        RegisterUsableItem = function(name, cb)
 | 
			
		||||
            ESX.RegisterUsableItem(name, function(source, item, data) 
 | 
			
		||||
		if not data then data = {} end
 | 
			
		||||
                cb(source, data.metadata, data.slot)
 | 
			
		||||
            end)
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
    if InitializeInventory then return InitializeInventory() end -- Already loaded through inventory folder.
 | 
			
		||||
end)
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,7 @@
 | 
			
		|||
local DefaultMax = 1000000
 | 
			
		||||
 | 
			
		||||
for k,v in pairs(Config.MaxValues) do 
 | 
			
		||||
    if v < 1 then
 | 
			
		||||
        Config.MaxValues[k] = DefaultMax
 | 
			
		||||
    end  
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,15 @@
 | 
			
		|||
if GetResourceState('ox_inventory') ~= 'started' then return end
 | 
			
		||||
 | 
			
		||||
Inventory = {}
 | 
			
		||||
 | 
			
		||||
Inventory.Items = {}
 | 
			
		||||
 | 
			
		||||
Inventory.Ready = false
 | 
			
		||||
 | 
			
		||||
RegisterNetEvent("pickle_consumables:setupInventory", function(data)
 | 
			
		||||
    Inventory.Items = data.items
 | 
			
		||||
    Inventory.Ready = true
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
function InitializeInventory()
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,55 @@
 | 
			
		|||
if GetResourceState('ox_inventory') ~= 'started' then return end
 | 
			
		||||
 | 
			
		||||
Inventory = {}
 | 
			
		||||
 | 
			
		||||
Inventory.Items = {}
 | 
			
		||||
 | 
			
		||||
Inventory.Ready = false
 | 
			
		||||
 | 
			
		||||
Inventory.CanCarryItem = function(source, name, count)
 | 
			
		||||
    return exports.ox_inventory:CanCarryItem(source, name, count)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Inventory.GetInventory = function(source)
 | 
			
		||||
    local items = {}
 | 
			
		||||
    local data = exports.ox_inventory:GetInventoryItems(source)
 | 
			
		||||
    for slot, item in pairs(data) do 
 | 
			
		||||
        items[#items + 1] = {
 | 
			
		||||
            name = item.name,
 | 
			
		||||
            label = item.label,
 | 
			
		||||
            count = item.count,
 | 
			
		||||
            weight = item.weight,
 | 
			
		||||
            slot = item.slot,
 | 
			
		||||
            metadata = item.metadata
 | 
			
		||||
        }
 | 
			
		||||
    end
 | 
			
		||||
    return items
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Inventory.AddItem = function(source, name, count, metadata, slot) -- Metadata is not required.
 | 
			
		||||
    exports.ox_inventory:AddItem(source, name, count, metadata, slot)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Inventory.RemoveItem = function(source, name, count, slot)
 | 
			
		||||
    exports.ox_inventory:RemoveItem(source, name, count, nil, slot)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Inventory.SetMetadata = function(source, slot, metadata)
 | 
			
		||||
    exports.ox_inventory:SetMetadata(source, slot, metadata)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Inventory.GetItemCount = function(source, name)
 | 
			
		||||
    return exports.ox_inventory:Search(source, "count", name) or 0
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function InitializeInventory()
 | 
			
		||||
    lib.callback.register("pickle_consumables:getInventory", function(source)
 | 
			
		||||
        return Inventory.GetInventory(source)
 | 
			
		||||
    end)
 | 
			
		||||
    
 | 
			
		||||
    for item, data in pairs(exports.ox_inventory:Items()) do
 | 
			
		||||
        Inventory.Items[item] = {label = data.label}
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
    Inventory.Ready = true
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,15 @@
 | 
			
		|||
if GetResourceState('tgiann-inventory') ~= 'started' then return end
 | 
			
		||||
 | 
			
		||||
Inventory = {}
 | 
			
		||||
 | 
			
		||||
Inventory.Items = {}
 | 
			
		||||
 | 
			
		||||
Inventory.Ready = false
 | 
			
		||||
 | 
			
		||||
RegisterNetEvent("pickle_consumables:setupInventory", function(data)
 | 
			
		||||
    Inventory.Items = data.items
 | 
			
		||||
    Inventory.Ready = true
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
function InitializeInventory()
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,74 @@
 | 
			
		|||
if GetResourceState('qs-inventory') ~= 'started' then return end
 | 
			
		||||
 | 
			
		||||
Inventory = {}
 | 
			
		||||
 | 
			
		||||
Inventory.Items = {}
 | 
			
		||||
 | 
			
		||||
Inventory.Ready = false
 | 
			
		||||
 | 
			
		||||
Inventory.CanCarryItem = function(source, name, count)
 | 
			
		||||
    return exports['qs-inventory']:CanCarryItem(source, name, count)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Inventory.GetInventory = function(source)
 | 
			
		||||
    local items = {}
 | 
			
		||||
    local data = exports['qs-inventory']:GetInventory(source)
 | 
			
		||||
    for slot, item in pairs(data) do 
 | 
			
		||||
        items[#items + 1] = {
 | 
			
		||||
            name = item.name,
 | 
			
		||||
            label = item.label,
 | 
			
		||||
            count = item.amount,
 | 
			
		||||
            weight = item.weight,
 | 
			
		||||
            slot = item.slot,
 | 
			
		||||
            metadata = item.info
 | 
			
		||||
        }
 | 
			
		||||
    end
 | 
			
		||||
    return items
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Inventory.AddItem = function(source, name, count, metadata, slot) -- Metadata is not required.
 | 
			
		||||
    exports['qs-inventory']:AddItem(source, name, count, slot, metadata)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Inventory.RemoveItem = function(source, name, count, slot)
 | 
			
		||||
    exports['qs-inventory']:RemoveItem(source, name, count, slot)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Inventory.SetMetadata = function(source, slot, metadata)
 | 
			
		||||
    exports['qs-inventory']:SetItemMetadata(source, slot, metadata)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Inventory.GetItemCount = function(source, name)
 | 
			
		||||
    return exports['qs-inventory']:GetItemTotalAmount(source, name) or 0
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function InitializeInventory()
 | 
			
		||||
    lib.callback.register("pickle_consumables:getInventory", function(source)
 | 
			
		||||
        return Inventory.GetInventory(source)
 | 
			
		||||
    end)
 | 
			
		||||
    
 | 
			
		||||
    for item, data in pairs(exports['qs-inventory']:GetItemList()) do
 | 
			
		||||
        Inventory.Items[item] = {label = data.label}
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
    Inventory.Ready = true
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if Framework == "ESX" then
 | 
			
		||||
    function UsableItem(name, cb)
 | 
			
		||||
        ESX.RegisterUsableItem(name, function(source, item, data) 
 | 
			
		||||
            cb(source, data.metadata, data.slot)
 | 
			
		||||
        end)
 | 
			
		||||
    end
 | 
			
		||||
elseif Framework == "QB" or Framework == "QBOX" then
 | 
			
		||||
    function UsableItem(name, cb)
 | 
			
		||||
        QBCore.Functions.CreateUseableItem(name, function(source, data)
 | 
			
		||||
            local item = data
 | 
			
		||||
            if item.info then
 | 
			
		||||
                item.metadata = data.info
 | 
			
		||||
                item.info = nil
 | 
			
		||||
            end
 | 
			
		||||
            cb(source, item.metadata, item.slot)
 | 
			
		||||
        end)
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,47 @@
 | 
			
		|||
if GetResourceState('qb-core') ~= 'started' then return end
 | 
			
		||||
 | 
			
		||||
QBCore = exports['qb-core']:GetCoreObject()
 | 
			
		||||
 | 
			
		||||
function ShowNotification(text)
 | 
			
		||||
	QBCore.Functions.Notify(text)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function GetPlayersInArea(coords, radius)
 | 
			
		||||
    local coords = coords or GetEntityCoords(PlayerPedId())
 | 
			
		||||
    local radius = radius or 3.0
 | 
			
		||||
    local list = QBCore.Functions.GetPlayersFromCoords(coords, radius)
 | 
			
		||||
    local players = {}
 | 
			
		||||
    for _, player in pairs(list) do 
 | 
			
		||||
        if player ~= PlayerId() then
 | 
			
		||||
            players[#players + 1] = player
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
    return players
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
RegisterNetEvent(GetCurrentResourceName()..":showNotification", function(text)
 | 
			
		||||
    ShowNotification(text)
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
 | 
			
		||||
    TriggerServerEvent("pickle_consumables:initializePlayer")
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
-- Inventory Fallback
 | 
			
		||||
 | 
			
		||||
CreateThread(function()
 | 
			
		||||
    Wait(100)
 | 
			
		||||
    
 | 
			
		||||
    if InitializeInventory then return InitializeInventory() end -- Already loaded through inventory folder.
 | 
			
		||||
 | 
			
		||||
    Inventory = {}
 | 
			
		||||
 | 
			
		||||
    Inventory.Items = {}
 | 
			
		||||
    
 | 
			
		||||
    Inventory.Ready = false
 | 
			
		||||
    
 | 
			
		||||
    RegisterNetEvent("pickle_consumables:setupInventory", function(data)
 | 
			
		||||
        Inventory.Items = data.items
 | 
			
		||||
        Inventory.Ready = true
 | 
			
		||||
    end)
 | 
			
		||||
end)
 | 
			
		||||
							
								
								
									
										149
									
								
								resources/[inventory]/pickle_consumables/bridge/qb/server.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										149
									
								
								resources/[inventory]/pickle_consumables/bridge/qb/server.lua
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,149 @@
 | 
			
		|||
if GetResourceState('qb-core') ~= 'started' then return end
 | 
			
		||||
 | 
			
		||||
Framework = "QB"
 | 
			
		||||
QBCore = exports['qb-core']:GetCoreObject()
 | 
			
		||||
 | 
			
		||||
function ShowNotification(target, text)
 | 
			
		||||
	TriggerClientEvent(GetCurrentResourceName()..":showNotification", target, text)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function GetIdentifier(source)
 | 
			
		||||
    local xPlayer = QBCore.Functions.GetPlayer(source).PlayerData
 | 
			
		||||
    return xPlayer.citizenid 
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function SetPlayerMetadata(source, key, data)
 | 
			
		||||
    QBCore.Functions.GetPlayer(source).Functions.SetMetaData(key, data)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function AddMoney(source, count)
 | 
			
		||||
    local xPlayer = QBCore.Functions.GetPlayer(source)
 | 
			
		||||
    xPlayer.Functions.AddMoney('cash',count)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function RemoveMoney(source, count)
 | 
			
		||||
    local xPlayer = QBCore.Functions.GetPlayer(source)
 | 
			
		||||
    xPlayer.Functions.RemoveMoney('cash',count)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function GetMoney(source)
 | 
			
		||||
    local xPlayer = QBCore.Functions.GetPlayer(source)
 | 
			
		||||
    return xPlayer.PlayerData.money.cash
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function CheckPermission(source, permission)
 | 
			
		||||
    local xPlayer = QBCore.Functions.GetPlayer(source).PlayerData
 | 
			
		||||
    local name = xPlayer.job.name
 | 
			
		||||
    local rank = xPlayer.job.grade.level
 | 
			
		||||
    if permission.jobs[name] and permission.jobs[name] <= rank then 
 | 
			
		||||
        return true
 | 
			
		||||
    end
 | 
			
		||||
    for i=1, #permission.groups do 
 | 
			
		||||
        if QBCore.Functions.HasPermission(source, permission.groups[i]) then 
 | 
			
		||||
            return true 
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Status
 | 
			
		||||
 | 
			
		||||
function ExecuteStatus(source, statuses)
 | 
			
		||||
    local xPlayer = QBCore.Functions.GetPlayer(source)
 | 
			
		||||
    for k,v in pairs(statuses) do 
 | 
			
		||||
        if Config.MaxValues[k] then
 | 
			
		||||
            local value = (0.01 * v) * Config.MaxValues[k]
 | 
			
		||||
            if xPlayer.PlayerData.metadata[k] then
 | 
			
		||||
                xPlayer.PlayerData.metadata[k] = ((xPlayer.PlayerData.metadata[k] + value < 0) and 0 or (xPlayer.PlayerData.metadata[k] + value))
 | 
			
		||||
            else
 | 
			
		||||
                xPlayer.PlayerData.metadata[k] = (value > 0 and value or 0)
 | 
			
		||||
            end
 | 
			
		||||
            xPlayer.Functions.SetMetaData(k, xPlayer.PlayerData.metadata[k])
 | 
			
		||||
            TriggerClientEvent('hud:client:UpdateNeeds', source, xPlayer.PlayerData.metadata.hunger, xPlayer.PlayerData.metadata.thirst)
 | 
			
		||||
        else
 | 
			
		||||
            Config.ExternalStatus(source, k, v)
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Inventory Fallback
 | 
			
		||||
 | 
			
		||||
CreateThread(function()
 | 
			
		||||
    Wait(100)
 | 
			
		||||
    
 | 
			
		||||
    if not UsableItem then 
 | 
			
		||||
        function RegisterUsableItem(name, cb)
 | 
			
		||||
            QBCore.Functions.CreateUseableItem(name, function(source, data)
 | 
			
		||||
                local item = data
 | 
			
		||||
                if item.info then
 | 
			
		||||
                    item.metadata = data.info
 | 
			
		||||
                    item.info = nil
 | 
			
		||||
                end
 | 
			
		||||
                cb(source, item.metadata, item.slot)
 | 
			
		||||
            end)
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if InitializeInventory then return InitializeInventory() end -- Already loaded through inventory folder.
 | 
			
		||||
    
 | 
			
		||||
    Inventory = {}
 | 
			
		||||
 | 
			
		||||
    Inventory.Items = {}
 | 
			
		||||
    
 | 
			
		||||
    Inventory.Ready = false
 | 
			
		||||
 | 
			
		||||
    Inventory.CanCarryItem = function(source, name, count)
 | 
			
		||||
        local slots = 40 -- Change this if higher / lower.
 | 
			
		||||
        local items = Inventory.GetInventory(source)
 | 
			
		||||
        return (#items + count < slots)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    Inventory.GetInventory = function(source)
 | 
			
		||||
        local xPlayer = QBCore.Functions.GetPlayer(source)
 | 
			
		||||
        local items = {}
 | 
			
		||||
        local data = xPlayer.PlayerData.items
 | 
			
		||||
        for slot, item in pairs(data) do 
 | 
			
		||||
            items[#items + 1] = {
 | 
			
		||||
                name = item.name,
 | 
			
		||||
                label = item.label,
 | 
			
		||||
                count = item.amount,
 | 
			
		||||
                weight = item.weight,
 | 
			
		||||
                slot = item.slot,
 | 
			
		||||
                metadata = item.info
 | 
			
		||||
            }
 | 
			
		||||
        end
 | 
			
		||||
        return items
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    Inventory.AddItem = function(source, name, count, metadata, slot) -- Metadata is not required.
 | 
			
		||||
        local xPlayer = QBCore.Functions.GetPlayer(source)
 | 
			
		||||
        xPlayer.Functions.AddItem(name, count, slot, metadata)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    Inventory.RemoveItem = function(source, name, count, slot)
 | 
			
		||||
        local xPlayer = QBCore.Functions.GetPlayer(source)
 | 
			
		||||
        xPlayer.Functions.RemoveItem(name, count, slot)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
    Inventory.SetMetadata = function(source, slot, metadata)
 | 
			
		||||
        local xPlayer = QBCore.Functions.GetPlayer(source)
 | 
			
		||||
        local Inventory = xPlayer.PlayerData.items
 | 
			
		||||
        Inventory[slot].info = metadata
 | 
			
		||||
        xPlayer.Functions.SetInventory(Inventory, true)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
    Inventory.GetItemCount = function(source, name)
 | 
			
		||||
        local xPlayer = QBCore.Functions.GetPlayer(source)
 | 
			
		||||
        local item = xPlayer.Functions.GetItemByName(name)
 | 
			
		||||
        return item and item.amount or 0
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    lib.callback.register("pickle_consumables:getInventory", function(source)
 | 
			
		||||
        return Inventory.GetInventory(source)
 | 
			
		||||
    end)
 | 
			
		||||
 | 
			
		||||
    for item, data in pairs(QBCore.Shared.Items) do
 | 
			
		||||
        Inventory.Items[item] = {label = data.label}
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    Inventory.Ready = true
 | 
			
		||||
end)
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,7 @@
 | 
			
		|||
local DefaultMax = 100
 | 
			
		||||
 | 
			
		||||
for k,v in pairs(Config.MaxValues) do 
 | 
			
		||||
    if v < 1 then
 | 
			
		||||
        Config.MaxValues[k] = DefaultMax
 | 
			
		||||
    end  
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,26 @@
 | 
			
		|||
if GetResourceState('ox_target') ~= 'started' or not Config.UseTarget then return end
 | 
			
		||||
 | 
			
		||||
function AddTargetModel(models, radius, options)
 | 
			
		||||
    local optionsNames = {}
 | 
			
		||||
    for i=1, #options do 
 | 
			
		||||
        optionsNames[i] = options[i].name
 | 
			
		||||
    end
 | 
			
		||||
    RemoveTargetModel(models, optionsNames)
 | 
			
		||||
    exports.ox_target:addModel(models, options)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function RemoveTargetModel(models, optionsNames)
 | 
			
		||||
    exports.ox_target:removeModel(models, optionsNames)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function AddTargetZone(coords, radius, options)
 | 
			
		||||
    return exports.ox_target:addSphereZone({
 | 
			
		||||
        coords = coords,
 | 
			
		||||
        radius = radius,
 | 
			
		||||
        options = options
 | 
			
		||||
    })
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function RemoveTargetZone(index)
 | 
			
		||||
    exports.ox_target:removeZone(index)
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,49 @@
 | 
			
		|||
if GetResourceState('ox_target') == 'started' or GetResourceState('qb-target') ~= 'started' or not Config.UseTarget then return end
 | 
			
		||||
 | 
			
		||||
local Zones = {}
 | 
			
		||||
 | 
			
		||||
function AddTargetModel(models, radius, options)
 | 
			
		||||
    local optionsNames = {}
 | 
			
		||||
    for i=1, #options do 
 | 
			
		||||
        optionsNames[i] = options[i].name
 | 
			
		||||
        if options[i].onSelect then
 | 
			
		||||
            local cb = options[i].onSelect
 | 
			
		||||
            options[i].action = function(entity)
 | 
			
		||||
                cb({entity = entity})
 | 
			
		||||
            end
 | 
			
		||||
            options[i].onSelect = nil
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
    RemoveTargetModel(models, optionsNames)
 | 
			
		||||
    exports['qb-target']:AddTargetModel(models, {options = options, distance = 2.5})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function RemoveTargetModel(models, optionsNames)
 | 
			
		||||
    exports['qb-target']:RemoveTargetModel(models, optionsNames)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function AddTargetZone(coords, radius, options)
 | 
			
		||||
    local index
 | 
			
		||||
    repeat
 | 
			
		||||
        index = "lottery_coord_" .. math.random(1, 999999999)
 | 
			
		||||
    until not Zones[index]
 | 
			
		||||
    for i=1, #options do 
 | 
			
		||||
        if options[i].onSelect then
 | 
			
		||||
            local cb = options[i].onSelect
 | 
			
		||||
            options[i].action = function(entity)
 | 
			
		||||
                cb({entity = entity})
 | 
			
		||||
            end
 | 
			
		||||
            options[i].onSelect = nil
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
    exports['qb-target']:AddCircleZone(index, coords, radius, {name = index}, {
 | 
			
		||||
        options = options
 | 
			
		||||
    })
 | 
			
		||||
    return index
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function RemoveTargetZone(index)
 | 
			
		||||
    if not index then return end
 | 
			
		||||
    Zones[index] = nil
 | 
			
		||||
    exports['qb-target']:RemoveZone(index)
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,37 @@
 | 
			
		|||
if GetResourceState('ox_target') == 'started' or GetResourceState('qtarget') ~= 'started' or not Config.UseTarget then return end
 | 
			
		||||
 | 
			
		||||
local Zones = {}
 | 
			
		||||
 | 
			
		||||
function AddTargetModel(models, radius, options)
 | 
			
		||||
    local optionsNames = {}
 | 
			
		||||
    for i=1, #options do 
 | 
			
		||||
        optionsNames[i] = options[i].name
 | 
			
		||||
    end
 | 
			
		||||
    RemoveTargetModel(models, optionsNames)
 | 
			
		||||
    exports['qtarget']:AddTargetModel(models, {options = options, distance = 2.5})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function RemoveTargetModel(models, optionsNames)
 | 
			
		||||
    exports['qtarget']:RemoveTargetModel(models, optionsNames)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function AddTargetZone(coords, radius, options)
 | 
			
		||||
    local index
 | 
			
		||||
    repeat
 | 
			
		||||
        index = "lottery_coord_" .. math.random(1, 999999999)
 | 
			
		||||
    until not Zones[index]
 | 
			
		||||
    exports['qtarget']:AddBoxZone(index, coords, radius, radius, {
 | 
			
		||||
        name = index,
 | 
			
		||||
        heading = 0.0,
 | 
			
		||||
        minZ = coords.z,
 | 
			
		||||
        maxZ = coords.z + radius,
 | 
			
		||||
    }, {
 | 
			
		||||
        options = options,
 | 
			
		||||
    })
 | 
			
		||||
    return index
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function RemoveTargetZone(index)
 | 
			
		||||
    Zones[index] = nil
 | 
			
		||||
    exports['qtarget']:RemoveZone(index)
 | 
			
		||||
end
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue