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

zednem

New Member
Joined
Nov 15, 2008
Messages
108
Reaction score
0
I am trying to do a script which when the player walk in certain tile he is teleported, but is not working =/
What could be?

PHP:
function onStepIn(cid, item, pos)

teleport = {x=1211, y=1233, z=7}
teleport1 = {x =1212, y =1215, z=7}
if isPlayer(cid) == 1 and item.actionid == 5820 then
doSendMagicEffect(teleport,10)
doTeleportThing(cid,teleport)
elseif isPlayer(cid) == 1 and item.actionid == 5821 then
doSendMagicEffect(teleport,10)
doTeleportThing(cid,teleport1)
end
end
 
Lua:
function onStepIn(cid, item, pos)

teleport = {x=1211, y=1233, z=7}
teleport1 = {x =1212, y =1215, z=7}
if isPlayer(cid) == TRUE and item.actionid == 5820 then
doSendMagicEffect(teleport,10)
doTeleportThing(cid,teleport)
elseif isPlayer(cid) == TRUE and item.actionid == 5821 then
doSendMagicEffect(teleport,10)
doTeleportThing(cid,teleport1)
end
return TRUE
end

Here you go :thumbup:.
 
Code:
function onStepIn(cid, item, pos)
	local teleports = {
		[5820] = {x = 1211, y = 1233, z = 7},
		[5821] = {x = 1211, y = 1233, z = 7}
	}

	local destination = teleports[item.actionid]
	if (destination == nil or isPlayer(cid) == false) then
		return
	end 

	doSendMagicEffect(destination, CONST_ME_TELEPORT)
	doTeleportThing(cid, destination)

	return true
end
 
Magic effect comes after teleport :).

Lua:
function onStepIn(cid, item, pos)
	local teleports = {
		[5820] = {x = 1211, y = 1233, z = 7},
		[5821] = {x = 1211, y = 1233, z = 7}
	}

	local destination = teleports[item.actionid]
	if (destination == nil or isPlayer(cid) == false) then
		return
	end 

	doTeleportThing(cid, destination)
	doSendMagicEffect(destination, CONST_ME_TELEPORT)

	return true
end
 
Doesn't woked neither =/
The ground has the actionid that i know, but still doesn't works =/

11:03 You see dirt.
ItemID: [351], ActionID: [5820].
Position: [X: 1205] [Y: 1233] [Z: 7].

Maybe problem in movements.xml?

<movevent event="StepIn" actionid="5820" script="teleport.lua"/>
<movevent event="StepIn" actionid="5821" script="teleport.lua"/>
 
Not Tested - Should Work - 0.3

Lua:
local positions =
{
    [5820] = { place = {x=1211, y=1233, z=7} },
    [5821] = { place = {x=1211, y=1233, z=7} }
}

function onStepIn(cid, fromPos, toPos)
local playerPos = getCreaturePosition(cid)
local destinations = positions[item.actionid].place
    if isPlayer(cid) == TRUE then
	doSendMagicEffect(playerPos, CONST_ME_TELEPORT)
	doTeleportThing(cid, destinations)
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been teleported.")
    end
    return TRUE
end

PHP:
<movevent event="StepIn" actionid="5820" script="teleport.lua"/>
<movevent event="StepIn" actionid="5821" script="teleport.lua"/>
 
Last edited:
Yeah appears to be correctly coded for me too, but doesn't works =/
i will give up think in another thing
but thanks for the help =D
 
Hmm you should post your TFS version maybe thats whats confusing everyone.

Anyways you can always find an alternative way of doing it, for example putting a teleporter on the tile you want, and a (non-moveable) crate or pile of crates on top of it so the player cant see the teleporter but still walk in :thumbup:

And if you want it to send a message to the player when teleporting then you could do something like this:

· In your map editor set the tile's unique id to 40000 (or any unused value and change the 40000 on the scripts below to it)

· In movements.xml:

PHP:
<movevent type="StepIn" uniqueid="40000" event="script" value="tp.lua"/>

· In tp.lua:

Lua:
function onStepIn(cid, item, frompos, item2, topos)
	if item.uid == 40000 then
		doPlayerSendTextMessage(cid, 25, "You've been teleported!")
	return TRUE
	end
end

And well, its n0b but it could be an alternative solution :D

Cheers.
 
@Up,
You forgot to teleport the player :eek:

Lua:
function onStepIn(cid, item, frompos, item2, topos)
    if (item.uid == 5820) or (item.uid == 5821) then
        doPlayerSendTextMessage(cid, 25, "You've been teleported!")
        doTeleportThing(cid, pos)
    end
    return TRUE
end
 
Last edited:
@Up,
You forgot to teleport the player :eek:

Lua:
function onStepIn(cid, item, frompos, item2, topos)
    if (item.uid == 5820) or (item.uid == 5821) then
        doPlayerSendTextMessage(cid, 25, "You've been teleported!")
        doTeleportThing(cid, pos)
    end
    return TRUE
end

Well considering there would be a teleporter hidden there with the coordinates and everything I didnt think was necessary xD The I wrote there is for the tile with the unique id 40000 or so, its only for the message :D
 
Lua:
local positions =
{
    [5820] = { place = {x=1211, y=1233, z=7} },
    [5821] = { place = {x=1211, y=1233, z=7} }
}

function onStepIn(cid, fromPos, toPos)
local playerPos = getCreaturePosition(cid)
local destinations = positions[item.actionid].place
    if isPlayer(cid) == TRUE then
	doSendMagicEffect(playerPos, CONST_ME_TELEPORT)
	doTeleportThing(cid, destinations)
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been teleported.")
    end
    return TRUE
end

PHP:
<movevent event="StepIn" actionid="5820" script="teleport.lua"/>
<movevent event="StepIn" actionid="5821" script="teleport.lua"/>

Why are there 2 - X,Y,Z? is the first 1 for the square the tile is on? can u explain this please, thanks!
 
Fle, that will not work, don't use that one.

Use:
Lua:
local positions =
{
    place = {x=100, y=100, z=7} -- New position.
}
function onStepIn(cid, item, fromPos, item2, toPos)
    if (item.uid == 5820) then -- Unique ID of the Tile.
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've been teleported!")
        doTeleportThing(cid, positions.place)
    end
    return TRUE
end
 
Back
Top