SHARE
TWEET

Untitled

a guest Jan 16th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Belt
  2.  
  3.  
  4. local speedBuffer  = {}
  5. local velBuffer    = {}
  6. local beltOn       = false
  7. local wasInCar     = false
  8.  
  9. local UI = {
  10.  
  11.     x =  0.033 ,
  12.     y =  -0.048 ,
  13.  
  14. }
  15.  
  16. IsCar = function(veh)
  17.             local vc = GetVehicleClass(veh)
  18.             return (vc >= 0 and vc <= 7) or (vc >= 9 and vc <= 12) or (vc >= 17 and vc <= 20)
  19.         end
  20.  
  21. Fwv = function (entity)
  22.             local hr = GetEntityHeading(entity) + 90.0
  23.             if hr < 0.0 then hr = 360.0 + hr end
  24.             hr = hr * 0.0174533
  25.             return { x = math.cos(hr) * 2.0, y = math.sin(hr) * 2.0 }
  26.       end
  27.  
  28. Citizen.CreateThread(function()
  29.     Citizen.Wait(500)
  30.     while true do
  31.        
  32.         local ped = GetPlayerPed(-1)
  33.         local car = GetVehiclePedIsIn(ped)
  34.        
  35.         if car ~= 0 and (wasInCar or IsCar(car)) then
  36.        
  37.             wasInCar = true
  38.            
  39.             if beltOn then DisableControlAction(0, 75) end
  40.            
  41.             speedBuffer[2] = speedBuffer[1]
  42.             speedBuffer[1] = GetEntitySpeed(car)
  43.            
  44.             if speedBuffer[2] ~= nil
  45.                and not beltOn
  46.                and GetEntitySpeedVector(car, true).y > 1.0  
  47.                and speedBuffer[1] > 19.25
  48.                and (speedBuffer[2] - speedBuffer[1]) > (speedBuffer[1] * 0.255) then
  49.                
  50.                 local co = GetEntityCoords(ped)
  51.                 local fw = Fwv(ped)
  52.                 SetEntityCoords(ped, co.x + fw.x, co.y + fw.y, co.z - 0.47, true, true, true)
  53.                 SetEntityVelocity(ped, velBuffer[2].x, velBuffer[2].y, velBuffer[2].z)
  54.                 Citizen.Wait(1)
  55.                 SetPedToRagdoll(ped, 1000, 1000, 0, 0, 0, 0)
  56.             end
  57.                
  58.             velBuffer[2] = velBuffer[1]
  59.             velBuffer[1] = GetEntityVelocity(car)
  60.  
  61. if IsControlJustReleased(0, 311) then
  62.                 beltOn = not beltOn
  63.                 if beltOn then sendNotification('Du tog pÃ¥ dig bältet.', 'success', 5000)
  64.                 else sendNotification('Du tog pÃ¥ dig bältet.', 'error', 5000) end
  65.             end
  66.         elseif wasInCar then
  67.             wasInCar = false
  68.             beltOn = false
  69.             speedBuffer[1], speedBuffer[2] = 0.0, 0.0
  70.         end
  71.         Citizen.Wait(0)
  72.     end
  73. end)
  74.  
  75. Citizen.CreateThread(function()
  76.     while true do
  77.         Citizen.Wait(0)
  78.         local ped = GetPlayerPed(-1)
  79.         local car = GetVehiclePedIsIn(ped)
  80.         if beltOn and IsPedInAnyVehicle(ped, false) then
  81.             local betonoff = 'PÃ…'
  82.             drawTxt(0.033 + 0.64,   -0.048 + 1.35, 1.0,1.0,0.49 , "~y~ BÄLTE: ~w~" .. betonoff, 255, 255, 255, 255)
  83.         elseif not beltOn and IsPedInAnyVehicle(ped, false) then
  84.             local betonoff = 'AV'
  85.             drawTxt(0.033 + 0.64,   -0.048 + 1.35, 1.0,1.0,0.49 , "~y~ BÄLTE: ~w~" .. betonoff, 255, 255, 255, 255)
  86.         end
  87.     end
  88. end)
  89.  
  90. function sendNotification(message, messageType, messageTimeout)
  91.     TriggerEvent("pNotify:SendNotification", {
  92.         text = message,
  93.         type = messageType,
  94.         queue = "qalle",
  95.         timeout = messageTimeout,
  96.         layout = "bottomCenter"
  97.     })
  98. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top