SolvedHow to loop for GLua?

Posts 16–29 of 29 · Page 2 of 2
Quote Originally Posted by Ariaa View Post
In multi-threaded applications the sleep function will just suspend to thread to the given interval, so if there was a sleep function in Lua, it wouldn't do anything but freeze up.
if you read it it's running it to type in chat "/sleep"
Quote Originally Posted by Keepo123 View Post
if you read it it's running it to type in chat "/sleep"
I wasn't talking to you.
Quote Originally Posted by Ariaa View Post
I wasn't talking to you.
Ahh, alright. Mb
Quote Originally Posted by Keepo123 View Post
Hello, I am fairly new to lua only started for about a week now.
I've been trying to make a exploit but I need to make it loop so It can be AFKABLE

Code:
function kappa()
timer.Simple( 0.4744, function() RunConsoleCommand("say","/drop" .. " ")  end )
timer.Simple( 1.4135, function() RunConsoleCommand("say","/sleep" .. " ")  end )
end
RunConsoleCommand("use", "WEAPON_IDl")
concommand.Add ("dupe", kappa )
I want make this have a constant loop and also have it change weapons if you understand.

Thanks, Keepo
Code:
for i = 1,1337 do 
RunConsoleCommand("say","/drop" .. " ")
RunConsoleCommand("say","/sleep" .. " ")
end
Quote Originally Posted by suchisgood View Post
Code:
for i = 1,1337 do 
RunConsoleCommand("say","/drop" .. " ")
RunConsoleCommand("say","/sleep" .. " ")
end
Now, is there away to stop it from keeping doing it?
Quote Originally Posted by Keepo123 View Post
Now, is there away to stop it from keeping doing it?
use
Code:
break
to stop the loop
Quote Originally Posted by cdr1zzle View Post
use
Code:
break
to stop the loop
Is there away I can trigger break? like put it into a function?

for i = 1,1337 do
RunConsoleCommand("say","/drop" .. " ")
RunConsoleCommand("say","/sleep" .. " ")
end

function stop()
break
end
concommand.Add ("brk", stop)

sorry I'm very new to lua
Quote Originally Posted by Keepo123 View Post
Is there away I can trigger break? like put it into a function?

for i = 1,1337 do
RunConsoleCommand("say","/drop" .. " ")
RunConsoleCommand("say","/sleep" .. " ")
end

function stop()
break
end
concommand.Add ("brk", stop)

sorry I'm very new to lua
Code:
function stop(p,c,a)
	for i = 1,tonumber(a[1]) do 
		RunConsoleCommand("say","/drop" .. " ")
		RunConsoleCommand("say","/sleep" .. " ")
	end
end
concommand.Add ("brk", stop)
brk 100
brk 10

It'll break after 100, The next one is to break at 10
Quote Originally Posted by suchisgood View Post
Code:
function stop(p,c,a)
	for i = 1,tonumber(a[1]) do 
		RunConsoleCommand("say","/drop" .. " ")
		RunConsoleCommand("say","/sleep" .. " ")
	end
end
concommand.Add ("brk", stop)
brk 100
brk 10

It'll break after 100, The next one is to break at 10
Thank you for the reply, and help. But lets say I don't want it do do 100 loops in a second is there away I can delay each loop?

- - - Updated - - -

Quote Originally Posted by suchisgood View Post
Code:
function stop(p,c,a)
	for i = 1,tonumber(a[1]) do 
		RunConsoleCommand("say","/drop" .. " ")
		RunConsoleCommand("say","/sleep" .. " ")
	end
end
concommand.Add ("brk", stop)
brk 100
brk 10

It'll break after 100, The next one is to break at 10
Also what would I look up to understand these lines?

function stop(p,c,a)
for i = 1,tonumber(a[1])
Quote Originally Posted by Keepo123 View Post
Thank you for the reply, and help. But lets say I don't want it do do 100 loops in a second is there away I can delay each loop?

- - - Updated - - -



Also what would I look up to understand these lines?

function stop(p,c,a)
for i = 1,tonumber(a[1])
Use a timer like this:
Code:
function stop(p,c,a)
	local Time = 0
	for i = 1,tonumber(a[1]) do 
		Time = Time + tonumber(a[2])
		timer.Simple(tonumber(a[3]) + Time, function() 
			RunConsoleCommand("say","/drop" .. " ")
			RunConsoleCommand("say","/sleep" .. " ")
		 end)
	end
end
concommand.Add ("brk", stop)

10 = loop
2 = the pause between each timer
10 is the delay in seconds + Time
brk 10 2 10
So it'll be

10
12
14
16
18

brk 10 5 10

10
15
20
25
30
Quote Originally Posted by suchisgood View Post
Use a timer like this:
Code:
function stop(p,c,a)
	local Time = 0
	for i = 1,tonumber(a[1]) do 
		Time = Time + tonumber(a[2])
		timer.Simple(tonumber(a[3]) + Time, function() 
			RunConsoleCommand("say","/drop" .. " ")
			RunConsoleCommand("say","/sleep" .. " ")
		 end)
	end
end
concommand.Add ("brk", stop)

10 = loop
2 = the pause between each timer
10 is the delay in seconds + Time
brk 10 2 10
So it'll be

10
12
14
16
18

brk 10 5 10

10
15
20
25
30
using a for loop and timer.simple instead of using timer.create = ez
Quote Originally Posted by suchisgood View Post
Use a timer like this:
Code:
function stop(p,c,a)
	local Time = 0
	for i = 1,tonumber(a[1]) do 
		Time = Time + tonumber(a[2])
		timer.Simple(tonumber(a[3]) + Time, function() 
			RunConsoleCommand("say","/drop" .. " ")
			RunConsoleCommand("say","/sleep" .. " ")
		 end)
	end
end
concommand.Add ("brk", stop)

10 = loop
2 = the pause between each timer
10 is the delay in seconds + Time
brk 10 2 10
So it'll be

10
12
14
16
18

brk 10 5 10

10
15
20
25
30
Thank you very much!
Quote Originally Posted by Keepo123 View Post
Thank you very much!
your welcome ^^
FYI if you're looking at this still, You could use timer.Create
But the way suchisgood is also very good to know when not working with stuff GLUA related.
Posts 16–29 of 29 · Page 2 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us