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

Possible to add a delay in a loop?

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,393
Solutions
7
Reaction score
552
Hey there,

So I'm just experimenting with loops and i was wondering if someone could help me with this? Idea is to continually say 'AFK' if storage value is = to 1 BUT i want a 3 second delay before it goes through the loop again so it doesnt spam. (Like animated text)


Code:
--CONFIG--
local afkactive = 808012 -- Assign a unsued storage
--END CONFIG--


function onSay(cid, words, param)
local player = Player(cid)
    while(player:getStorageValue(afkactive) == 1)
        do
        if player:getStorageValue(748596123) < os.time() then
            player:setStorageValue(748596123, os.time() + 3)
            player:say('AFK', TALKTYPE_MONSTER_SAY)
        end
    end
end
 
I got stuck a lot of time because I didn't realized I couldn't send player object as a parameter in addEvent, why that happens?
I have no idea, but sending objects in addEvent is a really bad design, if the object isn't there anymore the server would crash, that's why we send the Id and then we check if the creature still exists.
 
Back
Top