• Help with Player:VoiceVolume()
    4 replies, posted
I'm trying to continuously change a variable, "vol", depending on how loud the LocalPlayer() is when they start speaking (using hook GM:PlayerStartVoice). But when I test it in the game, it seems to remain a constant at a value of: 0.0098650315776467. Is the VOIP normalized or something? If so, is there any other way to find variation in the volume/amplitude of a user's voice? Full text of "cl_init.lua" include("shared.lua") surface.CreateFont( "VOL_FONT", { font = "Arial", extended = false, size = 20, weight = 500, } ) vol = 0; function GM:PlayerStartVoice(ply) vol = ply:VoiceVolume() end hook.Add("HUDPaint", "DrawVol", function() draw.SimpleText(vol,"VOL_FONT",100,100,Color(255, 0, 0)) end)
Your not really changing any variable in this code? You should show us the whole thing, including the part where you change the variable Because this just prints the players voice volume..thats it..there isnt much we can do with that
the original post was the full script. im changing it here in the hook: vol = 0; function GM:PlayerStartVoice(ply) vol = ply:VoiceVolume() end
Try printing the VoiceVolume in a hook that runs every tick or something, I feel like it "initializes" as that near-zero value whenever the player starts speaking.
I already fixed it, I probably should've mentioned that in this thread. Just made a simple timer to continuously update it. Thank you anyway. ply = LocalPlayer() vol = 0; function setVol() local ply = LocalPlayer() vol = ply:VoiceVolume() end; function GM:PlayerStartVoice(ply) timer.Create("assignment_timer_vol", 0.05, 0, setVol) end
Sorry, you need to Log In to post a reply to this thread.