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

Teleport Player With Countdown

Knight God

Member
Joined
Oct 19, 2008
Messages
1,180
Reaction score
21
Hi Otland, I wonder if you can help me with this problem.
The thing is I need a script (Creaturescript to be exact), that when a character reaches level for example:

level 30, this will be teleported to a position but before being transported count him out, for example.

"MESSAGE_EVENT_ADVANCE"
You've come to level 30 and be transported to your mission.

MESSAGE_STATUS_CONSOLE_ORANGE
You'll be transported in 30 seconds.
You'll be transported in 29 seconds.
You'll be transported in 28 seconds.
You'll be transported in 27 seconds.
You'll be transported in 26 seconds.
You'll be transported in 25 seconds.

and so on down to 0 and when it reaches 0 you are transported. if you could help me with this request, would give him thanks and of course I would be grateful to reputation.
thanks in advance
 
Past it into your functions.lua (LIB folder).
Lua:
czekaj = coroutine.yield
function czekanie(c)
    if(coroutine.status(c) ~= 'dead') then
        local _, czas = coroutine.resume(c)
        addEvent(czekanie, czas, c)
    end
end
function zacznijCzekac(f)
    if(type(f) == 'function') then
        local c = coroutine.create(f)
        czekanie(c)
    end
end

Script.lua
Lua:
--configuration--
local config = {
        skillID = 8,
        levelToTeleport = 30,
        storage = 9999,
        position = {x=9999, y=9999, z=7}
}
--end config--
function onAdvance(cid, skill, oldlevel, newlevel)
if(skill == config.skillID and newLevel >= config.levelToTeleport and getPlayerStorageValue(cid, config.storage) < 1) then
	doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You've come to level ".. config.levelToTeleport .." and be transported to your mission.")
	for i = 1, 30 do
		if i > 1 then
			doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You'll be transported in ".. i .." seconds.")
		elseif i == 1 then
			doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You'll be transported in ".. i .." second.")
		end
		czekaj(1000)
	end
	doTeleportThing(cid, config.position)
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
return true
end
end

Not tested, but it should be works(?).
 
Should work, not sure if level is skill 8;

Lua:
local pos = {x = 1000, y = 1000, z = 7}

local function countTele(cid, delay)
    if delay == 0 then
        return doTeleportThing(cid, pos)
    else
        doPlayerSendTextMessage("You will be teleported in " .. delay .. " second" .. delay == 1 and '.' or "s.", MESSAGE_STATUS_BLUE_CONSOLE)
        return addEvent(countTele, 1000, cid, delay-1)
    end
end

function onAdvance(cid, skill, oldlevel, newlevel)
    if  skill == 8 and oldlevel < 30 and newlevel >= 30 then
        countTele(cid, 30)
    end
    return true
end
 
Last edited by a moderator:
Past it into your functions.lua (LIB folder).
Lua:
czekaj = coroutine.yield
function czekanie(c)
    if(coroutine.status(c) ~= 'dead') then
        local _, czas = coroutine.resume(c)
        addEvent(czekanie, czas, c)
    end
end
function zacznijCzekac(f)
    if(type(f) == 'function') then
        local c = coroutine.create(f)
        czekanie(c)
    end
end

Script.lua
Lua:
--configuration--
local config = {
        skillID = 8,
        levelToTeleport = 30,
        storage = 9999,
        position = {x=9999, y=9999, z=7}
}
--end config--
function onAdvance(cid, skill, oldlevel, newlevel)
if(skill == config.skillID and newLevel >= config.levelToTeleport and getPlayerStorageValue(cid, config.storage) < 1) then
	doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You've come to level ".. config.levelToTeleport .." and be transported to your mission.")
	for i = 1, 30 do
		if i > 1 then
			doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You'll be transported in ".. i .." seconds.")
		elseif i == 1 then
			doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You'll be transported in ".. i .." second.")
		end
		czekaj(1000)
	end
	doTeleportThing(cid, config.position)
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
return true
end
end

Not tested, but it should be works(?).

look
error_1.jpg

Should work, not sure if level is skill 8;

Lua:
local pos = {x = 1000, y = 1000, z = 7}

local function countTele(cid, delay)
    if delay == 0 then
        return doTeleportThing(cid, pos)
    else
        doPlayerSendTextMessage("You will be teleported in " .. delay .. " second" .. delay == 1 and '.' or "s.", MESSAGE_STATUS_BLUE_CONSOLE)
        return addEvent(countTele, 1000, cid, delay-1)
    end
end

function onAdvance(cid, skill, oldlevel, newlevel)
    if  skill == 8 and oldlevel < 30 and newlevel >= 30 then
        countTele(cid, 30)
    end
    return true
end

look
error_2.jpg

dont work :/
 
Last edited by a moderator:
he got the params wrong?
Code:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_BLUE_CONSOLE, "You will be teleported in " .. delay .. " second" .. (delay == 1 and '.' or "s."))
 
Lua:
local c = {
	pos = {x = 866, y = 93, z = 8}, -- /goto 866, 93, 8
	time = 5,
	level = 30
}
 
local function countTele(pid, delay)
	if delay == c.time then
		doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You've come to level ".. c.level .." and be transported to your mission.")
	end
	if delay > 0 then
		doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_ORANGE, "You will be teleported in ".. delay .." second".. (delay > 1 and "s." or ".")) 
		addEvent(countTele, 1000, pid, delay - 1)
	else
		doTeleportThing(pid, c.pos)
		doSendMagicEffect(c.pos, CONST_ME_TELEPORT)
	end
	return true
end

function onAdvance(cid, skill, oldlevel, newlevel)
	if newlevel == 30 then
		countTele(cid, c.time)
	end
	return true
end
 
Your script works exelent 100% :DDD!!! nice and thanks very thanks!

"You must spread some Reputation around before giving it to andypsylon again."
i can't add reputation for you :/
 
I have a minimum problem: /, what happens is that when one goes up to skill 30 transportation also runs the script and do not want that to happen, you can help me?
 
Back
Top