You’ll want to create an infinite loop checking if the E key is pressed.
Citizen.CreateThread(function()
while true do
if IsControlJustPressed(1, 86) then --INPUT_HORN
local doorAngle = GetVehicleDoorAngleRatio(vehicle, 5) --check if trunk is open
if doorAngle == 0 then
SetVehicleDoorOpen(vehicle, 5, false, false)
else
SetVehicleDoorShut(vehicle, 5, false)
end
end
end
end)
As for displaying the help message, I wouldn’t recommend having anything permanently displayed in case it interferes with other scripts and their functionality.
That sounds like a much better idea. In which case, you would need another infinite loop checking the position of the player’s ped compared to the back of the vehicle and then display the message if they are within a reasonable distance.
Instead of giving you the code, this time I’m going to give you some natives to help.
GetDistanceBetweenCoords
GetEntityCoords
You can look more into these natives here. Good luck