• 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!

Wait function

MagicWall

Veteran OT User
Joined
Oct 12, 2008
Messages
124
Solutions
6
Reaction score
344
Hi, I have problem with create function who delay the script environment for a specified time. I was trying to use loops but client become unresponsive. I want to make this function easy to use.
Like:
Code
Wait(3000) --wait 3s
Code

I may use event but it's impractical.
 
you're better off using addEvent as it's already implemented, just create a local function to use as the callback for the code you want to execute


local function something(a)
print(a)
end

codehere
addEvent(something, 3000, "test")
 
If you want to repeat a function every 3 seconds:
Code:
cycleEvent(yourFunction, 3000)

If you want to call a function in 3 second:
Code:
scheduleEvent(yourFunction, 3000)
 
It is called Recursion,In which the Function Repeats itself until it meets the base case,So You could do as Mentioned Above

Code:
function ReapeatMyself(para)
    if isStrong(this) then
        GiveHimGift(para.cid)
        gg(para.cid)
        return true
    end
    addEvent(ReapeatMyself,3000,para)
end

This function will keep repeating itself until the player is strong :D

Hint:This code wont work, it is just for example
 
Back
Top