From 5fdcc34c523a7e7c1422013aa3fc1b9b08da030c Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Fri, 15 May 2020 17:10:51 -0500 Subject: [PATCH] Update esx_voice Add feature for voice UI element to not show until loading screen is off --- client/main.lua | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/client/main.lua b/client/main.lua index 7b461c26..9c5a3b57 100644 --- a/client/main.lua +++ b/client/main.lua @@ -23,36 +23,38 @@ AddEventHandler('onClientMapStart', function() end end) -Citizen.CreateThread(function() - while true do - Citizen.Wait(1) +AddEventHandler('esx:loadingScreenOff', function() + Citizen.CreateThread(function() + while true do + Citizen.Wait(1) + + if IsControlJustPressed(1, 74) and IsControlPressed(1, 21) then + voice.current = (voice.current + 1) % 3 + if voice.current == 0 then + NetworkSetTalkerProximity(voice.default) + voice.level = _U('normal') + elseif voice.current == 1 then + NetworkSetTalkerProximity(voice.shout) + voice.level = _U('shout') + elseif voice.current == 2 then + NetworkSetTalkerProximity(voice.whisper) + voice.level = _U('whisper') + end + end - if IsControlJustPressed(1, 74) and IsControlPressed(1, 21) then - voice.current = (voice.current + 1) % 3 if voice.current == 0 then - NetworkSetTalkerProximity(voice.default) voice.level = _U('normal') elseif voice.current == 1 then - NetworkSetTalkerProximity(voice.shout) voice.level = _U('shout') elseif voice.current == 2 then - NetworkSetTalkerProximity(voice.whisper) voice.level = _U('whisper') end - end - if voice.current == 0 then - voice.level = _U('normal') - elseif voice.current == 1 then - voice.level = _U('shout') - elseif voice.current == 2 then - voice.level = _U('whisper') + if NetworkIsPlayerTalking(PlayerId()) then + drawLevel(41, 128, 185, 255) + else + drawLevel(185, 185, 185, 255) + end end - - if NetworkIsPlayerTalking(PlayerId()) then - drawLevel(41, 128, 185, 255) - else - drawLevel(185, 185, 185, 255) - end - end + end) end)