• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Constant loop

sestorme

Member
Joined
Dec 9, 2011
Messages
272
Reaction score
6
Location
Birmingham, UK
I want to create an addEvent which will constantly loop itself if a condition is met:

Lua:
			function run(left)
				if (left > 0) then
				          doSendMagicEffect(getPlayerPosition(cid),5)
				          addEvent(run, 1000, left-1)
                                                    if (getCreatureMana(cid) >= 1) then
                                                    run(1)
                                                    end                              
				end
                                run(1)

And of course it don't loop.

Also tried like this:

Lua:
			function run(left)
				if (left > 0) then
				doSendMagicEffect(getPlayerPosition(cid),5)
				addEvent(run, 1000, left-1)

				if (getCreatureMana(cid) >= 1) then
				
				function run(left)
					if (left > 0) then
					doSendMagicEffect(getPlayerPosition(cid),5)
					addEvent(run, 1000, left-1)
					end
				end

				run(1)

				end
				return true
				end
			end

			run(1)

I bet it's rather easy, it's just need to be implemented in the right way.
 
Back
Top