forked from Simnation/Main
ed
This commit is contained in:
parent
dd9fcf9ecf
commit
364b3e9835
5 changed files with 164 additions and 155 deletions
|
@ -1,8 +1,35 @@
|
|||
local QBCore = exports[Config.CoreName]:GetCoreObject()
|
||||
|
||||
-- Function to check if player has an item
|
||||
local function HasItem(source, itemName)
|
||||
local items = exports["tgiann-inventory"]:GetPlayerItems(source)
|
||||
if not items then return false end
|
||||
|
||||
for _, item in pairs(items) do
|
||||
if item.name == itemName then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
-- Event for client to check if player has an item
|
||||
RegisterNetEvent('nightvision:checkItem', function(itemName)
|
||||
local src = source
|
||||
local hasItem = HasItem(src, itemName)
|
||||
TriggerClientEvent('nightvision:itemCheckResult', src, itemName, hasItem)
|
||||
end)
|
||||
|
||||
-- Register usable items
|
||||
QBCore.Functions.CreateUseableItem(Config.NVItem, function(source, item)
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
if Player.Functions.GetItemByName(item.name) then
|
||||
if HasItem(source, item.name) then
|
||||
TriggerClientEvent('nightvision:toggleHelmet', source)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
QBCore.Functions.CreateUseableItem(Config.ThermalItem, function(source, item)
|
||||
if HasItem(source, item.name) then
|
||||
TriggerClientEvent('nightvision:toggleGlasses', source, 'thermal')
|
||||
end
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue