forked from Simnation/Main
ed
This commit is contained in:
parent
bd8bb2d99b
commit
5f22a1888a
2 changed files with 77 additions and 25 deletions
|
@ -23,19 +23,29 @@ end
|
||||||
--remove items
|
--remove items
|
||||||
local function removeItem(src, item, amount)
|
local function removeItem(src, item, amount)
|
||||||
if InvType == 'qb' then
|
if InvType == 'qb' then
|
||||||
if exports['qb-inventory']:RemoveItem(src, item, amount, false, false, false) then
|
-- Modified for tgiann-inventory
|
||||||
TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'remove', amount)
|
if exports['tgiann-inventory']:RemoveItem(src, item, amount) then
|
||||||
|
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'remove', amount)
|
||||||
end
|
end
|
||||||
elseif InvType == 'ox' then
|
elseif InvType == 'ox' then
|
||||||
exports.ox_inventory:RemoveItem(src, item, amount)
|
exports.ox_inventory:RemoveItem(src, item, amount)
|
||||||
|
elseif InvType == 'tgiann' then
|
||||||
|
-- Direct support for tgiann-inventory
|
||||||
|
exports['tgiann-inventory']:RemoveItem(src, item, amount)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--add items
|
--add items
|
||||||
local function addItem(src, item, amount)
|
local function addItem(src, item, amount)
|
||||||
if InvType == 'qb' then
|
if InvType == 'qb' then
|
||||||
if exports['qb-inventory']:AddItem(src, item, amount, false, false, false) then
|
-- Modified for tgiann-inventory
|
||||||
TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'add', amount)
|
if exports['tgiann-inventory']:AddItem(src, item, amount, nil, {
|
||||||
|
serie = "SMOKING-" .. math.random(100000, 999999),
|
||||||
|
durabilityPercent = 100,
|
||||||
|
usedTotalAmmo = 0,
|
||||||
|
ammo = 0
|
||||||
|
}) then
|
||||||
|
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'add', amount)
|
||||||
end
|
end
|
||||||
elseif InvType == 'ox' then
|
elseif InvType == 'ox' then
|
||||||
if exports.ox_inventory:CanCarryItem(src, item, amount) then
|
if exports.ox_inventory:CanCarryItem(src, item, amount) then
|
||||||
|
@ -43,6 +53,18 @@ local function addItem(src, item, amount)
|
||||||
else
|
else
|
||||||
SendNotify(src, Config.Language.Notifications.CantCarry, 'error', 5000)
|
SendNotify(src, Config.Language.Notifications.CantCarry, 'error', 5000)
|
||||||
end
|
end
|
||||||
|
elseif InvType == 'tgiann' then
|
||||||
|
-- Direct support for tgiann-inventory
|
||||||
|
local metadata = {}
|
||||||
|
if string.match(item, "weapon_") then
|
||||||
|
metadata = {
|
||||||
|
serie = "SMOKING-" .. math.random(100000, 999999),
|
||||||
|
durabilityPercent = 100,
|
||||||
|
usedTotalAmmo = 0,
|
||||||
|
ammo = 0
|
||||||
|
}
|
||||||
|
end
|
||||||
|
exports['tgiann-inventory']:AddItem(src, item, amount, nil, metadata)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -61,8 +83,15 @@ QBCore.Functions.CreateCallback('lusty94_smoking:server:hasItem', function(sourc
|
||||||
local item = Config.Consumables[itemName]
|
local item = Config.Consumables[itemName]
|
||||||
if item then
|
if item then
|
||||||
if item.requiredItem then
|
if item.requiredItem then
|
||||||
local requiredItem = Player.Functions.GetItemByName(item.requiredItem)
|
local hasItem = false
|
||||||
if requiredItem then
|
if InvType == 'tgiann' then
|
||||||
|
hasItem = exports['tgiann-inventory']:HasItem(src, item.requiredItem, 1)
|
||||||
|
else
|
||||||
|
local requiredItem = Player.Functions.GetItemByName(item.requiredItem)
|
||||||
|
hasItem = requiredItem ~= nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if hasItem then
|
||||||
cb(true)
|
cb(true)
|
||||||
else
|
else
|
||||||
SendNotify(src, 'You need a ' .. item.requiredLabel .. ' to use this!', 'error', 5000)
|
SendNotify(src, 'You need a ' .. item.requiredLabel .. ' to use this!', 'error', 5000)
|
||||||
|
@ -107,19 +136,27 @@ RegisterNetEvent('lusty94_smoking:server:UseVapeJuice', function(itemName, amoun
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--qb inventory shop
|
--qb inventory shop
|
||||||
RegisterNetEvent('lusty94_smoking:server:openShop', function()
|
RegisterNetEvent('lusty94_smoking:server:openShop', function()
|
||||||
local src = source
|
local src = source
|
||||||
local Player = QBCore.Functions.GetPlayer(src)
|
local Player = QBCore.Functions.GetPlayer(src)
|
||||||
|
|
||||||
|
if InvType == 'tgiann' then
|
||||||
|
-- For tgiann-inventory
|
||||||
|
local items = {
|
||||||
|
{ name = 'redwoodpack', price = 250, amount = 100, type = 'item' },
|
||||||
|
{ name = 'debonairepack', price = 250, amount = 100, type = 'item' },
|
||||||
|
{ name = 'sixtyninepack', price = 250, amount = 100, type = 'item' },
|
||||||
|
{ name = 'yukonpack', price = 250, amount = 100, type = 'item' },
|
||||||
|
{ name = 'vape', price = 100, amount = 100, type = 'item' },
|
||||||
|
{ name = 'vapejuice', price = 50, amount = 100, type = 'item' },
|
||||||
|
{ name = 'lighter', price = 5, amount = 100, type = 'item' },
|
||||||
|
}
|
||||||
|
exports["tgiann-inventory"]:RegisterShop("smokingShop", items)
|
||||||
|
exports["tgiann-inventory"]:OpenShop(src, "smokingShop")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local smokingShop = {
|
local smokingShop = {
|
||||||
{ name = "redwoodpack", price = 250, amount = 100, info = {}, type = "item", slot = 1,},
|
{ name = "redwoodpack", price = 250, amount = 100, info = {}, type = "item", slot = 1,},
|
||||||
{ name = "debonairepack", price = 250, amount = 100, info = {}, type = "item", slot = 2,},
|
{ name = "debonairepack", price = 250, amount = 100, info = {}, type = "item", slot = 2,},
|
||||||
|
@ -129,14 +166,17 @@ RegisterNetEvent('lusty94_smoking:server:openShop', function()
|
||||||
{ name = "vapejuice", price = 50, amount = 100, info = {}, type = "item", slot = 6,},
|
{ name = "vapejuice", price = 50, amount = 100, info = {}, type = "item", slot = 6,},
|
||||||
{ name = "lighter", price = 5, amount = 100, info = {}, type = "item", slot = 7,},
|
{ name = "lighter", price = 5, amount = 100, info = {}, type = "item", slot = 7,},
|
||||||
}
|
}
|
||||||
exports['qb-inventory']:CreateShop({
|
|
||||||
name = 'smokingShop',
|
if InvType == 'qb' then
|
||||||
label = 'Smoking Shop',
|
exports['qb-inventory']:CreateShop({
|
||||||
slots = 7,
|
name = 'smokingShop',
|
||||||
items = smokingShop
|
label = 'Smoking Shop',
|
||||||
})
|
slots = 7,
|
||||||
if Player then
|
items = smokingShop
|
||||||
exports['qb-inventory']:OpenShop(source, 'smokingShop')
|
})
|
||||||
|
if Player then
|
||||||
|
exports['qb-inventory']:OpenShop(source, 'smokingShop')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -156,6 +196,18 @@ AddEventHandler('onResourceStart', function(resourceName)
|
||||||
{ name = 'lighter', price = 5 },
|
{ name = 'lighter', price = 5 },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
elseif InvType == 'tgiann' then
|
||||||
|
-- Register shop for tgiann-inventory on resource start
|
||||||
|
local items = {
|
||||||
|
{ name = 'redwoodpack', price = 250, amount = 100, type = 'item' },
|
||||||
|
{ name = 'debonairepack', price = 250, amount = 100, type = 'item' },
|
||||||
|
{ name = 'sixtyninepack', price = 250, amount = 100, type = 'item' },
|
||||||
|
{ name = 'yukonpack', price = 250, amount = 100, type = 'item' },
|
||||||
|
{ name = 'vape', price = 100, amount = 100, type = 'item' },
|
||||||
|
{ name = 'vapejuice', price = 50, amount = 100, type = 'item' },
|
||||||
|
{ name = 'lighter', price = 5, amount = 100, type = 'item' },
|
||||||
|
}
|
||||||
|
exports["tgiann-inventory"]:RegisterShop("smokingShop", items)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -180,4 +232,4 @@ local function CheckVersion()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
CheckVersion()
|
CheckVersion()
|
||||||
|
|
|
@ -28,7 +28,7 @@ Config.CoreSettings = {
|
||||||
--use 'ox' for ox_target
|
--use 'ox' for ox_target
|
||||||
},
|
},
|
||||||
Inventory = { --support for qb-inventory and ox_inventory
|
Inventory = { --support for qb-inventory and ox_inventory
|
||||||
Type = 'qb',
|
Type = 'tgiann',
|
||||||
--use 'qb' for qb-inventory
|
--use 'qb' for qb-inventory
|
||||||
--use 'ox' for ox_inventory
|
--use 'ox' for ox_inventory
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue