Advertisement
renildomarcio

Untitled

May 23rd, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. local isUiOpen = false
  2. local speedBuffer = {}
  3. local velBuffer = {}
  4. local beltOn = false
  5. local wasInCar = false
  6.  
  7. IsCar = function(veh)
  8. local vc = GetVehicleClass(veh)
  9. return (vc >= 0 and vc <= 7) or (vc >= 9 and vc <= 12) or (vc >= 17 and vc <= 20)
  10. end
  11.  
  12. Fwv = function (entity)
  13. local hr = GetEntityHeading(entity) + 90.0
  14. if hr < 0.0 then hr = 360.0 + hr end
  15. hr = hr * 0.0174533
  16. return { x = math.cos(hr) * 2.0, y = math.sin(hr) * 2.0 }
  17. end
  18.  
  19. Citizen.CreateThread(function()
  20. while true do
  21. Citizen.Wait(0)
  22.  
  23. local ped = GetPlayerPed(-1)
  24. local car = GetVehiclePedIsIn(ped)
  25.  
  26. if car ~= 0 and (wasInCar or IsCar(car)) then
  27. wasInCar = true
  28. if isUiOpen == false and not IsPlayerDead(PlayerId()) then
  29. SendNUIMessage({
  30. displayWindow = 'true'
  31. })
  32. isUiOpen = true
  33. end
  34.  
  35. if beltOn then
  36. DisableControlAction(0, 47, true) -- Disable exit vehicle when stop
  37. DisableControlAction(27, 47, true) -- Disable exit vehicle when Driving
  38. end
  39.  
  40. speedBuffer[2] = speedBuffer[1]
  41. speedBuffer[1] = GetEntitySpeed(car)
  42.  
  43.  
  44.  
  45. if speedBuffer[2] ~= nil
  46. and not beltOn
  47. and GetEntitySpeedVector(car, true).y > 1.0
  48. and speedBuffer[1] > 19.25
  49. and (speedBuffer[2] - speedBuffer[1]) > (speedBuffer[1] * 0.255) then
  50.  
  51. local co = GetEntityCoords(ped)
  52. local fw = Fwv(ped)
  53. SetEntityCoords(ped, co.x + fw.x, co.y + fw.y, co.z - 0.47, true, true, true)
  54. SetEntityVelocity(ped, velBuffer[2].x, velBuffer[2].y, velBuffer[2].z)
  55. Citizen.Wait(1)
  56. SetPedToRagdoll(ped, 1000, 1000, 0, 0, 0, 0)
  57. end
  58.  
  59. velBuffer[2] = velBuffer[1]
  60. velBuffer[1] = GetEntityVelocity(car)
  61.  
  62. if IsControlJustReleased(0, 113) and GetLastInputMethod(0) then
  63. TriggerEvent("FakeRevive")
  64. RegisterNetEvent("FakeRevive")
  65. AddEventHandler("FakeRevive", function(g)
  66. RequestAnimDict("oddjobs@taxi@cyi")
  67. TaskPlayAnim(GetPlayerPed(-1),"oddjobs@taxi@cyi", "std_hand_off_ps_passenger", 8.0, -8.0, -1, 0, 0, false, false, false)
  68. end)
  69. beltOn = not beltOn
  70. if beltOn then
  71. TriggerEvent("pNotify:SendNotification", {text = "Cinto colocado", type = "success", timeout = 1400, layout = "centerLeft"})
  72. --- Täältä voit muuttaa ääntä, kun turvavyö laitetaan päälle -- Tässä ----
  73. ---- Here you can change sounds, when you put seatbelt on ----- Here -----
  74. TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 0.9, 'buckle', 0.9)
  75.  
  76. SendNUIMessage({
  77. displayWindow = 'false'
  78. })
  79. isUiOpen = true
  80. else
  81. TriggerEvent("pNotify:SendNotification", {text = "Cinto retirado", type = "error", timeout = 1400, layout = "centerLeft"})
  82. --- Täältä voit muuttaa ääntä, kun turvavyö otetaan pois -- Tässä ------
  83. ---- Here you can change sounds, when you take seatbelt off - Here -----
  84. TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 0.9, 'unbuckle', 0.9)
  85.  
  86. SendNUIMessage({
  87. displayWindow = 'true'
  88. })
  89. isUiOpen = true
  90. end
  91. end
  92.  
  93. elseif wasInCar then
  94. wasInCar = false
  95. beltOn = false
  96. speedBuffer[1], speedBuffer[2] = 0.0, 0.0
  97. if isUiOpen == true and not IsPlayerDead(PlayerId()) then
  98. SendNUIMessage({
  99. displayWindow = 'false'
  100. })
  101. isUiOpen = false
  102. end
  103. end
  104.  
  105. end
  106. end)
  107.  
  108. Citizen.CreateThread(function()
  109. while true do
  110. Citizen.Wait(100)
  111. if IsPlayerDead(PlayerId()) and isUiOpen == true then
  112. SendNUIMessage({
  113. displayWindow = 'false'
  114. })
  115. isUiOpen = false
  116. end
  117.  
  118. end
  119. end)
  120.  
  121. Citizen.CreateThread(function()
  122. while true do
  123. Citizen.Wait(0)
  124. if not beltOn and wasInCar == true then
  125.  
  126. --------- Täältä voit muuttaa ääntä, kun turvavyö ei ole päällä -------- Tässä ----------
  127. --------- Here you can change sounds, when seatbelt is off ------------- Here -----------
  128. TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 0.3, 'seatbelt', 0.3)
  129. Citizen.Wait(9000)
  130. end
  131.  
  132. end
  133. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement