mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-28 17:01:16 +00:00
fix: remove usable item after resource stop
This commit is contained in:
@@ -18,6 +18,14 @@ AddEventHandler('playerDropped', function(reason)
|
||||
QBCore.Players[src] = nil
|
||||
end)
|
||||
|
||||
AddEventHandler("onResourceStop", function(resName)
|
||||
for i,v in pairs(QBCore.UsableItems) do
|
||||
if v.resource == resName then
|
||||
QBCore.UsableItems[i] = nil
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- Player Connecting
|
||||
|
||||
local function onPlayerConnecting(name, _, deferrals)
|
||||
|
||||
+20
-1
@@ -462,7 +462,26 @@ end
|
||||
---@param item string
|
||||
---@param data function
|
||||
function QBCore.Functions.CreateUseableItem(item, data)
|
||||
QBCore.UsableItems[item] = data
|
||||
local rawFunc = nil
|
||||
|
||||
if type(data) == "table" then
|
||||
if rawget(data, '__cfx_functionReference') then
|
||||
rawFunc = data
|
||||
elseif data.cb and rawget(data.cb, '__cfx_functionReference') then
|
||||
rawFunc = data.cb
|
||||
elseif data.callback and rawget(data.callback, '__cfx_functionReference') then
|
||||
rawFunc = data.callback
|
||||
end
|
||||
elseif type(data) == "function" then
|
||||
rawFunc = data
|
||||
end
|
||||
|
||||
if rawFunc then
|
||||
QBCore.UsableItems[item] = {
|
||||
func = rawFunc,
|
||||
resource = GetInvokingResource()
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
---Checks if the given item is usable
|
||||
|
||||
Reference in New Issue
Block a user