• 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 Adding Delay

Santi

Theres no way im stopping
Joined
Aug 29, 2010
Messages
1,975
Reaction score
152
Location
00
So, what I want to do is add delay beetween the counts (Tp en 1.. tp en 2..), someone can make it for me?
LUA:
local table = {
    ['!demon'] = {{x=94, y=125, z=7}, 39,6},
    ['!hydra'] = {{x=88, y=127, z=7}, 39,6}
}

local count = {"TP en 3..","TP en 2..","TP en 1..","Adios!"}

 
function onSay(cid, words, param, channel)
ppos = getPlayerPosition(cid)
    local table = table[words]
    if getPlayerItemCount(cid, 2345) > 0 then
	for i = 1,#count do
	  doPlayerSendTextMessage(cid,TALKTYPE_ORANGE_1,count[i])
        doTeleportThing(cid, table[1])
        doSendMagicEffect(table[1],table[2])
	  doSendMagicEffect(table[1],table[3])
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Necesitas una tp wand para utilizar este comando.')
    end
    return true
end
 
Try it:
LUA:
local countDown = 5 -- casting time in sec
 
local table = {
    ['!demon'] = {{x=94, y=125, z=7}, 39,6},
    ['!hydra'] = {{x=88, y=127, z=7}, 39,6}
}
 
local countdownEvent = {}
 
function onSay(cid, words, param, channel)
	if(getPlayerItemCount(cid, 2345) > 0) then
		if(countdownEvent[cid] == nil or countdownEvent[cid] == 0) then
			function finalCountdown(cid, countLeft, playerPos)
				if(countLeft == 0) then				
					doCreatureSay(cid, 'Adios!', TALKTYPE_ORANGE_1)
					local table = table[words]
					doTeleportThing(cid, table[1])
					doSendMagicEffect(table[1],table[2])
					doSendMagicEffect(table[1],table[3])
					countdownEvent[cid] = 0
					return
				end
 
				local tmpPos = getCreaturePosition(cid)
				if((tmpPos.x == playerPos.x) and (tmpPos.y == playerPos.y)) then
					doCreatureSay(cid, 'TP en ' .. countLeft .. '..', TALKTYPE_ORANGE_1)	
					
					local table = table[words]
					doSendMagicEffect(tmpPos,table[2])
					doSendMagicEffect(tmpPos,table[3])
					
					local eventId = addEvent(finalCountdown, 1000, cid, countLeft - 1, playerPos)
					countdownEvent[cid] = eventId
				else
					doSendAnimatedText(getCreaturePosition(cid), 'Stop cast!', TEXTCOLOR_RED)
					doPlayerSendCancel(cid, 'You have moved. You have stoped casting.')
					countdownEvent[cid] = 0
				end
			end		
			local eventId = addEvent(finalCountdown, 0, cid, countDown, getCreaturePosition(cid))
			countdownEvent[cid] = eventId
		else
			doPlayerSendCancel(cid, 'You\'re already teleporting!!')
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Necesitas una tp wand para utilizar este comando.')
	end
    return true
end
 
Last edited:
Back
Top