Facepunch / garrysmod-issues

Garry's Mod issue tracker
142 stars 56 forks source link

Client-side `Player:IsSpeaking()` bug #5851

Open unknown-gd opened 5 months ago

unknown-gd commented 5 months ago

Details

I recently found an really weird bug with glua, Player:IsSpeaking() starts lying at random times and returns wrong true/false values, works only if you have other players on the server and they are actively using voice chat, according to my tests it happened mostly with local player on the client side, in sandbox and other gamemodes it is not noticeable because they use the GM:PlayerStartVoice & GM:PlayerEndVoice hooks instead of this function.

Branch: main

Steps to reproduce

  1. Find a few players for the tests
  2. Create a hook in HudPaint that will draw a green rect when you speak, using LocalPlayer():IsSpeaking()
  3. Play and talk with other players
  4. At one point in time, the indicator turns green at all times, giving false information.
ryanoutcome20 commented 4 months ago

Details

I recently found an really weird bug with glua, Player:IsSpeaking() starts lying at random times and returns wrong true/false values, works only if you have other players on the server and they are actively using voice chat, according to my tests it happened mostly with local player on the client side, in sandbox and other gamemodes it is not noticeable because they use the GM:PlayerStartVoice & GM:PlayerEndVoice hooks instead of this function.

Branch: main

Steps to reproduce

  1. Find a few players for the tests
  2. Create a hook in HudPaint that will draw a green rect when you speak, using LocalPlayer():IsSpeaking()
  3. Play and talk with other players
  4. At one point in time, the indicator turns green at all times, giving false information.

I played for roughly 40~ some odd minutes on a DarkRP server with a Lua executor running this code:

-- Cache our LocalPlayer and color variable
local Local, Green = LocalPlayer( ), Color( 0, 255, 0 )

hook.Add( "HUDPaint", "DrawRectBox", function()
    if Local:IsSpeaking( ) then 
        surface.SetDrawColor( Green )
        surface.DrawRect( ScrW( ) / 1.5, 50, 250, 150 )
    end
end )

And I couldn't reproduce the bug even after adding fake lag and other lag elements to my game on purpose. Tested between 40-480ms and 20-400 FPS.