diff --git a/client/main.lua b/client/main.lua index 9c5a3b57..a235d995 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,14 +1,28 @@ +local Keys = { + ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, + ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, + ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, + ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, + ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, + ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, + ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, + ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, + ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 +} + local voice = {default = 5.0, shout = 12.0, whisper = 1.0, current = 0, level = nil} function drawLevel(r, g, b, a) SetTextFont(4) + SetTextProportional(1) SetTextScale(0.5, 0.5) SetTextColour(r, g, b, a) - SetTextDropshadow(0, 0, 0, 0, 255) + SetTextDropShadow(0, 0, 0, 0, 255) + SetTextEdge(1, 0, 0, 0, 255) SetTextDropShadow() SetTextOutline() - BeginTextCommandDisplayText('STRING') + BeginTextCommandDisplayText("STRING") AddTextComponentSubstringPlayerName(_U('voice', voice.level)) EndTextCommandDisplayText(0.175, 0.92) end @@ -23,38 +37,40 @@ AddEventHandler('onClientMapStart', function() end end) -AddEventHandler('esx:loadingScreenOff', function() - Citizen.CreateThread(function() - while true do - Citizen.Wait(1) +AddEventHandler('playerSpawned', function() + NetworkSetTalkerProximity(voice.default) +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 +Citizen.CreateThread(function() + while true do + Citizen.Wait(1) + if IsControlJustPressed(1, Keys['H']) and IsControlPressed(1, Keys['LEFTSHIFT']) 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 - - if NetworkIsPlayerTalking(PlayerId()) then - drawLevel(41, 128, 185, 255) - else - drawLevel(185, 185, 185, 255) - end end - 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') + end + + if NetworkIsPlayerTalking(PlayerId()) then + drawLevel(41, 128, 185, 255) + elseif not NetworkIsPlayerTalking(PlayerId()) then + drawLevel(185, 185, 185, 255) + end + end +end) \ No newline at end of file