• Clientside RunConsoleCommand Best way to make a person run a console command
    4 replies, posted
I am trying to make a weapon taunt using the built-in taunts, but when a person taunts, everyone on the server taunts. As of right now I am using the "RunConsoleCommand", is there a way to make it so that the only person that uses the console command (taunt) is the one using the weapon? (Please keep in mind that I am a total noob when it come to programming in Garry's Mod.)
How are you executing the taunt? Show us the code. [url]http://wiki.garrysmod.com/page/Player/ConCommand[/url] might help you.
Here is the code: [HTML]function SWEP:Think() if !self.Owner:KeyDown(IN_USE) then if self.Owner:KeyPressed(IN_RELOAD) then self.Weapon:EmitSound("npc/stalker/stalker_scream" .. math.random(1,4) .. ".wav") RunConsoleCommand("act", "zombie") if CLIENT then return end end end[/HTML] That also reminds me, how would you make it so that a person can't just spam the sound?
Put self.Owner:ConCommand("act zombie") instead of RunConsoleCommand.Best way to spam protect is to force user to wait a few seconds. So you store a variable on your SWEP, and if that variable is less than CurTime() then allow player to execute the command and set the variable to CurTime() + 5. Here's what I mean ( Forum fucked up the code ): [url]http://pastebin.com/1TPwhLGL[/url]
Thanks it works! You were very helpful! Thank you so much!
Sorry, you need to Log In to post a reply to this thread.