Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. Citizen.CreateThread(function()
  2.  
  3. while true do
  4. Citizen.Wait(100)
  5.  
  6. local veh = GetVehiclePedIsIn(GetPlayerPed(-1))
  7. local height = GetEntityHeightAboveGround(veh)
  8. if GetDisplayNameFromVehicleModel(GetEntityModel(veh)) == "POLMAV" then
  9. if (height > 75) then
  10. local lCoords = GetEntityCoords(veh)
  11. TriggerServerEvent('Server:NPAS', lCoords, height)
  12. else
  13. TriggerServerEvent('Server:NPASstop')
  14. end
  15. end
  16.  
  17. end
  18. end)
  19.  
  20. RegisterNetEvent('Client:NPAS')
  21. AddEventHandler('Client:NPAS', function(lCoords, height)
  22. local nCoords = GetEntityCoords(GetPlayerPed(-1))
  23. local hDist = GetDistanceBetweenCoords(lCoords.x, lCoords.y, lCoords.z, nCoords.x, nCoords.y, nCoords.z, false)
  24. local soundVolume = 0.35
  25. if (hDist > 0.8) then
  26. if (height < 150) then
  27. vDist = 1-((150-height)/75)
  28. elseif (height > 150) and (height < 330) then
  29. vDist = ((330-height)/180)
  30. end
  31.  
  32. local hVol = 1-(hDist/500)
  33.  
  34. soundVolume = soundVolume*vDist*hVol
  35.  
  36. SendNUIMessage({
  37. transactionType = 'npas',
  38. transactionVolume = soundVolume
  39. })
  40. end
  41.  
  42. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement