-----------------------------------------------------------------------------------------------------------------------------------------
-- VRP
-----------------------------------------------------------------------------------------------------------------------------------------
local Tunnel = module("vrp", "lib/Tunnel")
-----------------------------------------------------------------------------------------------------------------------------------------
-- CONNECTION
-----------------------------------------------------------------------------------------------------------------------------------------
Hensa = {}
Tunnel.bindInterface("screwdriver", Hensa)
-----------------------------------------------------------------------------------------------------------------------------------------
-- VARIABLES
-----------------------------------------------------------------------------------------------------------------------------------------
local Promise = nil
-----------------------------------------------------------------------------------------------------------------------------------------
-- EXIT
-----------------------------------------------------------------------------------------------------------------------------------------
RegisterNUICallback("Exit", function(data)
	ScrewdriverGameDone()

	TriggerEvent("inventory:Cancel")
end)
-----------------------------------------------------------------------------------------------------------------------------------------
-- DONE
-----------------------------------------------------------------------------------------------------------------------------------------
RegisterNUICallback("Done", function(data)
	ScrewdriverGameDone()
	Promise:resolve(true)

	TriggerEvent("inventory:Cancel")
end)
-----------------------------------------------------------------------------------------------------------------------------------------
-- FAIL
-----------------------------------------------------------------------------------------------------------------------------------------
RegisterNUICallback("Fail", function(data)
	ScrewdriverGameDone()
	Promise:resolve(false)

	TriggerEvent("inventory:Cancel")
end)
-----------------------------------------------------------------------------------------------------------------------------------------
-- SCREWDRIVERGAMEDONE
-----------------------------------------------------------------------------------------------------------------------------------------
ScrewdriverGameDone = function()
	SendNUIMessage({ showUI = false })
	SetNuiFocus(false, false)
end
-----------------------------------------------------------------------------------------------------------------------------------------
-- SCREWDRIVER
-----------------------------------------------------------------------------------------------------------------------------------------
function Hensa.Screwdriver()
	SendNUIMessage({ showUI = true, text1 = "Tentar", text2 = "Mover", text3 = "Sair" })
	SetNuiFocus(true, true)

	Promise = promise.new()

	local result = Citizen.Await(Promise)
	return result
end