• Need help with a voice chat command
    13 replies, posted
I'm trying to make it so when a player actively voice chats, the player performs the action ACT_GMOD_IN_CHAT and then after the voice chat stops, the player stops performing the act. Any ideas?
On the clientside. [CODE] function WhoIsTalking(ply) if ply:IsPlayer() then ply:AnimRestartGesture(GESTURE_SLOT_CUSTOM,ACT_GMOD_IN_CHAT,false) end end net.Receive("PlayerIsSpeaking",function() WhoIsTalking(net.ReadEntity()) end) function WhoIsStoppingTalking(ply) if ply:IsPlayer() then ply:AnimRestartGesture(GESTURE_SLOT_CUSTOM,ACT_GMOD_IN_CHAT,true) end end net.Receive("PlayerIsNotSpeaking",function() WhoIsStoppingTalking(net.ReadEntity()) end) function DidISpeak(ply) if ply == LocalPlayer() then net.Start("WhoIsSpeaking") net.SendToServer() end end hook.Add("PlayerStartVoice","DidISpeak",function(ply) DidISpeak(ply) end) function DidIStopTalking(ply) if ply == LocalPlayer() then net.Start("WhoIsStoppingTalking") net.SendToServer() end end hook.Add("PlayerEndVoice","DidIStopTalking",function(ply) DidIStopTalking(ply) end) [/CODE] On the serverside. [CODE] util.AddNetworkString("PlayerIsSpeaking") util.AddNetworkString("PlayerIsNotSpeaking") util.AddNetworkString("WhoIsSpeaking") util.AddNetworkString("WhoIsStoppingTalking") function WhoIsSpeaking(ply) if ply:IsPlayer() then ply:AnimRestartGesture(GESTURE_SLOT_CUSTOM,ACT_GMOD_IN_CHAT,false) net.Start("PlayerIsSpeaking") net.WriteEntity(ply) net.Broadcast() end end net.Receive("WhoIsSpeaking",function(len,ply) WhoIsSpeaking(ply) end) function WhoIsStoppingTalking(ply) if ply:IsPlayer() then ply:AnimRestartGesture(GESTURE_SLOT_CUSTOM,ACT_GMOD_IN_CHAT,true) net.Start("PlayerIsNotSpeaking") net.WriteEntity(ply) net.Broadcast() end end net.Receive("WhoIsStoppingTalking",function(len,ply) WhoIsStoppingTalking(ply) end) [/CODE] Should works.
This code should be place in lua/autorun/server correct?
[QUOTE=koolkiddo;49121448]This code should be place in lua/autorun/server correct?[/QUOTE] The serverside should be in /server, clientside in /client. The better choice (In my opinion) would be to put the code in lua/autorun and use if SERVER and if CLIENT
[QUOTE=JasonMan34;49121656]The serverside should be in /server, clientside in /client. The better choice (In my opinion) would be to put the code in lua/autorun and use if SERVER and if CLIENT[/QUOTE] For small scripts this is fine, but its still bad practice. Your sending useless amounts of code that the client won't ever run, and handing over the entierety of your source code to someone who might steal or otherwise maliciously use it.
Hi guys, sorry for late reply. The server side script doesn't work and neither does the client side one
How are you setting them up? Does ir give errors? Can you try to give morw fucking details than: hey guyz, it doezent work :ohno:
As in it doesn't work. No errors or anything. [editline]18th November 2015[/editline] I've art it up correctly, added if SERVER then and everything
I mean the fucking file structure.
As I've said its in lua\autorun\server
[QUOTE=koolkiddo;49140450]As I've said its in lua\autorun\server[/QUOTE] post the fking file :mindblown:
[QUOTE=koolkiddo;49140450]As I've said its in lua\autorun\server[/QUOTE] How is a fucking clientside script work for the client if you are putting it on the server autorun????
The server sided is in lua/autorun/server and the client is in lua/autorun/client, there's no need to be an asshole, if you don't want to help you don't have to
Im not being an asshole. Its just you not giving enough info. If you want help, post the code. Also, do you have the code in garrysmod/lua/autorun/?
Sorry, you need to Log In to post a reply to this thread.