I know Auto-Shooting Luas exist already, but I thought it would be a great script for me to practice with. For some reason, it is not working. Any help please? Thanks in advance!
[lua]On = 1
function toggle()
if On == 1 then
On = 0
LocalPlayer():ChatPrint("Auto-Shoot Disabled")
elseif On == 0 then
On = 1
LocalPlayer():ChatPrint("Auto-Shoot Enabled")
end
end
concommand.Add("Autoshoot_Toggle", toggle)
function unattack()
RunConsoleCommand("-attack")
end
if On == 1 then
if (input.IsKeyDown( MOUSE_LEFT )) then
RunConsoleCommand("+attack")
timer.Simple(1.0, unattack)
end
end[/lua]
[editline]12:32PM[/editline]
I know the timer is set to 1. I'm just trying to get everything working before I change unimportant things.
-Dumb-
[QUOTE=|King Flawless|;22283951]also change line 21 to timer.Simple(1.0, unattack())[/QUOTE]
Why on earth would you do that? You would be passing a nil value as the timer callback.
[QUOTE=Dave_Parker;22282866]Hook it to Think or something similar.
[URL]http://wiki.garrysmod.com/?title=Hook.Add[/URL][/QUOTE]
Yeah... For some reason I can't really grasp the understanding of Think. I have absolutely no idea how to utilize it.
hooking into an event means that whatever you hooked into it gets called whenever the function you hooked into does. So if you hook a function to think, it gets called whenever think does.
OH! Thank you so much! That seems like a much better idea than a timer. Thank you.
Sorry, you need to Log In to post a reply to this thread.