ScriptsAboutBlogToolsKnowledge BaseReviewsFAQBasketDocsSupport
ESXserver

ESX.RegisterUsableItem

ESX server documentation with a FiveM Lua example.

Summary

Registers a useable item in ESX, running your callback when used. The ESX equivalent of a consumable/tool hook.

Returns

void

Parameters

itemstringThe item name.
callbackfunctionfunction(source).

Example

ESX.RegisterUsableItem('bread', function(source)
  local xPlayer = ESX.GetPlayerFromId(source)
  xPlayer.removeInventoryItem('bread', 1)
  -- feed the player
end)

Common pitfalls

  • Remove the item in the callback or it's never consumed.
  • On ox_inventory servers this is handled via ox hooks instead.

Related functions

Related guides

FiveM scripts done right

Optimized, dual-framework scripts for QBCore and ESX from Viper Development — escrow protected, delivered instantly to your Cfx portal.

Browse Scripts →