Merge pull request #419 from thelindat/patch-1

fix(esx/server): use protected calls for Item Callbacks
This commit is contained in:
Mycroft
2022-08-25 13:12:27 +01:00
committed by GitHub
+8 -2
View File
@@ -311,8 +311,14 @@ end
function ESX.UseItem(source, item, ...)
if ESX.Items[item] then
if Core.UsableItemsCallbacks[item] then
Core.UsableItemsCallbacks[item](source, item, ...)
local itemCallback = Core.UsableItemsCallbacks[item]
if itemCallback then
local success, result = pcall(itemCallback, source, item, ...)
if not success then
return result and print(result) or print(('[^3WARNING^7] An error occured when using item ^5"%s"^7! This was not caused by ESX.'):format(item))
end
end
else
print(('[^3WARNING^7] Item ^5"%s"^7 was used but does not exist!'):format(item))