I need the pros of Garrysmod to tell me what I'm doing wrong. I want to attack once, and stop. Any positive/negative criticism welcomed.
[CODE]local function rope()
RunConsoleCommand("+attack")
print("+attack")
timer.Simple( 1, LClick)
end
function LClick()
RunConsoleCommand("-attack")
print("-attack")
end
concommand.Add("roper",rope)[/CODE]
-snip-
[QUOTE=gary23548;42572682]I need the pros of Garrysmod to tell me what I'm doing wrong. I want to attack once, and stop. Any positive/negative criticism welcomed.
[CODE]local function rope()
RunConsoleCommand("+attack")
print("+attack")
timer.Simple( 1, LClick)
end
function LClick()
RunConsoleCommand("-attack")
print("-attack")
end
concommand.Add("roper",rope)[/CODE][/QUOTE]
This'll attack multiple times if you're using an automatic weapon (as +attack is toggled for a whole second)
[QUOTE=Willox;42572753]This'll attack multiple times if you're using an automatic weapon (as +attack is toggled for a whole second)[/QUOTE]
I don't see why you'd disagree when I fixed the issue in the code he posted.
[QUOTE=brandonj4;42572786]I don't see why you'd disagree when I fixed the issue in the code he posted.[/QUOTE]
The arguments to timer.Simple are delay, function. He's used it correctly.
[lua]
concommand.Add( "roper", function( )
RunConsoleCommand( "+attack" )
timer.Simple( 0.001, function( ) RunConsoleCommand( "-attack" ) end )
end )
[/lua]
It doesn't honestly make a difference how you code it. Every coder has their own style. My style does not involve making useless functions.
[QUOTE=EthanTheGreat;42572873][lua]
concommand.Add( "roper", function( )
RunConsoleCommand( "+attack" )
timer.Simple( 0.001, function( ) RunConsoleCommand( "-attack" ) end )
end )
[/lua]
It doesn't honestly make a difference how you code it. Every coder has their own style. My style does not involve making useless functions.[/QUOTE]
You could just use 0 for next tick (frame?) in a timer.
You could, just wanted to show that you can adjust the delay past 1.
Sorry, you need to Log In to post a reply to this thread.