[CLOSED]ESX RegisterUsableItem can't use item


#1

Hello,
I wanted to create an item that after use would trigger a client script. Everything works fine, I can get an item via commands but I can’t use the item in game.After that I tried to copy some code from esx_basicneeds but without any result

ESX.RegisterUsableItem('Code', function(source)

	local xPlayer = ESX.GetPlayerFromId(source)

	xPlayer.removeInventoryItem('Code', 1)

	TriggerClientEvent('RemoteHack', source)

end)

#2

you are forget this line?

TriggerEvent('■■■:getSharedObject', function(obj) ESX = obj end)