DisableControlAction To prevent players from exiting the vehicle when they have the seatbelt on doesn't work

I need help to prevent player from exiting the vehicle when they have the seatbelt on

This is the code:

RegisterCommand(“seatbelt”, function()
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)

if VehicleType ~= 'automobile' and VehicleType ~= 'heli' then
	return
end

if vehicle ~= 0 then
	SeatBelt = not SeatBelt

	SendNUIMessage({
		action = "belt",
		status = SeatBelt
	})

	if SeatBelt then
		Citizen.CreateThread(function()
			while activated do
				Citizen.Wait(1)
				DisableControlAction(0, 75, true)
				DisableControlAction(27, 75, true)
			end
		end)
	end
end

end)

RegisterKeyMapping(‘Cinturon’, ‘Abrochar/Desabrochar cinturon de seguridad’, ‘keyboard’, beltKey)

You are using the variable activated in the thread. You need to use SeatBelt

Thanks mate

1 Like