I have tried alot of different ways to do this, and I have no idea why my code is not working in-game. Tried different control presses and nothing works.
Edit: It doesn’t even need on VehicleHorn, I just want it to show something on a keypress.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CitizenFX.Core.UI;
using CitizenFX.Core;
using CitizenFX.Core.Native;
namespace Example
{
public class Class1 : BaseScript
{
public Class1()
{
Tick += OnTick;
}
public async Task OnTick()
{
if (Game.IsControlJustPressed(0, Control.VehicleHorn))
{
Screen.ShowNotification("Vehicle horn was pressed!");
}
await BaseScript.Delay(0);
}
}
}
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if IsControlJustPressed(0, 86) then
ShowNotification("Vehicle horn was pressed!")
end
end
end)
function ShowNotification(text)
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(false, false)
end