• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

MoveEvent Customize your own teleports

Dridia

New Member
Joined
Jan 17, 2012
Messages
49
Reaction score
1
Location
Sweden
Hello, I'm going to release my customized teleport script. It's simple and maybe there is someone that want to use this useless script ^_^
I'm sure there's another way to do this script, with less codelines. I'm new to LUA, don't blame me.

First off we have to create an walkable tile with the Action ID: 9500 (the Action ID can be any value, remember to change the action ID, both in the mapeditor and in movements.xml)
I've added 2 images on how to change the Action IDs of a tile
tutorial1.jpgtutorial2.png


after that we are going to add a line in:
data/movements/movements.xml
XML:
<movevent type="StepIn" actionid="9500" event="script" value="teleports.lua"/>


After that, we're going to create a new .lua dokument. Name it "teleports.lua", without the quotes.
data/movements/scripts/teleports.lua
Lua:
function onStepIn(cid, item, frompos, itemEx, topos)
local fromPos = getPlayerPosition(cid)
local toMonster = {x=1310, y=1024, z=8}
local toQuest = {x=1308, y=1059, z=8}
local toShop = {x=1031, y=1002, z=7}
local toHouse = {x=1564, y=1489, z=7}
local toOB = {x=1214, y=1073, z=7}
	
	if fromPos.x == 997 and fromPos.y == 994 and fromPos.z == 7 then
		local fromMonster = {x=998, y=994, z=7}
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING,"Welcome to the monster teleports!")
		doTeleportThing(cid, toMonster)
		doSendMagicEffect(toMonster, 37)
		doSendMagicEffect(fromMonster, 67)
		
	elseif fromPos.x == 995 and fromPos.y == 994 and fromPos.z == 7 then
		local fromQuest = {x=996, y=994, z=7}
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING,"Welcome to the quest room!")
		doTeleportThing(cid, toQuest)
		doSendMagicEffect(toQuest, 37)
		doSendMagicEffect(fromQuest, 67)
		
	elseif fromPos.x == 991 and fromPos.y == 994 and fromPos.z == 7 then
		local fromShop = {x=992, y=994, z=7}
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING,"Welcome to the shops!")
		doTeleportThing(cid, toShop)
		doSendMagicEffect(toShop, 37)
		doSendMagicEffect(fromShop, 67)
	
	elseif fromPos.x == 990 and fromPos.y == 995 and fromPos.z == 7 then
		local fromHouse = {x=991, y=995, z=7}
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING,"Welcome to the house island!")
		doTeleportThing(cid, toHouse)
		doSendMagicEffect(toHouse, 37)
		doSendMagicEffect(fromHouse, 67)
	
	elseif fromPos.x == 990 and fromPos.y == 996 and fromPos.z == 7 then
		local fromOB = {x=991, y=996, z=7}
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING,"Welcome to the open battle!")
		doTeleportThing(cid, toOB)
		doSendMagicEffect(toOB, 37)
		doSendMagicEffect(fromOB, 67)
		
	end
end
How to edit:

To change the coordinates of the tiles position we have to change the
fromPos.x, fromPos.y and fromPos.z.
Code:
if fromPos.x == [COLOR="#FF0000"]997[/COLOR] and fromPos.y == [COLOR="#00FF00"]994[/COLOR] and fromPos.z == [COLOR="#0000FF"]7[/COLOR] then

The red numbers are the X coordinates
The green numbers are the Y coordinates
The blue numbers are the Z coordinates
These are the coordiantes you have to enter in order to get teleported.

The destination of our teleport are simple, just these coordinates:
Lua:
local toMonster = {x=1310, y=1024, z=8}


Note: I know that this thread, may be a little to detailed.

Best regards,
Dridia
 
Thanks, i will surely take a look. I will update the script if i get the tables to work ;)
 
Lua:
function onStepIn(cid, item, position, fromPosition)
	local places = {
	--	{from, to, text}
		{{x=998, y=994, z=7}, {x=1310, y=1024, z=8}, "monsters teleports!"},
		{{x=1308, y=1059, z=8}, {x=996, y=994, z=7}, "the quest rooms!"}
	}
 
	for i = 1, #places do
		if(fromPosition.x == places[i][1].x and fromPosition.y == places[i][1].y and fromPosition.z == places[i][1].z) then
			doTeleportThing(cid, places[i][2])
			doSendMagicEffect(getCreaturePosition(cid), 67)
			doSendMagicEffect(places[i][2], 37)
			doSendTextMessage(cid, 19, "Welcome to the ".. places[i][3])
			break
		end
	end
	return true
end

Dunno, if it works. It's a poor made table but you could learn from this to start with.
 
Last edited:
Back
Top