Alright So I’ve been trying to make my rectangle work with the esx_voice feature so I can get rid of the annoying string ect… I’ve gotten this far and I am trying to make it change the size of the rectangle depending on what the voice is set to example (Shout = full box ) (Whisper = 10% of box full) (Normal = 50% of box full) So this is what I’ve been doing can someone assist me on this I’d be happy to share when finished.
local Width, Height = GetActiveScreenResolution()
local voice = {default = 6.0, shout = 18.0, whisper = 2.0, current = 0, level = nil}
local voicebar = 0
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")
DrawText(0.164, 0.97)
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, 47) 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"
voicebar = 66 -- Bar is halfway here.
elseif voice.current == 1 then
voice.level = "Shout"
voicebar = 133 -- Fills the entire bar
elseif voice.current == 2 then
voice.level = "Whisper"
voicebar = 33 -- bar is like 10% Full
end
if NetworkIsPlayerTalking(PlayerId()) then
drawLevel(41, 128, 185, 255)
elseif not NetworkIsPlayerTalking(PlayerId()) then
drawLevel(185, 185, 185, 255)
end
end
end)
function setVoice()
voice.current = (voice.current + 1) % 3
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
end
I added comments to the parts I am trying to make work
So here is the method I am using for the rectangle.
Citizen.CreateThread(function()
while true do
DrawRectangle(164, 1064, 135, 15, 0, 0, 0, 115, 0, 0)
DrawRectangle(166, 1066, voicebar, 10, 39, 117, 254, 130, 0, 0)
Wait(0)
end
end)
So here is what it looks like all the time
Normal (Doesn’t change)
Shout (Doesn’t Change)
Whisper(Doesn’t Change)
Would be nice to have those fill or decrease in size depending on the pitch that is set
For some reason its just not changing.