forked from Simnation/Main
ed
This commit is contained in:
parent
6a6c44143c
commit
e50a457657
31 changed files with 1135 additions and 764 deletions
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue