Advertisement
Guest User

Untitled

a guest
Jan 12th, 2018
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. Citizen.CreateThread(function()
  2. while true do
  3. Citizen.Wait(0)
  4. if IsControlJustPressed(1, 246) then
  5. TriggerEvent('pv:setCruiseSpeed')
  6. end
  7. end
  8. end)
  9.  
  10. local cruise = 0
  11.  
  12. AddEventHandler('pv:setCruiseSpeed', function()
  13. if cruise == 0 and IsPedInAnyVehicle(GetPlayerPed(-1), false) then
  14. if GetEntitySpeedVector(GetVehiclePedIsIn(GetPlayerPed(-1), false), true)['y'] > 0 then
  15. cruise = GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false))
  16. local cruiseKm = math.floor(cruise * 3.6 + 0.5)
  17. local cruiseMph = math.floor(cruise * 2.23694 + 0.5)
  18.  
  19. NotificationMessage("CruiseControl: ~g~ TÆNDT~w~ - ~b~ " .. cruiseKm .." km/t")
  20.  
  21. Citizen.CreateThread(function()
  22. while cruise > 0 and GetPedInVehicleSeat(GetVehiclePedIsIn(GetPlayerPed(-1), false), -1) == GetPlayerPed(-1) do
  23. local cruiseVeh = GetVehiclePedIsIn(GetPlayerPed(-1), false)
  24. if IsVehicleOnAllWheels(cruiseVeh) and GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false)) > (cruise - 2.0) then
  25. SetVehicleForwardSpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false), cruise)
  26. else
  27. cruise = 0
  28. NotificationMessage("CruiseControl: ~r~ SLUKKET")
  29. break
  30. end
  31. if IsControlPressed(1, 8) then
  32. cruise = 0
  33. NotificationMessage("CruiseControl: ~r~ SLUKKET")
  34. end
  35. if IsControlPressed(1, 32) then
  36. cruise = 0
  37. TriggerEvent('pv:setNewSpeed')
  38. end
  39. if cruise > 44 then
  40. cruise = 0
  41. NotificationMessage("CruiseControl: Kan ikke sættes så høj!")
  42. break
  43. end
  44. Wait(200)
  45. end
  46. cruise = 0
  47. end)
  48. else
  49. cruise = 0
  50. NotificationMessage("CruiseControl: ~r~SLUKKET")
  51. end
  52. else
  53. if cruise > 0 then
  54. NotificationMessage("CruiseControl: ~r~SLUKKET")
  55. end
  56. cruise = 0
  57. end
  58. end)
  59.  
  60. AddEventHandler('pv:setNewSpeed', function()
  61. Citizen.CreateThread(function()
  62. while IsControlPressed(1, 32) do
  63. Wait(1)
  64. end
  65. TriggerEvent('pv:setCruiseSpeed')
  66. end)
  67. end)
  68.  
  69. function NotificationMessage(message)
  70. SetNotificationTextEntry("STRING")
  71. AddTextComponentString(message)
  72. DrawNotification(0,1)
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement