Helpful Functions to Copy
Various functions that can be used in other scripts
Disable inventory:
-- Function
function lockInv(toggle)
if toggle then
LocalPlayer.state:set("inv_busy", true, true) TriggerEvent('inventory:client:busy:status', true) TriggerEvent('canUseInventoryAndHotbar:toggle', false)
else
LocalPlayer.state:set("inv_busy", false, true) TriggerEvent('inventory:client:busy:status', false) TriggerEvent('canUseInventoryAndHotbar:toggle', true)
end
end
-- Use Case
-- Notes: When lockInv(true) is used you must always have a lockInv(false) at the end of the function or event
lockInv(true) -- Disables Inventory
lockInv(false) -- Enables InventoryPolice Online Check:
-- Server-side: callback for getting # of police online
QBCore.Functions.CreateCallback('qb-jewellery:server:getCops', function(source, cb)
local amount = 0
for _, v in pairs(QBCore.Functions.GetQBPlayers()) do
if (v.PlayerData.job.name == 'police' or v.PlayerData.job.type == 'leo') and v.PlayerData.job.onduty then
amount = amount + 1
end
end
cachedPoliceAmount[source] = amount
cb(amount)
end)
-- Client-side usage
QBCore.Functions.TriggerCallback('qb-jewellery:server:getCops', function(cops)
if cops >= Config.RequiredCops then
end
end)Last updated