ed
This commit is contained in:
		
							parent
							
								
									45e1a2659f
								
							
						
					
					
						commit
						9dc050cb24
					
				
					 20 changed files with 1135 additions and 0 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								resources/[inventory]/tgiann-weapons-on-back/.fxap
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/[inventory]/tgiann-weapons-on-back/.fxap
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										28
									
								
								resources/[inventory]/tgiann-weapons-on-back/checkInv.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								resources/[inventory]/tgiann-weapons-on-back/checkInv.lua
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,28 @@
 | 
			
		|||
config.useDefaultInventory = true
 | 
			
		||||
 | 
			
		||||
local function log(msg)
 | 
			
		||||
    print(string.format('\x1b[32m[tgiann-weapons-on-back]\x1b[0m %s', msg))
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Chezza Studios inventory works fine with normal esx(don't add to the list)
 | 
			
		||||
local inventorys = {
 | 
			
		||||
    "tgiann-inventory",
 | 
			
		||||
    "mf-inventory",
 | 
			
		||||
    "ox_inventory",
 | 
			
		||||
    "core_inventory",
 | 
			
		||||
    "qs-inventory",
 | 
			
		||||
    "codem-inventory",
 | 
			
		||||
    "origen_inventory"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
for i = 1, #inventorys do
 | 
			
		||||
    local inventory = inventorys[i]
 | 
			
		||||
    local isStarted = GetResourceState(inventory) == "started"
 | 
			
		||||
    if isStarted then
 | 
			
		||||
        config[inventory] = true
 | 
			
		||||
        config.useDefaultInventory = false
 | 
			
		||||
        log(string.format("Started with %s inventory", inventory))
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if config.useDefaultInventory then log(string.format("Started with %s default inventory", config.framework == "qb" and "QB" or "ESX")) end
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								resources/[inventory]/tgiann-weapons-on-back/client/client.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/[inventory]/tgiann-weapons-on-back/client/client.lua
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,12 @@
 | 
			
		|||
function canShow(targetPed)
 | 
			
		||||
    local isEntityVisible = IsEntityVisible(targetPed)
 | 
			
		||||
    local getEntityAlpha = GetEntityAlpha(targetPed)
 | 
			
		||||
    local pedIsVisible = isEntityVisible and getEntityAlpha == 255
 | 
			
		||||
    debug("pedIsVisible: " .. tostring(pedIsVisible), "ped:" .. targetPed, "isEntityVisible: " .. tostring(isEntityVisible), "getEntityAlpha: " .. getEntityAlpha)
 | 
			
		||||
    return pedIsVisible
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function debug(...)
 | 
			
		||||
    if not config.debug then return end
 | 
			
		||||
    print(...)
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										206
									
								
								resources/[inventory]/tgiann-weapons-on-back/configs/config.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										206
									
								
								resources/[inventory]/tgiann-weapons-on-back/configs/config.lua
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,206 @@
 | 
			
		|||
--[[
 | 
			
		||||
    - this script needs tgiann-core script to work, you can download the script from your keymaster account
 | 
			
		||||
      Start tgiann-core script after es_extented/qb-core script and before tgiann-* scripts
 | 
			
		||||
      Adjust the tgiann-core config file according to the framework you are using
 | 
			
		||||
 | 
			
		||||
    https://tgiann.gitbook.io/tgiann/scripts/tgiann-weapons-on-back
 | 
			
		||||
 | 
			
		||||
    Note: If you want the weapons to be invisible while in Noclip, the character must be completely invisible. If your character is invisible to other players, other players cannot see these weapons.
 | 
			
		||||
    If you want to edit this, take a look at client/editable.lua
 | 
			
		||||
]]
 | 
			
		||||
 | 
			
		||||
tgiCoreExports = exports["tgiann-core"]
 | 
			
		||||
config = tgiCoreExports:getConfig()
 | 
			
		||||
config.debug = false
 | 
			
		||||
 | 
			
		||||
config.tgiann_attachments = GetResourceState("tgiann-attachment") ~= "missing" -- https://tgiann.tebex.io/package/5399235
 | 
			
		||||
 | 
			
		||||
-- Weapon positions for male and female characters. You can add additional positions here if you like.
 | 
			
		||||
config.positions = {
 | 
			
		||||
    male = {
 | 
			
		||||
        back = { -- We have set 3 positions for the back. You can add or remove extra positions if you like. This setting also applies to other positions.
 | 
			
		||||
            {    -- position 1
 | 
			
		||||
                bone = 24816,
 | 
			
		||||
                offset = vector3(0.285, -0.17, 0.13),
 | 
			
		||||
                rot = vector3(0.0, 170.0, 0.0),
 | 
			
		||||
            },
 | 
			
		||||
            { -- position 2
 | 
			
		||||
                bone = 24816,
 | 
			
		||||
                offset = vector3(0.285, -0.17, 0.0),
 | 
			
		||||
                rot = vector3(0.0, 170.0, 0.0),
 | 
			
		||||
            },
 | 
			
		||||
            { -- position 3
 | 
			
		||||
                bone = 24816,
 | 
			
		||||
                offset = vector3(0.285, -0.17, -0.13),
 | 
			
		||||
                rot = vector3(0.0, 170.0, 0.0),
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        front = {
 | 
			
		||||
            {
 | 
			
		||||
                bone = 24818,
 | 
			
		||||
                offset = vector3(-0.03, 0.19, 0.0),
 | 
			
		||||
                rot = vector3(-10.0, 40.0, 5.0),
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        right = {
 | 
			
		||||
            {
 | 
			
		||||
                bone = 11816,
 | 
			
		||||
                offset = vector3(-0.01, 0.02, 0.215),
 | 
			
		||||
                rot = vector3(-100.0, 60.0, 45.0),
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        rLegBack = {
 | 
			
		||||
            {
 | 
			
		||||
                bone = 11816,
 | 
			
		||||
                offset = vector3(-0.15, -0.11, 0.22),
 | 
			
		||||
                rot = vector3(0.0, 95.0, 180.0),
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        waist = {
 | 
			
		||||
            {
 | 
			
		||||
                bone = 11816,
 | 
			
		||||
                offset = vector3(-0.07, -0.13, 0.05),
 | 
			
		||||
                rot = vector3(180.0, -30.0, 10.0),
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        -- You can add extra positions here if you like.
 | 
			
		||||
        -- The positions you add can be used in the `config.weaponPositions`, `config.weaponGroupPositions` and `config.weaponGroupJobPositions` settings.
 | 
			
		||||
        --[[ exampleCustomName = {
 | 
			
		||||
            {
 | 
			
		||||
                bone = 11816,
 | 
			
		||||
                offset = vector3(-0.07, -0.13, 0.05),
 | 
			
		||||
                rot = vector3(180.0, -30.0, 10.0),
 | 
			
		||||
            }
 | 
			
		||||
        }, ]]
 | 
			
		||||
    },
 | 
			
		||||
    female = {
 | 
			
		||||
        back = {
 | 
			
		||||
            {
 | 
			
		||||
                bone = 24816,
 | 
			
		||||
                offset = vector3(0.285, -0.15, 0.13),
 | 
			
		||||
                rot = vector3(0.0, 170.0, 0.0),
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                bone = 24816,
 | 
			
		||||
                offset = vector3(0.285, -0.15, 0.0),
 | 
			
		||||
                rot = vector3(0.0, 170.0, 0.0),
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                bone = 24816,
 | 
			
		||||
                offset = vector3(0.285, -0.15, -0.13),
 | 
			
		||||
                rot = vector3(0.0, 170.0, 0.0),
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        front = {
 | 
			
		||||
            {
 | 
			
		||||
                bone = 24818,
 | 
			
		||||
                offset = vector3(-0.03, 0.21, 0.0),
 | 
			
		||||
                rot = vector3(-10.0, 40.0, 5.0),
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        right = {
 | 
			
		||||
            {
 | 
			
		||||
                bone = 11816,
 | 
			
		||||
                offset = vector3(-0.09, 0.03, 0.18),
 | 
			
		||||
                rot = vector3(-105.0, 75.0, 45.0),
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        rLegBack = {
 | 
			
		||||
            {
 | 
			
		||||
                bone = 11816,
 | 
			
		||||
                offset = vector3(-0.15, -0.11, 0.22),
 | 
			
		||||
                rot = vector3(0.0, 95.0, 180.0),
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        waist = {
 | 
			
		||||
            {
 | 
			
		||||
                bone = 11816,
 | 
			
		||||
                offset = vector3(-0.07, -0.09, 0.05),
 | 
			
		||||
                rot = vector3(180.0, -30.0, 10.0),
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- Weapons in the list do not appear on the character
 | 
			
		||||
config.disabledWeapons = {
 | 
			
		||||
    weapon_flashlight = true,
 | 
			
		||||
    weapon_knuckle = true,
 | 
			
		||||
    weapon_bottle = true,
 | 
			
		||||
    weapon_snowball = true,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- adjusts the location of the weapon regardless of its group
 | 
			
		||||
config.weaponPositions = {
 | 
			
		||||
    --weapon_pistol = "right",
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- adjusts the position of the weapon regardless of its group
 | 
			
		||||
config.weaponCustomPositions = {
 | 
			
		||||
    male = {
 | 
			
		||||
        weapon_bat = {
 | 
			
		||||
            bone = 24816,
 | 
			
		||||
            offset = vector3(0.0, -0.15, 0.03),
 | 
			
		||||
            rot = vector3(0.0, 80.0, 0.0),
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    female = {
 | 
			
		||||
        weapon_bat = {
 | 
			
		||||
            bone = 24816,
 | 
			
		||||
            offset = vector3(0.0, -0.15, 0.03),
 | 
			
		||||
            rot = vector3(0.0, 80.0, 0.0),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
--"waist"  -  "back"  -  "front"  -  "rigt"  -  "rLegBack"   -  "none"
 | 
			
		||||
config.weaponGroupPostions = {
 | 
			
		||||
    [3539449195] = "back",    --GROUP_DIGISCANNER
 | 
			
		||||
    [-37788308] = "rLegBack", --GROUP_FIREEXTINGUISHER
 | 
			
		||||
    [1175761940] = "none",    --GROUP_HACKINGDEVICE
 | 
			
		||||
    [2725924767] = "back",    --GROUP_HEAVY
 | 
			
		||||
    [-728555052] = "back",    --GROUP_MELEE
 | 
			
		||||
    [3759491383] = "none",    --GROUP_METALDETECTOR
 | 
			
		||||
    [1159398588] = "back",    --GROUP_MG
 | 
			
		||||
    [3493187224] = "none",    --GROUP_NIGHTVISION
 | 
			
		||||
    [431593103] = "none",     --GROUP_PARACHUTE
 | 
			
		||||
    [1595662460] = "none",    --GROUP_PETROLCAN
 | 
			
		||||
    [416676503] = "waist",    --GROUP_PISTOL
 | 
			
		||||
    [970310034] = "back",     --GROUP_RIFLE
 | 
			
		||||
    [860033945] = "back",     --GROUP_SHOTGUN
 | 
			
		||||
    [-957766203] = "front",   --GROUP_SMG
 | 
			
		||||
    [-1212426201] = "back",   --GROUP_SNIPER
 | 
			
		||||
    [690389602] = "none",     --GROUP_STUNGUN
 | 
			
		||||
    [1548507267] = "none",    --GROUP_THROWN
 | 
			
		||||
    [75159441] = "back",      --GROUP_TRANQILIZER
 | 
			
		||||
    [2685387236] = "none",    --GROUP_UNARMED
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- weapon locations for jobs
 | 
			
		||||
config.weaponGroupJobPostions = {
 | 
			
		||||
    {
 | 
			
		||||
        jobs = { "police" },          -- u can add multible job name
 | 
			
		||||
        postions = {
 | 
			
		||||
            [3539449195] = "back",    --GROUP_DIGISCANNER
 | 
			
		||||
            [-37788308] = "rLegBack", --GROUP_FIREEXTINGUISHER
 | 
			
		||||
            [1175761940] = "none",    --GROUP_HACKINGDEVICE
 | 
			
		||||
            [2725924767] = "back",    --GROUP_HEAVY
 | 
			
		||||
            [-728555052] = "back",    --GROUP_MELEE
 | 
			
		||||
            [3759491383] = "none",    --GROUP_METALDETECTOR
 | 
			
		||||
            [1159398588] = "back",    --GROUP_MG
 | 
			
		||||
            [3493187224] = "none",    --GROUP_NIGHTVISION
 | 
			
		||||
            [431593103] = "none",     --GROUP_PARACHUTE
 | 
			
		||||
            [1595662460] = "none",    --GROUP_PETROLCAN
 | 
			
		||||
            [416676503] = "right",    --GROUP_PISTOL
 | 
			
		||||
            [970310034] = "back",     --GROUP_RIFLE
 | 
			
		||||
            [860033945] = "back",     --GROUP_SHOTGUN
 | 
			
		||||
            [-957766203] = "front",   --GROUP_SMG
 | 
			
		||||
            [-1212426201] = "back",   --GROUP_SNIPER
 | 
			
		||||
            [690389602] = "none",     --GROUP_STUNGUN
 | 
			
		||||
            [1548507267] = "none",    --GROUP_THROWN
 | 
			
		||||
            [75159441] = "back",      --GROUP_TRANQILIZER
 | 
			
		||||
            [2685387236] = "none",    --GROUP_UNARMED
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
config.enableInv = {
 | 
			
		||||
    ["content"] = true,
 | 
			
		||||
    ["primary"] = true,
 | 
			
		||||
    ["secondry"] = true,
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										34
									
								
								resources/[inventory]/tgiann-weapons-on-back/fxmanifest.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								resources/[inventory]/tgiann-weapons-on-back/fxmanifest.lua
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,34 @@
 | 
			
		|||
fx_version 'cerulean'
 | 
			
		||||
game 'gta5'
 | 
			
		||||
version '1.0.1'
 | 
			
		||||
 | 
			
		||||
lua54 'yes'
 | 
			
		||||
 | 
			
		||||
dependencies {
 | 
			
		||||
  'tgiann-core',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
escrow_ignore {
 | 
			
		||||
  'configs/*.lua',
 | 
			
		||||
  'checkInv.lua',
 | 
			
		||||
  'client/bridge/*.lua',
 | 
			
		||||
  'client/editable.lua',
 | 
			
		||||
  'server/bridge/*.lua'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
shared_script {
 | 
			
		||||
  'configs/*.lua',
 | 
			
		||||
  'checkInv.lua',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
client_scripts {
 | 
			
		||||
  'client/*.lua',
 | 
			
		||||
  'client/bridge/*.lua'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
server_scripts {
 | 
			
		||||
  "server/server.lua",
 | 
			
		||||
  'server/bridge/*.lua',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
dependency '/assetpacks'
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
if not config.core_inventory then return end
 | 
			
		||||
 | 
			
		||||
tgiCore.cbFunction('tgiann-weapons-on-back:core_inventory:server:getInventory', function(source, cb)
 | 
			
		||||
    local src = source
 | 
			
		||||
    local xPlayer = tgiCore.getPlayer(src)
 | 
			
		||||
    if not xPlayer then return end
 | 
			
		||||
    local citizenid = tgiCore.getCid(xPlayer)
 | 
			
		||||
    local playerItems = {}
 | 
			
		||||
    for inv, canAdd in pairs(config.enableInv) do
 | 
			
		||||
        if canAdd then playerItems[inv] = exports['core_inventory']:getInventory(string.format("%s-%s", inv, citizenid)) end
 | 
			
		||||
    end
 | 
			
		||||
    cb(playerItems)
 | 
			
		||||
end)
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,10 @@
 | 
			
		|||
if config.framework ~= "esx" then return end
 | 
			
		||||
if not config.useDefaultInventory then return end
 | 
			
		||||
 | 
			
		||||
-- esx is very bad, I can't access current inventory data from client
 | 
			
		||||
tgiCore.cbFunction('tgiann-weapons-on-back:esx_inv:server:getInventory', function(source, cb)
 | 
			
		||||
    local src = source
 | 
			
		||||
    local xPlayer = tgiCore.getPlayer(src)
 | 
			
		||||
    if not xPlayer then return end
 | 
			
		||||
    cb(xPlayer.getInventory(), xPlayer.getLoadout())
 | 
			
		||||
end)
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								resources/[inventory]/tgiann-weapons-on-back/server/server.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/[inventory]/tgiann-weapons-on-back/server/server.lua
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue