This commit is contained in:
Nordi98 2025-08-12 13:34:26 +02:00
parent 6a6c44143c
commit e50a457657
31 changed files with 1135 additions and 764 deletions

View file

@ -0,0 +1,89 @@
if not config["codem-inventory"] then return end
local playerJob = ""
local lastItems = {}
RegisterNetEvent('tgiCore:Client:OnPlayerLogout', function()
self.Functions.RemoveAllWeapons()
end)
RegisterNetEvent('tgiCore:Client:OnPlayerLoaded')
AddEventHandler('tgiCore:Client:OnPlayerLoaded', function(PlayerData)
playerJob = PlayerData.job.name
SetTimeout(2000, function() -- some waiting time because the character's inventory data is loaded later
lastItems = exports['codem-inventory']:GetClientPlayerInventory()
weaponCheck()
end)
end)
RegisterNetEvent('tgiCore:Client:OnJobUpdate')
AddEventHandler('tgiCore:Client:OnJobUpdate', function(job)
self.Functions.RemoveAllWeapons()
playerJob = job.name
weaponCheck()
end)
RegisterNetEvent('codem-inventory:client:additem')
AddEventHandler('codem-inventory:client:additem', function(slot, data)
lastItems[tostring(slot)] = data
weaponCheck()
end)
RegisterNetEvent('codem-inventory:client:removeitemtoclientInventory')
AddEventHandler('codem-inventory:client:removeitemtoclientInventory', function(slot, amount)
slot = tostring(slot)
if lastItems[slot] then
local itemAmount = lastItems[slot].count or lastItems[slot].amount
if itemAmount == amount then
lastItems[slot] = nil
end
end
weaponCheck()
end)
RegisterNetEvent('codem-inventory:client:clearinventory')
AddEventHandler('codem-inventory:client:clearinventory', function()
lastItems = {}
weaponCheck()
end)
RegisterNetEvent('codem-inventory:client:setitembyslot')
AddEventHandler('codem-inventory:client:setitembyslot', function(slot, itemData)
lastItems[tostring(slot)] = itemData
weaponCheck()
end)
self.Functions.CheckWeaponIsRemoved = function()
if not next(self.weapons) then return end
for key, _ in pairs(self.weapons) do
local success = false
for _, item in pairs(lastItems) do
if key == item.info?.serie or item.name then
success = true
break
end
end
if not success then
self.Functions.RemoveWeapon(key)
end
end
end
function weaponCheck()
if not lastItems then return end
Wait(100)
self.Functions.CheckWeaponIsRemoved()
local isMale = GetEntityModel(PlayerPedId()) == `mp_m_freemode_01`
for _, item in pairs(lastItems) do
if item and item.type == "weapon" then
self.Functions.AddWeapon({
weapon = item.name,
key = item?.info?.serie or item.name,
attachments = config.tgiann_attachments and
getTgiannAttachments(item.info.tgiattachments, joaat(item.name)) or item.info.attachments,
playerJob = playerJob,
isMale = isMale
})
end
end
end

View file

@ -0,0 +1,116 @@
-- https://docs.c8re.store/core-inventory/api
if not config.core_inventory then return end
local function splitStr(str, delimiter)
local result = {}
local from = 1
local delim_from, delim_to = string.find(str, delimiter, from)
while delim_from do
result[#result + 1] = string.sub(str, from, delim_from - 1)
from = delim_to + 1
delim_from, delim_to = string.find(str, delimiter, from)
end
result[#result + 1] = string.sub(str, from)
return result
end
local playerJob = ""
local invItems = {}
local playerItems = {}
local function getInventoryItems()
tgiCore.cbFunction('tgiann-weapons-on-back:core_inventory:server:getInventory', function(newPlayerItems)
playerItems = newPlayerItems
weaponCheck(true)
end)
end
RegisterNetEvent('core_inventory:client:sync', function(inventory, data)
local split = splitStr(inventory, '-')[1]
if config.enableInv[split] then
playerItems[split] = data.content
end
end)
RegisterNetEvent('tgiCore:Client:OnPlayerLoaded')
AddEventHandler('tgiCore:Client:OnPlayerLoaded', function(PlayerData)
if not PlayerData then return end
playerJob = PlayerData.job.name
getInventoryItems(PlayerData.identifier)
end)
RegisterNetEvent('tgiCore:Client:OnPlayerLogout', function()
self.Functions.RemoveAllWeapons()
end)
RegisterNetEvent('tgiCore:Client:OnJobUpdate')
AddEventHandler('tgiCore:Client:OnJobUpdate', function(job)
self.Functions.RemoveAllWeapons()
playerJob = job.name
weaponCheck(false)
end)
if config.framework == "qb" then
RegisterNetEvent('QBCore:Player:SetPlayerData', function(PlayerData)
playerJob = PlayerData.job.name
if not config.enableInv["content"] then return end
playerItems["content"] = PlayerData?.items
weaponCheck(true)
end)
else
RegisterNetEvent('esx:addInventoryItem')
AddEventHandler('esx:addInventoryItem', function(job)
local PlayerData = exports["tgiann-core"]:getPlayerData()
if not PlayerData then return end
getInventoryItems(PlayerData.identifier)
end)
RegisterNetEvent('esx:removeInventoryItem')
AddEventHandler('esx:removeInventoryItem', function(job)
local PlayerData = exports["tgiann-core"]:getPlayerData()
if not PlayerData then return end
getInventoryItems(PlayerData.identifier)
end)
end
self.Functions.CheckWeaponIsRemoved = function()
if not next(self.weapons) then return end
for key, _ in pairs(self.weapons) do
local success = false
for _, item in pairs(invItems) do
if item and key == (item.metadata?.serial or item.name) then
success = true
break
end
end
if not success then
self.Functions.RemoveWeapon(key)
end
end
end
function weaponCheck(updateData)
if updateData then
invItems = {}
for _, inv in pairs(playerItems) do
for _, item in pairs(inv) do
invItems[#invItems + 1] = item
end
end
end
Wait(100)
self.Functions.CheckWeaponIsRemoved()
local isMale = GetEntityModel(PlayerPedId()) == `mp_m_freemode_01`
for _, item in pairs(invItems) do
if item and string.find(string.lower(item.name), "weapon") then
self.Functions.AddWeapon({
weapon = item.name,
key = item.metadata?.serial or item.name,
attachments = config.tgiann_attachments and
getTgiannAttachments(item.metadata.tgiattachments, joaat(item.name)) or item.metadata.attachments,
playerJob = playerJob,
isMale = isMale
})
end
end
end

View file

@ -0,0 +1,88 @@
if config.framework ~= "esx" then return end
if not config.useDefaultInventory then return end
local playerJob = ""
local lastItems = {}
local function getInventoryItems()
tgiCore.cbFunction('tgiann-weapons-on-back:esx_inv:server:getInventory', function(playerItems, loadout)
local itemList = {}
-- ESX is suck
if loadout and #loadout > 0 then
for i = 1, #loadout do
itemList[#itemList + 1] = loadout[i]
end
end
if playerItems and #playerItems > 0 then
for i = 1, #playerItems do
if playerItems[i].count > 0 then
itemList[#itemList + 1] = playerItems[i]
end
end
end
lastItems = itemList
weaponCheck()
end)
end
RegisterNetEvent('tgiCore:Client:OnPlayerLoaded')
AddEventHandler('tgiCore:Client:OnPlayerLoaded', function(PlayerData)
playerJob = PlayerData.job.name
getInventoryItems()
end)
RegisterNetEvent('tgiCore:Client:OnPlayerLogout', function()
self.Functions.RemoveAllWeapons()
end)
RegisterNetEvent('esx:addInventoryItem')
AddEventHandler('esx:addInventoryItem', function(job)
getInventoryItems()
end)
RegisterNetEvent('esx:removeInventoryItem')
AddEventHandler('esx:removeInventoryItem', function(job)
getInventoryItems()
end)
RegisterNetEvent('tgiCore:Client:OnJobUpdate')
AddEventHandler('tgiCore:Client:OnJobUpdate', function(job)
self.Functions.RemoveAllWeapons()
playerJob = job.name
weaponCheck()
end)
self.Functions.CheckWeaponIsRemoved = function()
if not next(self.weapons) then return end
for key, _ in pairs(self.weapons) do
local success = false
for _, item in pairs(lastItems) do
if item and key == item.name then
success = true
break
end
end
if not success then
self.Functions.RemoveWeapon(key)
end
end
end
function weaponCheck()
self.Functions.CheckWeaponIsRemoved()
Wait(100)
local isMale = GetEntityModel(PlayerPedId()) == `mp_m_freemode_01`
for _, item in pairs(lastItems) do
if item and string.find(string.lower(item.name), "weapon") then
self.Functions.AddWeapon({
weapon = item.name,
key = item.name,
attachments = config.tgiann_attachments and
getTgiannAttachments(item?.info?.tgiattachments, joaat(item.name)) or item.components,
playerJob = playerJob,
isMale = isMale
})
end
end
end

View file

@ -0,0 +1,99 @@
tgiCore = nil
CreateThread(function()
while not tgiCore do
tgiCore = tgiCoreExports:getCore()
Wait(200)
end
end)
local function LoadModel(model)
if HasModelLoaded(model) then return end
RequestModel(model)
while not HasModelLoaded(model) do Wait(0) end
end
self.Functions.AddAttachments = function(entity, weaponName, weaponHash, attachments)
if not attachments then return end
if config.tgiann_attachments then
for _, data in pairs(attachments) do
local model = GetWeaponComponentTypeModel(data.component)
if model ~= 0 then
LoadModel(model)
GiveWeaponComponentToWeaponObject(entity, data.component)
SetModelAsNoLongerNeeded(data.component)
else
SetWeaponObjectTintIndex(entity, data.component)
end
end
elseif config.core_inventory then
for _, data in pairs(attachments) do
local model = GetWeaponComponentTypeModel(data.componentHash)
if model ~= 0 then
LoadModel(model)
GiveWeaponComponentToWeaponObject(entity, data.componentHash)
SetModelAsNoLongerNeeded(data.componentHash)
else
SetWeaponObjectTintIndex(entity, data.componentHash)
end
end
elseif config.ox_inventory then
if not oxItems then oxItems = exports.ox_inventory:Items() end
for i = 1, #attachments do
local components = oxItems[attachments[i]].client.component
for v = 1, #components do
local component = components[v]
if DoesWeaponTakeWeaponComponent(weaponHash, component) then
local model = GetWeaponComponentTypeModel(component)
if model ~= 0 then
LoadModel(model)
GiveWeaponComponentToWeaponObject(entity, component)
SetModelAsNoLongerNeeded(component)
end
end
end
end
elseif config.framework == "qb" then
for _, data in pairs(attachments) do
local model = GetWeaponComponentTypeModel(data.component)
if model ~= 0 then
LoadModel(model)
GiveWeaponComponentToWeaponObject(entity, data.component)
SetModelAsNoLongerNeeded(data.component)
else
SetWeaponObjectTintIndex(entity, data.component)
end
end
else
--ESX is suck
for i = 1, #attachments do
local componentData = tgiCore.core.GetWeaponComponent(weaponName, attachments[i])
if componentData then
local hash = componentData.hash
local model = GetWeaponComponentTypeModel(hash)
if model ~= 0 then
LoadModel(model)
GiveWeaponComponentToWeaponObject(entity, hash)
SetModelAsNoLongerNeeded(hash)
else
SetWeaponObjectTintIndex(entity, hash)
end
end
end
end
end
function getTgiannAttachments(tgiattachments, weapon)
local invSettings = exports["tgiann-attachment"]:inventoryConfig()
if invSettings then
return tgiattachments
else
local returnVal = nil
local waitCb = true
tgiCore.cbFunction("tgiann-attachment:getAttachment", function(data)
returnVal = data
waitCb = false
end, weapon)
while waitCb do Wait(10) end
return returnVal
end
end

View file

@ -0,0 +1,77 @@
if not config["mf-inventory"] then return end
local playerJob = ""
local lastItems = {}
local function getInventoryItems(identifier)
exports["mf-inventory"]:getInventoryItems(identifier, function(items)
lastItems = items
weaponCheck()
end)
end
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(PlayerData)
playerJob = PlayerData.job.name
getInventoryItems(PlayerData.identifier)
end)
RegisterNetEvent('tgiCore:Client:OnPlayerLogout', function()
self.Functions.RemoveAllWeapons()
end)
RegisterNetEvent('esx:addInventoryItem')
AddEventHandler('esx:addInventoryItem', function(job)
local PlayerData = exports["tgiann-core"]:getPlayerData()
if not PlayerData then return end
getInventoryItems(PlayerData.identifier)
end)
RegisterNetEvent('esx:removeInventoryItem')
AddEventHandler('esx:removeInventoryItem', function(job)
local PlayerData = exports["tgiann-core"]:getPlayerData()
if not PlayerData then return end
getInventoryItems(PlayerData.identifier)
end)
RegisterNetEvent('tgiCore:Client:OnJobUpdate')
AddEventHandler('tgiCore:Client:OnJobUpdate', function(job)
self.Functions.RemoveAllWeapons()
playerJob = job.name
weaponCheck()
end)
self.Functions.CheckWeaponIsRemoved = function()
if not next(self.weapons) then return end
for key, _ in pairs(self.weapons) do
local success = false
for _, item in pairs(lastItems) do
if item and key == item.name then
success = true
break
end
end
if not success then
self.Functions.RemoveWeapon(key)
end
end
end
function weaponCheck()
if not lastItems then return end
Wait(100)
self.Functions.CheckWeaponIsRemoved(lastItems)
local isMale = GetEntityModel(PlayerPedId()) == `mp_m_freemode_01`
for _, item in pairs(lastItems) do
if item and string.find(string.lower(item.name), "weapon") then
self.Functions.AddWeapon({
weapon = item.name,
key = item.name,
attachments = config.tgiann_attachments and
getTgiannAttachments(item.metadata.tgiattachments, joaat(item.name)),
playerJob = playerJob,
isMale = isMale
})
end
end
end

View file

@ -0,0 +1,79 @@
if not config.origen_inventory then return end
local origen_inventory = exports.origen_inventory
local playerJob = ""
local lastItems = {}
local function getInventoryItems()
lastItems = origen_inventory:GetInventory()
weaponCheck()
end
RegisterNetEvent('tgiCore:Client:OnPlayerLogout', function()
self.Functions.RemoveAllWeapons()
end)
RegisterNetEvent('tgiCore:Client:OnPlayerLoaded')
AddEventHandler('tgiCore:Client:OnPlayerLoaded', function(PlayerData)
playerJob = PlayerData.job.name
getInventoryItems()
end)
RegisterNetEvent('tgiCore:Client:OnJobUpdate')
AddEventHandler('tgiCore:Client:OnJobUpdate', function(job)
self.Functions.RemoveAllWeapons()
playerJob = job.name
weaponCheck()
end)
--QB
RegisterNetEvent('QBCore:Player:SetPlayerData', function(PlayerData)
playerJob = PlayerData.job.name
getInventoryItems()
end)
--ESX
RegisterNetEvent('esx:addInventoryItem')
AddEventHandler('esx:addInventoryItem', function()
getInventoryItems()
end)
RegisterNetEvent('esx:removeInventoryItem')
AddEventHandler('esx:removeInventoryItem', function()
getInventoryItems()
end)
self.Functions.CheckWeaponIsRemoved = function()
if not next(self.weapons) then return end
for key, _ in pairs(self.weapons) do
local success = false
for _, item in pairs(lastItems) do
if key == item.info.serie then
success = true
break
end
end
if not success then
self.Functions.RemoveWeapon(key)
end
end
end
function weaponCheck()
if not lastItems then return end
Wait(100)
self.Functions.CheckWeaponIsRemoved()
local isMale = GetEntityModel(PlayerPedId()) == `mp_m_freemode_01`
for _, item in pairs(lastItems) do
if item and item.type == "weapon" then
self.Functions.AddWeapon({
weapon = item.name,
key = item.info.serie,
attachments = config.tgiann_attachments and
getTgiannAttachments(item.info.tgiattachments, joaat(item.name)) or item.info.attachments,
playerJob = playerJob,
isMale = isMale
})
end
end
end

View file

@ -0,0 +1,64 @@
if not config.ox_inventory then return end
local playerJob = ""
local lastItems = {}
RegisterNetEvent('tgiCore:Client:OnPlayerLoaded')
AddEventHandler('tgiCore:Client:OnPlayerLoaded', function(PlayerData)
playerJob = PlayerData.job.name
lastItems = exports.ox_inventory:GetPlayerItems() or {}
weaponCheck()
end)
RegisterNetEvent('tgiCore:Client:OnPlayerLogout', function()
self.Functions.RemoveAllWeapons()
end)
AddEventHandler('ox_inventory:updateInventory', function(changes)
for i, value in pairs(changes) do
lastItems[i] = value or nil
end
weaponCheck()
end)
RegisterNetEvent('tgiCore:Client:OnJobUpdate')
AddEventHandler('tgiCore:Client:OnJobUpdate', function(job)
self.Functions.RemoveAllWeapons()
playerJob = job.name
weaponCheck()
end)
self.Functions.CheckWeaponIsRemoved = function()
if not next(self.weapons) then return end
for key, _ in pairs(self.weapons) do
local success = false
for _, item in pairs(lastItems) do
if item and key == (item.metadata.serial or item.name) then
success = true
break
end
end
if not success then
self.Functions.RemoveWeapon(key)
end
end
end
function weaponCheck()
if not lastItems then return end
Wait(100)
self.Functions.CheckWeaponIsRemoved()
local isMale = GetEntityModel(PlayerPedId()) == `mp_m_freemode_01`
for _, item in pairs(lastItems) do
if item and string.find(string.lower(item.name), "weapon") then
self.Functions.AddWeapon({
weapon = item.name,
key = item.metadata.serial or item.name,
attachments = config.tgiann_attachments and
getTgiannAttachments(item.metadata.tgiattachments, joaat(item.name)) or item.metadata.components,
playerJob = playerJob,
isMale = isMale
})
end
end
end

View file

@ -0,0 +1,64 @@
if config.framework ~= "qb" then return end
if not config.useDefaultInventory then return end
local playerJob = ""
local lastItems = {}
RegisterNetEvent('tgiCore:Client:OnPlayerLogout', function()
self.Functions.RemoveAllWeapons()
end)
RegisterNetEvent('tgiCore:Client:OnPlayerLoaded')
AddEventHandler('tgiCore:Client:OnPlayerLoaded', function(PlayerData)
playerJob = PlayerData.job.name
lastItems = PlayerData?.items
weaponCheck()
end)
RegisterNetEvent('QBCore:Player:SetPlayerData', function(PlayerData)
playerJob = PlayerData.job.name
lastItems = PlayerData?.items
weaponCheck()
end)
RegisterNetEvent('tgiCore:Client:OnJobUpdate')
AddEventHandler('tgiCore:Client:OnJobUpdate', function(job)
self.Functions.RemoveAllWeapons()
playerJob = job.name
weaponCheck()
end)
self.Functions.CheckWeaponIsRemoved = function()
if not next(self.weapons) then return end
for key, _ in pairs(self.weapons) do
local success = false
for _, item in pairs(lastItems) do
if key == item.info.serie then
success = true
break
end
end
if not success then
self.Functions.RemoveWeapon(key)
end
end
end
function weaponCheck()
if not lastItems then return end
Wait(100)
self.Functions.CheckWeaponIsRemoved()
local isMale = GetEntityModel(PlayerPedId()) == `mp_m_freemode_01`
for _, item in pairs(lastItems) do
if item and item.type == "weapon" then
self.Functions.AddWeapon({
weapon = item.name,
key = item.info.serie,
attachments = config.tgiann_attachments and
getTgiannAttachments(item.info.tgiattachments, joaat(item.name)) or item.info.attachments,
playerJob = playerJob,
isMale = isMale
})
end
end
end

View file

@ -0,0 +1,89 @@
if not config["qs-inventory"] then return end
local playerJob = ""
local lastItems = {}
local isBussy = false
local function getInventoryItems()
if isBussy then return end
isBussy = true
while exports['qs-inventory']:inInventory() do Wait(10) end -- getUserInventory not updating when inventory is open
Wait(1000) -- getUserInventory is updating late
lastItems = exports['qs-inventory']:getUserInventory()
weaponCheck(playerJob, true)
isBussy = false
end
RegisterNetEvent('tgiCore:Client:OnPlayerLoaded')
AddEventHandler('tgiCore:Client:OnPlayerLoaded', function(PlayerData)
playerJob = PlayerData.job.name
getInventoryItems()
end)
RegisterNetEvent('tgiCore:Client:OnPlayerLogout', function()
self.Functions.RemoveAllWeapons()
end)
--ESX
RegisterNetEvent('esx:addInventoryItem')
AddEventHandler('esx:addInventoryItem', function()
getInventoryItems()
end)
RegisterNetEvent('esx:removeInventoryItem')
AddEventHandler('esx:removeInventoryItem', function()
getInventoryItems()
end)
--QB
RegisterNetEvent('QBCore:Player:SetPlayerData', function(PlayerData)
playerJob = PlayerData.job.name
lastItems = PlayerData?.items
weaponCheck()
end)
RegisterNetEvent('tgiCore:Client:OnJobUpdate')
AddEventHandler('tgiCore:Client:OnJobUpdate', function(job)
self.Functions.RemoveAllWeapons()
playerJob = job.name
weaponCheck(playerJob)
end)
self.Functions.CheckWeaponIsRemoved = function()
if not next(self.weapons) then return end
for key, _ in pairs(self.weapons) do
local success = false
for _, item in pairs(lastItems) do
if item and key == (item.info?.serie or item.name) then
success = true
break
end
end
if not success then
self.Functions.RemoveWeapon(key)
end
end
end
function weaponCheck()
Wait(100)
self.Functions.CheckWeaponIsRemoved()
local isMale = GetEntityModel(PlayerPedId()) == `mp_m_freemode_01`
for _, item in pairs(lastItems) do
if item then
local isWeapon = string.find(string.lower(item.name), "weapon")
debug(item.name .. " Check For Add Weapon", "isWeapon: " .. tostring(isWeapon))
if isWeapon then
debug(item.name .. " Added")
self.Functions.AddWeapon({
weapon = item.name,
key = item.info?.serie or item.name,
attachments = config.tgiann_attachments and
getTgiannAttachments(item.info.tgiattachments, joaat(item.name)) or item.info?.attachments,
playerJob = playerJob,
isMale = isMale
})
end
end
end
end

View file

@ -0,0 +1,62 @@
if not config["tgiann-inventory"] then return end
local playerJob = ""
local lastItems = {}
RegisterNetEvent('tgiCore:Client:OnPlayerLogout', function()
self.Functions.RemoveAllWeapons()
end)
RegisterNetEvent('tgiCore:Client:OnPlayerLoaded')
AddEventHandler('tgiCore:Client:OnPlayerLoaded', function(PlayerData)
playerJob = PlayerData.job.name
lastItems = exports["tgiann-inventory"]:GetPlayerItems()
weaponCheck()
end)
RegisterNetEvent('tgiann-inventory:inventoryUpdated')
AddEventHandler('tgiann-inventory:inventoryUpdated', function(items)
lastItems = items
weaponCheck()
end)
RegisterNetEvent('tgiCore:Client:OnJobUpdate')
AddEventHandler('tgiCore:Client:OnJobUpdate', function(job)
self.Functions.RemoveAllWeapons()
playerJob = job.name
weaponCheck()
end)
self.Functions.CheckWeaponIsRemoved = function()
if not next(self.weapons) then return end
for key, _ in pairs(self.weapons) do
local success = false
for _, item in pairs(lastItems) do
if key == item?.info?.serie then
success = true
break
end
end
if not success then
self.Functions.RemoveWeapon(key)
end
end
end
function weaponCheck()
if not lastItems then return end
Wait(100)
self.Functions.CheckWeaponIsRemoved()
local isMale = GetEntityModel(PlayerPedId()) == `mp_m_freemode_01`
for _, item in pairs(lastItems) do
if item and item.type == "weapon" then
self.Functions.AddWeapon({
weapon = string.gsub(item.name, "_police", ""),
key = item?.info?.serie or item.name,
attachments = item?.info?.tgiattachments or {},
playerJob = playerJob,
isMale = isMale
})
end
end
end