Please follow each step carefully to avoid any problems during installation.
BASICS
Put core_gangs in your resources folder
Upload the sql file on your database to create the required table / column on your database
Check that all the item set in the config file (GenerationItem / ProcessingFrom / ProcessingTo / SaleItem) exist change it. Add the items in your items.lua (QBCore / ox_inventory / qs-inventory) OR in your item database (ESX).
Read the config file to parameter your framework / inventory script / zone etc.
Make sure you have qb-target or ox_target script
Ensure the resource in your server.cfg
INVENTORY COMPATABILITY
This script uses stashes for Value Zones for that funcionality to work you need to check inventory compatability
IF YOU USE QB-INVENTORY / LJ-INVENTORY / PS-INVENTORY OR any fork of QB-INVENTORY, PLEASE ADD ALL THE CODE BEHIND IN qb-inventory(lj-inventory / ps-inventory etc.) / server / main.luaat the total end of the file:
Old version of qb-inventory / ps-inventory / lj-inventory (Version older or equal to Apr 29, 2024 (version less than 2.0.0)) :
New version of qb-inventory (Version newer then Apr 29, 2024 (version greater or equal to 2.0.0))
C8RE TOOLS
This script will soon feature C8RE TOOLS an in-game config for easier configuration. Stay tuned!
-------------------------------------------------------
--------------- ADDON FOR C8RE GANGS ------------------
-------------------------------------------------------
---Check If item can be added to the stash
---@param stashid number stash id / stash name
---@param item string The item to add to the inventory
---@param amount? number The amount of the item to add
---@param slots? number of slot of the stash if it s not exist
---@param maxWeight? number of slot of the stash if it s not existmax height of the stash
---@return boolean success Returns true if the item can be added, false it the item cannot be added
local function StashCanCarryItem(stashid, item, amount, slots, maxWeight)
local Stash = Stashes[stashid];
if not Stash then
Stashes[stashid] = {}
local items = GetStashItems(stashid)
if next(items) then
Stashes[stashid].items = items
else
Stashes[stashid].items = {}
end
Stashes[stashid].isOpen = false
Stashes[stashid].label = "Stash-"..stashid
Stashes[stashid].slot = tonumber(slots) or tonumber(10)
Stashes[stashid].maxWeight = tonumber(maxWeight) or tonumber(1000000)
end
local totalWeight = GetTotalWeight(Stashes[stashid].items)
local itemInfo = QBCore.Shared.Items[item:lower()]
if not itemInfo then
print("^1[ERROR] Item does not exist^7", item:lower())
return false
end
amount = tonumber(amount) or 1
if (totalWeight + ((itemInfo['weight'] or 100) * amount)) > (Stashes[stashid].maxWeight or tonumber(maxWeight) or tonumber(1000000)) then
return false
end
return true
end
exports("StashCanCarryItem", StashCanCarryItem)
---Add an item to the inventory of the player
---@param source number The source of the player
---@param item string The item to add to the inventory
---@param amount? number The amount of the item to add
---@param slot? number The slot to add the item to
---@param info? table Extra info to add onto the item to use whenever you get the item
---@param slots? number of slot of the stash if it s not exist
---@param maxWeight? number of slot of the stash if it s not existmax height of the stash
---@return boolean success Returns true if the item was added, false it the item couldn't be added
local function AddItemIntoStash(stashid, item, amount, slot, info, slots, maxWeight)
local Stash = Stashes[stashid];
if not Stash then
Stashes[stashid] = {}
local items = GetStashItems(stashid)
if next(items) then
Stashes[stashid].items = items
else
Stashes[stashid].items = {}
end
Stashes[stashid].isOpen = false
Stashes[stashid].label = "Stash-"..stashid
Stashes[stashid].slot = tonumber(slots) or tonumber(10)
Stashes[stashid].maxWeight = tonumber(maxWeight) or tonumber(1000000)
end
local totalWeight = GetTotalWeight(Stashes[stashid].items)
local itemInfo = QBCore.Shared.Items[item:lower()]
if not itemInfo then
print("^1[ERROR] Item does not exist^7", item:lower())
return false
end
amount = tonumber(amount) or 1
slot = tonumber(slot) or GetFirstSlotByItem(Stashes[stashid].items, item)
info = info or {}
if itemInfo['type'] == 'weapon' then
info.serie = info.serie or tostring(QBCore.Shared.RandomInt(2) .. QBCore.Shared.RandomStr(3) .. QBCore.Shared.RandomInt(1) .. QBCore.Shared.RandomStr(2) .. QBCore.Shared.RandomInt(3) .. QBCore.Shared.RandomStr(4))
info.quality = info.quality or 100
end
if (slot and Stashes[stashid].items[slot]) and (Stashes[stashid].items[slot].name:lower() == item:lower()) and (itemInfo['type'] == 'item' and not itemInfo['unique']) then
Stashes[stashid].items[slot].amount = Stashes[stashid].items[slot].amount + amount
SaveStashItems(stashid, Stashes[stashid].items);
return true
elseif not itemInfo['unique'] and slot or slot and Stashes[stashid].items[slot] == nil then
Stashes[stashid].items[slot] = { name = itemInfo['name'], amount = amount, info = info or '', label = itemInfo['label'], description = itemInfo['description'] or '', weight = itemInfo['weight'], type = itemInfo['type'], unique = itemInfo['unique'], useable = itemInfo['useable'], image = itemInfo['image'], shouldClose = itemInfo['shouldClose'], slot = slot, combinable = itemInfo['combinable'] }
SaveStashItems(stashid, Stashes[stashid].items);
return true
elseif itemInfo['unique'] or (not slot or slot == nil) or itemInfo['type'] == 'weapon' then
for i = 1, Config.MaxInventorySlots, 1 do -- TO REVIEW
if Stashes[stashid].items[i] == nil then
Stashes[stashid].items[i] = { name = itemInfo['name'], amount = amount, info = info or '', label = itemInfo['label'], description = itemInfo['description'] or '', weight = itemInfo['weight'], type = itemInfo['type'], unique = itemInfo['unique'], useable = itemInfo['useable'], image = itemInfo['image'], shouldClose = itemInfo['shouldClose'], slot = i, combinable = itemInfo['combinable'] }
SaveStashItems(stashid, Stashes[stashid].items);
return true
end
end
end
return false
end
exports("AddItemIntoStash", AddItemIntoStash)
---Remove an item from the inventory of the player
---@param source number The source of the player
---@param item string The item to remove from the inventory
---@param amount? number The amount of the item to remove
---@param slot? number The slot to remove the item from
---@return boolean success Returns true if the item was remove, false it the item couldn't be removed
local function RemoveItemIntoStash(stashid, item, amount, slot, slots, maxWeight)
local Stash = Stashes[stashid];
if not Stash then
Stashes[stashid] = {}
local items = GetStashItems(stashid)
if next(items) then
Stashes[stashid].items = items
else
Stashes[stashid].items = {}
end
Stashes[stashid].isOpen = false
Stashes[stashid].label = "Stash-"..stashid
Stashes[stashid].slot = tonumber(slots) or tonumber(10)
Stashes[stashid].maxWeight = tonumber(maxWeight) or tonumber(1000000)
end
amount = tonumber(amount) or 1
slot = tonumber(slot)
if slot then
if Stashes[stashid].items[slot].amount > amount then
Stashes[stashid].items[slot].amount = Stashes[stashid].items[slot].amount - amount
SaveStashItems(stashid, Stashes[stashid].items);
return true
elseif Stashes[stashid].items[slot].amount == amount then
Stashes[stashid].items[slot] = nil
SaveStashItems(stashid, Stashes[stashid].items);
return true
end
else
local slots = GetSlotsByItem(Stashes[stashid].items, item)
local amountToRemove = amount
if not slots then return false end
for _, _slot in pairs(slots) do
if Stashes[stashid].items[_slot].amount > amountToRemove then
Stashes[stashid].items[_slot].amount = Stashes[stashid].items[_slot].amount - amountToRemove
return true
elseif Stashes[stashid].items[_slot].amount == amountToRemove then
Stashes[stashid].items[_slot] = nil
SaveStashItems(stashid, Stashes[stashid].items);
return true
end
end
end
return false
end
exports("RemoveItemIntoStash", RemoveItemIntoStash)
---------------------------------------------------
---------------------------------------------------
---------------------------------------------------
-------------------------------------------------------
--------------- ADDON FOR C8RE GANGS ------------------
-------------------------------------------------------
RegisterNetEvent('inventory:server:OpenInventory', function(name, id, other)
local src = source
exports['qb-inventory']:OpenInventory(source, id, other)
end)
local function GetStashItems(inventory)
return Inventories[inventory] and Inventories[inventory].items or {}
end
local function SaveStashItems(inventory, items)
Inventories[inventory].items = items
return Inventories[inventory].items
end
---Check If item can be added to the stash
---@param stashid number stash id / stash name
---@param item string The item to add to the inventory
---@param amount? number The amount of the item to add
---@param slots? number of slot of the stash if it s not exist
---@param maxWeight? number of slot of the stash if it s not existmax height of the stash
---@return boolean success Returns true if the item can be added, false it the item cannot be added
local function StashCanCarryItem(stashid, item, amount, slots, maxWeight)
local Stash = Inventories[stashid];
if not Stash then
Inventories[stashid] = {}
local items = GetStashItems(stashid)
if next(items) then
Inventories[stashid].items = items
else
Inventories[stashid].items = {}
end
Inventories[stashid].isOpen = false
Inventories[stashid].label = "Stash-"..stashid
Inventories[stashid].slot = tonumber(slots) or tonumber(10)
Inventories[stashid].maxWeight = tonumber(maxWeight) or tonumber(1000000)
end
local totalWeight = GetTotalWeight(Inventories[stashid].items)
local itemInfo = QBCore.Shared.Items[item:lower()]
if not itemInfo then
print("^1[ERROR] Item does not exist^7", item:lower())
return false
end
amount = tonumber(amount) or 1
if (totalWeight + ((itemInfo['weight'] or 100) * amount)) > (Inventories[stashid].maxWeight or tonumber(maxWeight) or tonumber(1000000)) then
return false
end
return true
end
exports("StashCanCarryItem", StashCanCarryItem)
---Add an item to the inventory of the player
---@param source number The source of the player
---@param item string The item to add to the inventory
---@param amount? number The amount of the item to add
---@param slot? number The slot to add the item to
---@param info? table Extra info to add onto the item to use whenever you get the item
---@param slots? number of slot of the stash if it s not exist
---@param maxWeight? number of slot of the stash if it s not existmax height of the stash
---@return boolean success Returns true if the item was added, false it the item couldn't be added
local function AddItemIntoStash(stashid, item, amount, slot, info, slots, maxWeight)
local Stash = Inventories[stashid];
if not Stash then
Inventories[stashid] = {}
local items = GetStashItems(stashid)
if next(items) then
Inventories[stashid].items = items
else
Inventories[stashid].items = {}
end
Inventories[stashid].isOpen = false
Inventories[stashid].label = "Stash-"..stashid
Inventories[stashid].slot = tonumber(slots) or tonumber(10)
Inventories[stashid].maxWeight = tonumber(maxWeight) or tonumber(1000000)
end
local totalWeight = GetTotalWeight(Inventories[stashid].items)
local itemInfo = QBCore.Shared.Items[item:lower()]
if not itemInfo then
print("^1[ERROR] Item does not exist^7", item:lower())
return false
end
amount = tonumber(amount) or 1
slot = tonumber(slot) or GetFirstSlotByItem(Inventories[stashid].items, item)
info = info or {}
if itemInfo['type'] == 'weapon' then
info.serie = info.serie or tostring(QBCore.Shared.RandomInt(2) .. QBCore.Shared.RandomStr(3) .. QBCore.Shared.RandomInt(1) .. QBCore.Shared.RandomStr(2) .. QBCore.Shared.RandomInt(3) .. QBCore.Shared.RandomStr(4))
info.quality = info.quality or 100
end
if (slot and Inventories[stashid].items[slot]) and (Inventories[stashid].items[slot].name:lower() == item:lower()) and (itemInfo['type'] == 'item' and not itemInfo['unique']) then
Inventories[stashid].items[slot].amount = Inventories[stashid].items[slot].amount + amount
SaveStashItems(stashid, Inventories[stashid].items);
return true
elseif not itemInfo['unique'] and slot or slot and Inventories[stashid].items[slot] == nil then
Inventories[stashid].items[slot] = { name = itemInfo['name'], amount = amount, info = info or '', label = itemInfo['label'], description = itemInfo['description'] or '', weight = itemInfo['weight'], type = itemInfo['type'], unique = itemInfo['unique'], useable = itemInfo['useable'], image = itemInfo['image'], shouldClose = itemInfo['shouldClose'], slot = slot, combinable = itemInfo['combinable'] }
SaveStashItems(stashid, Inventories[stashid].items);
return true
elseif itemInfo['unique'] or (not slot or slot == nil) or itemInfo['type'] == 'weapon' then
for i = 1, Config.MaxSlots, 1 do
if Inventories[stashid].items[i] == nil then
Inventories[stashid].items[i] = { name = itemInfo['name'], amount = amount, info = info or '', label = itemInfo['label'], description = itemInfo['description'] or '', weight = itemInfo['weight'], type = itemInfo['type'], unique = itemInfo['unique'], useable = itemInfo['useable'], image = itemInfo['image'], shouldClose = itemInfo['shouldClose'], slot = i, combinable = itemInfo['combinable'] }
SaveStashItems(stashid, Inventories[stashid].items);
return true
end
end
end
return false
end
exports("AddItemIntoStash", AddItemIntoStash)
---Remove an item from the inventory of the player
---@param source number The source of the player
---@param item string The item to remove from the inventory
---@param amount? number The amount of the item to remove
---@param slot? number The slot to remove the item from
---@return boolean success Returns true if the item was remove, false it the item couldn't be removed
local function RemoveItemIntoStash(stashid, item, amount, slot, slots, maxWeight)
local Stash = Inventories[stashid];
if not Stash then
Inventories[stashid] = {}
local items = GetStashItems(stashid)
if next(items) then
Inventories[stashid].items = items
else
Inventories[stashid].items = {}
end
Inventories[stashid].isOpen = false
Inventories[stashid].label = "Stash-"..stashid
Inventories[stashid].slot = tonumber(slots) or tonumber(10)
Inventories[stashid].maxWeight = tonumber(maxWeight) or tonumber(1000000)
end
amount = tonumber(amount) or 1
slot = tonumber(slot)
if slot then
if Inventories[stashid].items[slot].amount > amount then
Inventories[stashid].items[slot].amount = Inventories[stashid].items[slot].amount - amount
SaveStashItems(stashid, Inventories[stashid].items);
return true
elseif Inventories[stashid].items[slot].amount == amount then
Inventories[stashid].items[slot] = nil
SaveStashItems(stashid, Inventories[stashid].items);
return true
end
else
local slots = GetSlotsByItem(Inventories[stashid].items, item)
local amountToRemove = amount
if not slots then return false end
for _, _slot in pairs(slots) do
if Inventories[stashid].items[_slot].amount > amountToRemove then
Inventories[stashid].items[_slot].amount = Inventories[stashid].items[_slot].amount - amountToRemove
return true
elseif Inventories[stashid].items[_slot].amount == amountToRemove then
Inventories[stashid].items[_slot] = nil
SaveStashItems(stashid, Inventories[stashid].items);
return true
end
end
end
return false
end
exports("RemoveItemIntoStash", RemoveItemIntoStash)
---------------------------------------------------
---------------------------------------------------
---------------------------------------------------