diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..4bfca33b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +indent_size = 2 +indent_style = space +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/README.md b/README.md index e2e586d7..6e381f32 100644 --- a/README.md +++ b/README.md @@ -1 +1,32 @@ -# esx_voice \ No newline at end of file +# esx_voice +FXServer ESX Voice + + +#### Description +This is a proximity voice controller script. The default control for this is `Left Control + H` (QWERTY). + +#### Download + +**1) Using [fvm](https://github.com/qlaffont/fvm-installer)** +``` +fvm install --save --folder=esx esx-org/esx_voice +``` + +**2) Manually** +- Download https://github.com/ESX-Org/esx_voice/releases/latest +- Put it in resource/[esx] directory + +**3) Using Git** + +``` +cd resouces +git clone https://github.com/ESX-Org/esx_voice +``` + +#### Installation + +1) Add `start esx_voice` to your server.cfg + + +#### Credits +Original Script by [aabbfive](https://github.com/aabbfive/voicecontroller) diff --git a/__resource.lua b/__resource.lua new file mode 100644 index 00000000..f3fcc699 --- /dev/null +++ b/__resource.lua @@ -0,0 +1,15 @@ +--[[ + +-- ESX Voice +-- Original Author of Script: github.com/aabbfive +-- Edited by: nearbyplayer + +--]] + +resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' + +description 'ESX Voice Controller' + +version '1.0.0' + +client_script 'client/main.lua' diff --git a/client/main.lua b/client/main.lua new file mode 100644 index 00000000..dfa3c14a --- /dev/null +++ b/client/main.lua @@ -0,0 +1,64 @@ +--[[ + +-- ESX Voice +-- Original Author of Script: github.com/aabbfive +-- Edited by: nearbyplayer + +--]] + +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) + SetTextEdge(1, 0, 0, 0, 255) + SetTextDropShadow() + SetTextOutline() + SetTextEntry("STRING") + AddTextComponentString("~y~Voice:~s~ " .. voice.level) + DrawText(0.175, 0.92) +end + +AddEventHandler('onClientMapStart', function() + if voice.current == 0 then + NetworkSetTalkerProximity(voice.default) + elseif voice.current == 1 then + NetworkSetTalkerProximity(voice.shout) + elseif voice.current == 2 then + NetworkSetTalkerProximity(voice.whisper) + end +end) + +Citizen.CreateThread(function() + while true do + Citizen.Wait(0) + 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 = "Normal" + elseif voice.current == 1 then + NetworkSetTalkerProximity(voice.shout) + voice.level = "Shout" + elseif voice.current == 2 then + NetworkSetTalkerProximity(voice.whisper) + voice.level = "Whisper" + end + end + if voice.current == 0 then + voice.level = "Normal" + elseif voice.current == 1 then + voice.level = "Shout" + elseif voice.current == 2 then + voice.level = "Whisper" + end + if NetworkIsPlayerTalking(PlayerId()) then + drawLevel(41, 128, 185, 255) + elseif not NetworkIsPlayerTalking(PlayerId()) then + drawLevel(185, 185, 185, 255) + end + end +end)