• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Teleport Tile

Skillionaire

New Member
Joined
Aug 10, 2013
Messages
20
Reaction score
0
Hello, i need a movement script that teleports a player to a destination after 5 MINUTES being in that TILE!

A tile with UNIQUEID and that...

Thanks!
 
The green code is meant to be edited by you, here we go:

movements.xml
Code:
<movevent event="StepIn" uniqueid="[COLOR="#008000"]21101[/COLOR]" script="[COLOR="#008000"]delayed_teleport_tile[/COLOR].lua"/>
<movevent event="StepOut" uniqueid="[COLOR="#008000"]21101[/COLOR]" script="[COLOR="#008000"]delayed_teleport_tile[/COLOR].lua"/>

delayed_teleport_tile.lua
Code:
[COLOR="#008000"]local config = {
	storage = 21100,
	delay = 1000,
	teleportPos = {x = 984, y = 431, z = 8},
	teleportMsg = "You have been standing still staring too long."
}[/COLOR]

local function scheduleTeleport(cid)
	if isPlayer(cid) then
		setPlayerStorageValue(cid, config.storage, -1)
		
		doCreatureSay(cid, config.teleportMsg, TALKTYPE_ORANGE_1)
		
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		doTeleportThing(cid, config.teleportPos, FALSE)
		doSendMagicEffect(config.teleportPos, CONST_ME_TELEPORT)
	end
end

function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) then
		setPlayerStorageValue(cid, config.storage, addEvent(scheduleTeleport, config.delay, cid))
	end
	return TRUE
end

function onStepOut(cid, item, position, fromPosition)
	if isPlayer(cid) then
		local eventId = getPlayerStorageValue(cid, config.storage)
		if eventId ~= -1 then
			stopEvent(eventId)
			setPlayerStorageValue(cid, config.value, -1)
		end
	end
	return TRUE
end
 
Last edited:
Trolle,

Make sure also to check inside the:
local function scheduleTeleport(cid)
LUA:
if isPlayer(cid) then

Since, if a player logout during the addevent and it try to execute it, it will cause error.
and same goes for stepin, check if its player step into tile else if monster step in, error.
 
So i put like this?

LUA:
local config = {
	storage = 21100,
	delay = 5 * 60 * 1000,
	teleportPos = {x = 984, y = 431, z = 8},
	teleportMsg = "You have been standing still staring too long."
}

local function scheduleTeleport(cid)
	if isPlayer(cid) then
		setPlayerStorageValue(cid, config.storage, -1)
		
		doCreatureSay(cid, config.teleportMsg, TALKTYPE_ORANGE_1)
		
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		doTeleportThing(cid, config.teleportPos, FALSE)
		doSendMagicEffect(config.teleportPos, CONST_ME_TELEPORT)
	end
end

function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) then
		setPlayerStorageValue(cid, config.storage, addEvent(scheduleTeleport, config.delay, cid))
	end
	return TRUE
end

function onStepOut(cid, item, position, fromPosition)
	if isPlayer(cid) then
		local eventId = getPlayerStorageValue(cid, config.storage)
		if eventId ~= -1 then
			stopEvent(eventId)
			setPlayerStorageValue(cid, config.value, -1)
		end
	end
	return TRUE
end
 
Back
Top