Find if a player is talking.

Hi.

DarkRP allows me to use


LocalPlayer().DRPIsTalking

But what is its equivalent in Non-DarpRP gamemode?

Client side, you can use this: http://wiki.garrysmod.com/page/Player/IsSpeaking
I’m unsure if there’s a server side method.

Assign a variable on the player in those functions if you want a similar feature.

-snip- derp

You are just creating two hooks that’s overwriting themselves? And the PlayerStartVoice hook is client side. Let me write you a script. brb

[editline]31st October 2014[/editline]

Also, you do not need the “or false”, because if the var is a nil, it returns false anyways.

Don’t return ply.IsVoiceChatting( ) or false… The value is a variable, not a function. Additionally, they’re client-side hooks ( says so at the bottom of the wiki page ) so you’d need to network the data to the server when they start and stop and set the var on the client and the net.Receive on the server in order for it to be shared.

As you could probably guess, untested, but should work just fine.
[lua]
– CLIENT SIDE LUA

hook.Add(“PlayerStartVoice”, “IsVoiceChattingCheck”, function(ply)
net.Start(“IsVoiceChattingCheck”)
net.WriteBit(true)
net.SendToServer()
end)

hook.Add(“PlayerEndVoice”, “IsVoiceChattingCheck”, function(ply)
net.Start(“IsVoiceChattingCheck”)
net.WriteBit(false)
net.SendToServer()
end)

– SERVER SIDE LUA

util.AddNetworkString(“IsVoiceChattingCheck”)

net.Receive(“IsVoiceChattingCheck”, function(len, client)
if net.WriteBit and IsValid(client) and client:IsPlayer() then
client.IsVoiceChattingCheck = net.WriteBit
end
end)

function FindMetaTable(“Player”):IsVoiceChatting()
if IsValid(self) and self:IsPlayer then
return self.IsVoiceChattingCheck
end
end[/lua]

No need to write anything just send an empty message and toggle it.
[lua]
client.IsVoiceChattingCheck = not client.IsVoiceChattingCheck
[/lua]