Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Belt
- local speedBuffer = {}
- local velBuffer = {}
- local beltOn = false
- local wasInCar = false
- local UI = {
- x = 0.033 ,
- y = -0.048 ,
- }
- IsCar = function(veh)
- local vc = GetVehicleClass(veh)
- return (vc >= 0 and vc <= 7) or (vc >= 9 and vc <= 12) or (vc >= 17 and vc <= 20)
- end
- Fwv = function (entity)
- local hr = GetEntityHeading(entity) + 90.0
- if hr < 0.0 then hr = 360.0 + hr end
- hr = hr * 0.0174533
- return { x = math.cos(hr) * 2.0, y = math.sin(hr) * 2.0 }
- end
- Citizen.CreateThread(function()
- Citizen.Wait(500)
- while true do
- local ped = GetPlayerPed(-1)
- local car = GetVehiclePedIsIn(ped)
- if car ~= 0 and (wasInCar or IsCar(car)) then
- wasInCar = true
- if beltOn then DisableControlAction(0, 75) end
- speedBuffer[2] = speedBuffer[1]
- speedBuffer[1] = GetEntitySpeed(car)
- if speedBuffer[2] ~= nil
- and not beltOn
- and GetEntitySpeedVector(car, true).y > 1.0
- and speedBuffer[1] > 19.25
- and (speedBuffer[2] - speedBuffer[1]) > (speedBuffer[1] * 0.255) then
- local co = GetEntityCoords(ped)
- local fw = Fwv(ped)
- SetEntityCoords(ped, co.x + fw.x, co.y + fw.y, co.z - 0.47, true, true, true)
- SetEntityVelocity(ped, velBuffer[2].x, velBuffer[2].y, velBuffer[2].z)
- Citizen.Wait(1)
- SetPedToRagdoll(ped, 1000, 1000, 0, 0, 0, 0)
- end
- velBuffer[2] = velBuffer[1]
- velBuffer[1] = GetEntityVelocity(car)
- if IsControlJustReleased(0, 311) then
- beltOn = not beltOn
- if beltOn then sendNotification('Du tog på dig bältet.', 'success', 5000)
- else sendNotification('Du tog på dig bältet.', 'error', 5000) end
- end
- elseif wasInCar then
- wasInCar = false
- beltOn = false
- speedBuffer[1], speedBuffer[2] = 0.0, 0.0
- end
- Citizen.Wait(0)
- end
- end)
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- local ped = GetPlayerPed(-1)
- local car = GetVehiclePedIsIn(ped)
- if beltOn and IsPedInAnyVehicle(ped, false) then
- local betonoff = 'PÃ…'
- drawTxt(0.033 + 0.64, -0.048 + 1.35, 1.0,1.0,0.49 , "~y~ BÄLTE: ~w~" .. betonoff, 255, 255, 255, 255)
- elseif not beltOn and IsPedInAnyVehicle(ped, false) then
- local betonoff = 'AV'
- drawTxt(0.033 + 0.64, -0.048 + 1.35, 1.0,1.0,0.49 , "~y~ BÄLTE: ~w~" .. betonoff, 255, 255, 255, 255)
- end
- end
- end)
- function sendNotification(message, messageType, messageTimeout)
- TriggerEvent("pNotify:SendNotification", {
- text = message,
- type = messageType,
- queue = "qalle",
- timeout = messageTimeout,
- layout = "bottomCenter"
- })
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement