mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 09:48:52 +00:00
fix(esx/server): use protected calls for Item Callbacks
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user