Advertisement
Guest User

indicators_client.lua

a guest
Dec 30th, 2016
4,647
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. local IndicatorL = false
  2. local IndicatorR = false
  3.  
  4. Citizen.CreateThread(function()
  5. while true do
  6. Citizen.Wait(0)
  7. if IsControlJustPressed(1, 43) then -- left
  8. if IsPedInAnyVehicle(GetPlayerPed(-1), true) then
  9. TriggerEvent('Indicator', 'left')
  10. end
  11. end
  12.  
  13. if IsControlJustPressed(1, 42) then --right
  14. if IsPedInAnyVehicle(GetPlayerPed(-1), true) then
  15. TriggerEvent('Indicator', 'right')
  16. end
  17. end
  18. end
  19. end)
  20.  
  21. AddEventHandler('Indicator', function(dir)
  22. Citizen.CreateThread(function()
  23. local Ped = GetPlayerPed(-1)
  24. if IsPedInAnyVehicle(Ped, true) then
  25. local Veh = GetVehiclePedIsIn(Ped, false)
  26. if GetPedInVehicleSeat(Veh, -1) == Ped then
  27. if dir == 'left' then
  28. IndicatorL = not IndicatorL
  29. TriggerServerEvent('IndicatorL', IndicatorL)
  30. elseif dir == 'right' then
  31. IndicatorR = not IndicatorR
  32. TriggerServerEvent('IndicatorR', IndicatorR)
  33. end
  34. end
  35. end
  36. end)
  37. end)
  38.  
  39. RegisterNetEvent('updateIndicators')
  40. AddEventHandler('updateIndicators', function(PID, dir, Toggle)
  41. --if isPlayerOnline(PID) then
  42. local Veh = GetVehiclePedIsIn(GetPlayerPed(GetPlayerFromServerId(PID)), false)
  43. if dir == 'left' then
  44. SetVehicleIndicatorLights(Veh, 1, Toggle)
  45. elseif dir == 'right' then
  46. SetVehicleIndicatorLights(Veh, 0, Toggle)
  47. end
  48. --end
  49. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement