Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.52 KB | None | 0 0
  1. --[[
  2. ---------------------------------------------------
  3. LUXART VEHICLE CONTROL (FOR FIVEM)
  4. ---------------------------------------------------
  5. Last revision: MAY 01 2017 (VERS. 1.01)
  6. Coded by Lt.Caine
  7. ---------------------------------------------------
  8. NOTES
  9. LVC will automatically apply to all emergency vehicles (vehicle class 18)
  10. ---------------------------------------------------
  11. CONTROLS
  12. Right indicator: = (Next Custom Radio Track)
  13. Left indicator: - (Previous Custom Radio Track)
  14. Hazard lights: Backspace (Phone Cancel)
  15. Toggle emergency lights: Y (Text Chat Team)
  16. Airhorn: E (Horn)
  17. Toggle siren: , (Previous Radio Station)
  18. Manual siren / Change siren tone: N (Next Radio Station)
  19. Auxiliary siren: Down Arrow (Phone Up)
  20. ---------------------------------------------------
  21. ]]
  22.  
  23. local count_bcast_timer = 0
  24. local delay_bcast_timer = 200
  25.  
  26. local count_sndclean_timer = 0
  27. local delay_sndclean_timer = 400
  28.  
  29. local actv_ind_timer = false
  30. local count_ind_timer = 0
  31. local delay_ind_timer = 180
  32.  
  33. local actv_lxsrnmute_temp = false
  34. local srntone_temp = 0
  35. local dsrn_mute = true
  36.  
  37. local state_indic = {}
  38. local state_lxsiren = {}
  39. local state_pwrcall = {}
  40. local state_airmanu = {}
  41.  
  42. local ind_state_o = 0
  43. local ind_state_l = 1
  44. local ind_state_r = 2
  45. local ind_state_h = 3
  46.  
  47. local snd_lxsiren = {}
  48. local snd_pwrcall = {}
  49. local snd_airmanu = {}
  50.  
  51. -- these models will use their real wail siren, as determined by their assigned audio hash in vehicles.meta
  52. local eModelsWithFireSrn =
  53. {
  54. "FIRETRUK",
  55. }
  56.  
  57. -- models listed below will use AMBULANCE_WARNING as auxiliary siren
  58. -- unlisted models will instead use the default wail as the auxiliary siren
  59. local eModelsWithPcall =
  60. {
  61. "AMBULANCE",
  62. "FIRETRUK",
  63. "LGUARD",
  64. }
  65.  
  66.  
  67. ---------------------------------------------------------------------
  68. function ShowDebug(text)
  69. SetNotificationTextEntry("STRING")
  70. AddTextComponentString(text)
  71. DrawNotification(false, false)
  72. end
  73.  
  74. ---------------------------------------------------------------------
  75. function useFiretruckSiren(veh)
  76. local model = GetEntityModel(veh)
  77. for i = 1, #eModelsWithFireSrn, 1 do
  78. if model == GetHashKey(eModelsWithFireSrn[i]) then
  79. return true
  80. end
  81. end
  82. return false
  83. end
  84.  
  85. ---------------------------------------------------------------------
  86. function usePowercallAuxSrn(veh)
  87. local model = GetEntityModel(veh)
  88. for i = 1, #eModelsWithPcall, 1 do
  89. if model == GetHashKey(eModelsWithPcall[i]) then
  90. return true
  91. end
  92. end
  93. return false
  94. end
  95.  
  96. ---------------------------------------------------------------------
  97. function CleanupSounds()
  98. if count_sndclean_timer > delay_sndclean_timer then
  99. count_sndclean_timer = 0
  100. for k, v in pairs(state_lxsiren) do
  101. if v > 0 then
  102. if not DoesEntityExist(k) or IsEntityDead(k) then
  103. if snd_lxsiren[k] ~= nil then
  104. StopSound(snd_lxsiren[k])
  105. ReleaseSoundId(snd_lxsiren[k])
  106. snd_lxsiren[k] = nil
  107. state_lxsiren[k] = nil
  108. end
  109. end
  110. end
  111. end
  112. for k, v in pairs(state_pwrcall) do
  113. if v == true then
  114. if not DoesEntityExist(k) or IsEntityDead(k) then
  115. if snd_pwrcall[k] ~= nil then
  116. StopSound(snd_pwrcall[k])
  117. ReleaseSoundId(snd_pwrcall[k])
  118. snd_pwrcall[k] = nil
  119. state_pwrcall[k] = nil
  120. end
  121. end
  122. end
  123. end
  124. for k, v in pairs(state_airmanu) do
  125. if v == true then
  126. if not DoesEntityExist(k) or IsEntityDead(k) or IsVehicleSeatFree(k, -1) then
  127. if snd_airmanu[k] ~= nil then
  128. StopSound(snd_airmanu[k])
  129. ReleaseSoundId(snd_airmanu[k])
  130. snd_airmanu[k] = nil
  131. state_airmanu[k] = nil
  132. end
  133. end
  134. end
  135. end
  136. else
  137. count_sndclean_timer = count_sndclean_timer + 1
  138. end
  139. end
  140.  
  141. ---------------------------------------------------------------------
  142. function TogIndicStateForVeh(veh, newstate)
  143. if DoesEntityExist(veh) and not IsEntityDead(veh) then
  144. if newstate == ind_state_o then
  145. SetVehicleIndicatorLights(veh, 0, false) -- R
  146. SetVehicleIndicatorLights(veh, 1, false) -- L
  147. elseif newstate == ind_state_l then
  148. SetVehicleIndicatorLights(veh, 0, false) -- R
  149. SetVehicleIndicatorLights(veh, 1, true) -- L
  150. elseif newstate == ind_state_r then
  151. SetVehicleIndicatorLights(veh, 0, true) -- R
  152. SetVehicleIndicatorLights(veh, 1, false) -- L
  153. elseif newstate == ind_state_h then
  154. SetVehicleIndicatorLights(veh, 0, true) -- R
  155. SetVehicleIndicatorLights(veh, 1, true) -- L
  156. end
  157. state_indic[veh] = newstate
  158. end
  159. end
  160.  
  161. ---------------------------------------------------------------------
  162. function TogMuteDfltSrnForVeh(veh, toggle)
  163. if DoesEntityExist(veh) and not IsEntityDead(veh) then
  164. DisableVehicleImpactExplosionActivation(veh, toggle)
  165. end
  166. end
  167.  
  168. ---------------------------------------------------------------------
  169. function SetLxSirenStateForVeh(veh, newstate)
  170. if DoesEntityExist(veh) and not IsEntityDead(veh) then
  171. if newstate ~= state_lxsiren[veh] then
  172.  
  173. if snd_lxsiren[veh] ~= nil then
  174. StopSound(snd_lxsiren[veh])
  175. ReleaseSoundId(snd_lxsiren[veh])
  176. snd_lxsiren[veh] = nil
  177. end
  178.  
  179. if newstate == 1 then
  180. if useFiretruckSiren(veh) then
  181. TogMuteDfltSrnForVeh(veh, false)
  182. else
  183. snd_lxsiren[veh] = GetSoundId()
  184. PlaySoundFromEntity(snd_lxsiren[veh], "VEHICLES_HORNS_SIREN_1", veh, 0, 0, 0)
  185. TogMuteDfltSrnForVeh(veh, true)
  186. end
  187.  
  188. elseif newstate == 2 then
  189. snd_lxsiren[veh] = GetSoundId()
  190. PlaySoundFromEntity(snd_lxsiren[veh], "VEHICLES_HORNS_SIREN_2", veh, 0, 0, 0)
  191. TogMuteDfltSrnForVeh(veh, true)
  192.  
  193. elseif newstate == 3 then
  194. snd_lxsiren[veh] = GetSoundId()
  195. if useFiretruckSiren(veh) then
  196. PlaySoundFromEntity(snd_lxsiren[veh], "VEHICLES_HORNS_AMBULANCE_WARNING", veh, 0, 0, 0)
  197. else
  198. PlaySoundFromEntity(snd_lxsiren[veh], "VEHICLES_HORNS_POLICE_WARNING", veh, 0, 0, 0)
  199. end
  200. TogMuteDfltSrnForVeh(veh, true)
  201.  
  202. else
  203. TogMuteDfltSrnForVeh(veh, true)
  204.  
  205. end
  206.  
  207. state_lxsiren[veh] = newstate
  208. end
  209. end
  210. end
  211.  
  212. ---------------------------------------------------------------------
  213. function TogPowercallStateForVeh(veh, toggle)
  214. if DoesEntityExist(veh) and not IsEntityDead(veh) then
  215. if toggle == true then
  216. if snd_pwrcall[veh] == nil then
  217. snd_pwrcall[veh] = GetSoundId()
  218. if usePowercallAuxSrn(veh) then
  219. PlaySoundFromEntity(snd_pwrcall[veh], "VEHICLES_HORNS_AMBULANCE_WARNING", veh, 0, 0, 0)
  220. else
  221. PlaySoundFromEntity(snd_pwrcall[veh], "VEHICLES_HORNS_SIREN_1", veh, 0, 0, 0)
  222. end
  223. end
  224. else
  225. if snd_pwrcall[veh] ~= nil then
  226. StopSound(snd_pwrcall[veh])
  227. ReleaseSoundId(snd_pwrcall[veh])
  228. snd_pwrcall[veh] = nil
  229. end
  230. end
  231. state_pwrcall[veh] = toggle
  232. end
  233. end
  234.  
  235. ---------------------------------------------------------------------
  236. function SetAirManuStateForVeh(veh, newstate)
  237. if DoesEntityExist(veh) and not IsEntityDead(veh) then
  238. if newstate ~= state_airmanu[veh] then
  239.  
  240. if snd_airmanu[veh] ~= nil then
  241. StopSound(snd_airmanu[veh])
  242. ReleaseSoundId(snd_airmanu[veh])
  243. snd_airmanu[veh] = nil
  244. end
  245.  
  246. if newstate == 1 then
  247. snd_airmanu[veh] = GetSoundId()
  248. if useFiretruckSiren(veh) then
  249. PlaySoundFromEntity(snd_airmanu[veh], "VEHICLES_HORNS_FIRETRUCK_WARNING", veh, 0, 0, 0)
  250. else
  251. PlaySoundFromEntity(snd_airmanu[veh], "SIRENS_AIRHORN", veh, 0, 0, 0)
  252. end
  253.  
  254. elseif newstate == 2 then
  255. snd_airmanu[veh] = GetSoundId()
  256. PlaySoundFromEntity(snd_airmanu[veh], "VEHICLES_HORNS_SIREN_1", veh, 0, 0, 0)
  257.  
  258. elseif newstate == 3 then
  259. snd_airmanu[veh] = GetSoundId()
  260. PlaySoundFromEntity(snd_airmanu[veh], "VEHICLES_HORNS_SIREN_2", veh, 0, 0, 0)
  261.  
  262. end
  263.  
  264. state_airmanu[veh] = newstate
  265. end
  266. end
  267. end
  268.  
  269.  
  270. ---------------------------------------------------------------------
  271. RegisterNetEvent("lvc_TogIndicState_c")
  272. AddEventHandler("lvc_TogIndicState_c", function(sender, newstate)
  273. local player_s = GetPlayerFromServerId(sender)
  274. local ped_s = GetPlayerPed(player_s)
  275. if DoesEntityExist(ped_s) and not IsEntityDead(ped_s) then
  276. if ped_s ~= GetPlayerPed(-1) then
  277. if IsPedInAnyVehicle(ped_s, false) then
  278. local veh = GetVehiclePedIsUsing(ped_s)
  279. TogIndicStateForVeh(veh, newstate)
  280. end
  281. end
  282. end
  283. end)
  284.  
  285. ---------------------------------------------------------------------
  286. RegisterNetEvent("lvc_TogDfltSrnMuted_c")
  287. AddEventHandler("lvc_TogDfltSrnMuted_c", function(sender, toggle)
  288. local player_s = GetPlayerFromServerId(sender)
  289. local ped_s = GetPlayerPed(player_s)
  290. if DoesEntityExist(ped_s) and not IsEntityDead(ped_s) then
  291. if ped_s ~= GetPlayerPed(-1) then
  292. if IsPedInAnyVehicle(ped_s, false) then
  293. local veh = GetVehiclePedIsUsing(ped_s)
  294. TogMuteDfltSrnForVeh(veh, toggle)
  295. end
  296. end
  297. end
  298. end)
  299.  
  300. ---------------------------------------------------------------------
  301. RegisterNetEvent("lvc_SetLxSirenState_c")
  302. AddEventHandler("lvc_SetLxSirenState_c", function(sender, newstate)
  303. local player_s = GetPlayerFromServerId(sender)
  304. local ped_s = GetPlayerPed(player_s)
  305. if DoesEntityExist(ped_s) and not IsEntityDead(ped_s) then
  306. if ped_s ~= GetPlayerPed(-1) then
  307. if IsPedInAnyVehicle(ped_s, false) then
  308. local veh = GetVehiclePedIsUsing(ped_s)
  309. SetLxSirenStateForVeh(veh, newstate)
  310. end
  311. end
  312. end
  313. end)
  314.  
  315. ---------------------------------------------------------------------
  316. RegisterNetEvent("lvc_TogPwrcallState_c")
  317. AddEventHandler("lvc_TogPwrcallState_c", function(sender, toggle)
  318. local player_s = GetPlayerFromServerId(sender)
  319. local ped_s = GetPlayerPed(player_s)
  320. if DoesEntityExist(ped_s) and not IsEntityDead(ped_s) then
  321. if ped_s ~= GetPlayerPed(-1) then
  322. if IsPedInAnyVehicle(ped_s, false) then
  323. local veh = GetVehiclePedIsUsing(ped_s)
  324. TogPowercallStateForVeh(veh, toggle)
  325. end
  326. end
  327. end
  328. end)
  329.  
  330. ---------------------------------------------------------------------
  331. RegisterNetEvent("lvc_SetAirManuState_c")
  332. AddEventHandler("lvc_SetAirManuState_c", function(sender, newstate)
  333. local player_s = GetPlayerFromServerId(sender)
  334. local ped_s = GetPlayerPed(player_s)
  335. if DoesEntityExist(ped_s) and not IsEntityDead(ped_s) then
  336. if ped_s ~= GetPlayerPed(-1) then
  337. if IsPedInAnyVehicle(ped_s, false) then
  338. local veh = GetVehiclePedIsUsing(ped_s)
  339. SetAirManuStateForVeh(veh, newstate)
  340. end
  341. end
  342. end
  343. end)
  344.  
  345.  
  346.  
  347. ---------------------------------------------------------------------
  348. Citizen.CreateThread(function()
  349. while true do
  350.  
  351. CleanupSounds()
  352.  
  353. ----- IS IN VEHICLE -----
  354. local playerped = GetPlayerPed(-1)
  355. if IsPedInAnyVehicle(playerped, false) then
  356.  
  357. ----- IS DRIVER -----
  358. local veh = GetVehiclePedIsUsing(playerped)
  359. if GetPedInVehicleSeat(veh, -1) == playerped then
  360.  
  361. DisableControlAction(0, 84, true) -- INPUT_VEH_PREV_RADIO_TRACK
  362. DisableControlAction(0, 83, true) -- INPUT_VEH_NEXT_RADIO_TRACK
  363.  
  364. if state_indic[veh] ~= ind_state_o and state_indic[veh] ~= ind_state_l and state_indic[veh] ~= ind_state_r and state_indic[veh] ~= ind_state_h then
  365. state_indic[veh] = ind_state_o
  366. end
  367.  
  368. -- INDIC AUTO CONTROL
  369. if actv_ind_timer == true then
  370. if state_indic[veh] == ind_state_l or state_indic[veh] == ind_state_r then
  371. if GetEntitySpeed(veh) < 6 then
  372. count_ind_timer = 0
  373. else
  374. if count_ind_timer > delay_ind_timer then
  375. count_ind_timer = 0
  376. actv_ind_timer = false
  377. state_indic[veh] = ind_state_o
  378. PlaySoundFrontend(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
  379. TogIndicStateForVeh(veh, state_indic[veh])
  380. count_bcast_timer = delay_bcast_timer
  381. else
  382. count_ind_timer = count_ind_timer + 1
  383. end
  384. end
  385. end
  386. end
  387.  
  388.  
  389. --- IS EMERG VEHICLE ---
  390. if GetVehicleClass(veh) == 18 then
  391.  
  392. local actv_manu = false
  393. local actv_horn = false
  394.  
  395. DisableControlAction(0, 86, true) -- INPUT_VEH_HORN
  396. DisableControlAction(0, 172, true) -- INPUT_CELLPHONE_UP
  397. --DisableControlAction(0, 173, true) -- INPUT_CELLPHONE_DOWN
  398. --DisableControlAction(0, 174, true) -- INPUT_CELLPHONE_LEFT
  399. --DisableControlAction(0, 175, true) -- INPUT_CELLPHONE_RIGHT
  400. DisableControlAction(0, 81, true) -- INPUT_VEH_NEXT_RADIO
  401. DisableControlAction(0, 82, true) -- INPUT_VEH_PREV_RADIO
  402. DisableControlAction(0, 19, true) -- INPUT_CHARACTER_WHEEL
  403. DisableControlAction(0, 85, true) -- INPUT_VEH_RADIO_WHEEL
  404. DisableControlAction(0, 80, true) -- INPUT_VEH_CIN_CAM
  405.  
  406. SetVehRadioStation(veh, "OFF")
  407. SetVehicleRadioEnabled(veh, false)
  408.  
  409. if state_lxsiren[veh] ~= 1 and state_lxsiren[veh] ~= 2 and state_lxsiren[veh] ~= 3 then
  410. state_lxsiren[veh] = 0
  411. end
  412. if state_pwrcall[veh] ~= true then
  413. state_pwrcall[veh] = false
  414. end
  415. if state_airmanu[veh] ~= 1 and state_airmanu[veh] ~= 2 and state_airmanu[veh] ~= 3 then
  416. state_airmanu[veh] = 0
  417. end
  418.  
  419. if useFiretruckSiren(veh) and state_lxsiren[veh] == 1 then
  420. TogMuteDfltSrnForVeh(veh, false)
  421. dsrn_mute = false
  422. else
  423. TogMuteDfltSrnForVeh(veh, true)
  424. dsrn_mute = true
  425. end
  426.  
  427. if not IsVehicleSirenOn(veh) and state_lxsiren[veh] > 0 then
  428. PlaySoundFrontend(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
  429. SetLxSirenStateForVeh(veh, 0)
  430. count_bcast_timer = delay_bcast_timer
  431. end
  432. if not IsVehicleSirenOn(veh) and state_pwrcall[veh] == true then
  433. PlaySoundFrontend(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
  434. TogPowercallStateForVeh(veh, false)
  435. count_bcast_timer = delay_bcast_timer
  436. end
  437.  
  438. ----- CONTROLS -----
  439. if not IsPauseMenuActive() then
  440.  
  441. -- TOG DFLT SRN LIGHTS
  442. if IsDisabledControlJustReleased(0, 85) then
  443. if IsVehicleSirenOn(veh) then
  444. PlaySoundFrontend(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
  445. SetVehicleSiren(veh, false)
  446. else
  447. PlaySoundFrontend(-1, "NAV_LEFT_RIGHT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
  448. SetVehicleSiren(veh, true)
  449. count_bcast_timer = delay_bcast_timer
  450. end
  451.  
  452. -- TOG LX SIREN
  453. elseif IsDisabledControlJustReleased(0, 19) or IsDisabledControlJustReleased(0, 82) then
  454. local cstate = state_lxsiren[veh]
  455. if cstate == 0 then
  456. if IsVehicleSirenOn(veh) then
  457. PlaySoundFrontend(-1, "NAV_LEFT_RIGHT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1) -- on
  458. SetLxSirenStateForVeh(veh, 1)
  459. count_bcast_timer = delay_bcast_timer
  460. end
  461. else
  462. PlaySoundFrontend(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1) -- off
  463. SetLxSirenStateForVeh(veh, 0)
  464. count_bcast_timer = delay_bcast_timer
  465. end
  466.  
  467. -- POWERCALL
  468. elseif IsDisabledControlJustReleased(0, 172) then
  469. if state_pwrcall[veh] == true then
  470. PlaySoundFrontend(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
  471. TogPowercallStateForVeh(veh, false)
  472. count_bcast_timer = delay_bcast_timer
  473. else
  474. if IsVehicleSirenOn(veh) then
  475. PlaySoundFrontend(-1, "NAV_LEFT_RIGHT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
  476. TogPowercallStateForVeh(veh, true)
  477. count_bcast_timer = delay_bcast_timer
  478. end
  479. end
  480.  
  481. end
  482.  
  483. -- BROWSE LX SRN TONES
  484. if state_lxsiren[veh] > 0 then
  485. if IsDisabledControlJustReleased(0, 80) or IsDisabledControlJustReleased(0, 81) then
  486. if IsVehicleSirenOn(veh) then
  487. local cstate = state_lxsiren[veh]
  488. local nstate = 1
  489. PlaySoundFrontend(-1, "NAV_LEFT_RIGHT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1) -- on
  490. if cstate == 1 then
  491. nstate = 2
  492. elseif cstate == 2 then
  493. nstate = 3
  494. else
  495. nstate = 1
  496. end
  497. SetLxSirenStateForVeh(veh, nstate)
  498. count_bcast_timer = delay_bcast_timer
  499. end
  500. end
  501. end
  502.  
  503. -- MANU
  504. if state_lxsiren[veh] < 1 then
  505. if IsDisabledControlPressed(0, 80) or IsDisabledControlPressed(0, 81) then
  506. actv_manu = true
  507. else
  508. actv_manu = false
  509. end
  510. else
  511. actv_manu = false
  512. end
  513.  
  514. -- HORN
  515. if IsDisabledControlPressed(0, 86) then
  516. actv_horn = true
  517. else
  518. actv_horn = false
  519. end
  520.  
  521. end
  522.  
  523. ---- ADJUST HORN / MANU STATE ----
  524. local hmanu_state_new = 0
  525. if actv_horn == true and actv_manu == false then
  526. hmanu_state_new = 1
  527. elseif actv_horn == false and actv_manu == true then
  528. hmanu_state_new = 2
  529. elseif actv_horn == true and actv_manu == true then
  530. hmanu_state_new = 3
  531. end
  532. if hmanu_state_new == 1 then
  533. if not useFiretruckSiren(veh) then
  534. if state_lxsiren[veh] > 0 and actv_lxsrnmute_temp == false then
  535. srntone_temp = state_lxsiren[veh]
  536. SetLxSirenStateForVeh(veh, 0)
  537. actv_lxsrnmute_temp = true
  538. end
  539. end
  540. else
  541. if not useFiretruckSiren(veh) then
  542. if actv_lxsrnmute_temp == true then
  543. SetLxSirenStateForVeh(veh, srntone_temp)
  544. actv_lxsrnmute_temp = false
  545. end
  546. end
  547. end
  548. if state_airmanu[veh] ~= hmanu_state_new then
  549. SetAirManuStateForVeh(veh, hmanu_state_new)
  550. count_bcast_timer = delay_bcast_timer
  551. end
  552. end
  553.  
  554.  
  555. --- IS ANY LAND VEHICLE ---
  556. if GetVehicleClass(veh) ~= 14 and GetVehicleClass(veh) ~= 15 and GetVehicleClass(veh) ~= 16 and GetVehicleClass(veh) ~= 21 then
  557.  
  558. ----- CONTROLS -----
  559. if not IsPauseMenuActive() then
  560.  
  561. -- IND L
  562. if IsDisabledControlJustReleased(0, 84) then -- INPUT_VEH_PREV_RADIO_TRACK
  563. local cstate = state_indic[veh]
  564. if cstate == ind_state_l then
  565. state_indic[veh] = ind_state_o
  566. actv_ind_timer = false
  567. PlaySoundFrontend(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
  568. else
  569. state_indic[veh] = ind_state_l
  570. actv_ind_timer = true
  571. PlaySoundFrontend(-1, "NAV_LEFT_RIGHT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
  572. end
  573. TogIndicStateForVeh(veh, state_indic[veh])
  574. count_ind_timer = 0
  575. count_bcast_timer = delay_bcast_timer
  576. -- IND R
  577. elseif IsDisabledControlJustReleased(0, 83) then -- INPUT_VEH_NEXT_RADIO_TRACK
  578. local cstate = state_indic[veh]
  579. if cstate == ind_state_r then
  580. state_indic[veh] = ind_state_o
  581. actv_ind_timer = false
  582. PlaySoundFrontend(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
  583. else
  584. state_indic[veh] = ind_state_r
  585. actv_ind_timer = true
  586. PlaySoundFrontend(-1, "NAV_LEFT_RIGHT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
  587. end
  588. TogIndicStateForVeh(veh, state_indic[veh])
  589. count_ind_timer = 0
  590. count_bcast_timer = delay_bcast_timer
  591. -- IND H
  592. elseif IsControlJustReleased(0, 202) then -- INPUT_FRONTEND_CANCEL / Backspace
  593. if GetLastInputMethod(0) then -- last input was with kb
  594. local cstate = state_indic[veh]
  595. if cstate == ind_state_h then
  596. state_indic[veh] = ind_state_o
  597. PlaySoundFrontend(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
  598. else
  599. state_indic[veh] = ind_state_h
  600. PlaySoundFrontend(-1, "NAV_LEFT_RIGHT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
  601. end
  602. TogIndicStateForVeh(veh, state_indic[veh])
  603. actv_ind_timer = false
  604. count_ind_timer = 0
  605. count_bcast_timer = delay_bcast_timer
  606. end
  607. end
  608.  
  609. end
  610.  
  611.  
  612. ----- AUTO BROADCAST VEH STATES -----
  613. if count_bcast_timer > delay_bcast_timer then
  614. count_bcast_timer = 0
  615. --- IS EMERG VEHICLE ---
  616. if GetVehicleClass(veh) == 18 then
  617. TriggerServerEvent("lvc_TogDfltSrnMuted_s", dsrn_mute)
  618. TriggerServerEvent("lvc_SetLxSirenState_s", state_lxsiren[veh])
  619. TriggerServerEvent("lvc_TogPwrcallState_s", state_pwrcall[veh])
  620. TriggerServerEvent("lvc_SetAirManuState_s", state_airmanu[veh])
  621. end
  622. --- IS ANY OTHER VEHICLE ---
  623. TriggerServerEvent("lvc_TogIndicState_s", state_indic[veh])
  624. else
  625. count_bcast_timer = count_bcast_timer + 1
  626. end
  627.  
  628. end
  629.  
  630. end
  631. end
  632.  
  633. Citizen.Wait(0)
  634. end
  635. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement