I am working on some stuff for the Stranded gamemode, but in that gamemode the (command) in console causes the player to be able to leave his computer/tab out of the game and still farm ore/wood.
What I would like to know is if there is any way to detect when he pushes the left mouse button to detect whether or not he keeps pushing it, or when he inputs (a command) into console to automatically do (the opposite of the command). I am not sure how the (command) works but I know I can't just remove it or override it because it is needed to play the game.
I am blocking out the command name to avoid people abusing it...hopefully it's not too vague.
To give a bit more input, the command imitates/is used for left clicking things ingame..but repeats itself after typing it in.
Any way to detect what they put into console, or set a timer or something to check if they have hit they have hit the left click within a certain frame of time? Or even checking for movement while hitting left click.
[CODE]
if !system.HasFocus() then return end
[/CODE]
[url]http://wiki.garrysmod.com/page/system/HasFocus[/url]
put that at the start of your console command.
edit: Apologies, I didn't see it auto restarted. post the code for the console command and I'll help ya out.
player:KeyPressed(IN_ATTACK)
Will be true if they just started pressing the same frame this was called on.
Alternatively if you're using a SWEP it's as simple as setting SWEP.Primary.Automatic to false
Ah, JetBoom that works for all of the tools the gamemode uses, now how would I go about limiting the E/Use button? Another command in the console (Base Gmod Command) can have people farm with that as well.
Would it be IN_USE?
IN_USE
Or set the entity's use type to SIMPLE_USE and it will not continuously register uses while someone holds it down.
self:SetUseType(SIMPLE_USE)
Sorry, you need to Log In to post a reply to this thread.