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

Need help with teleport function

zaxaer

New Member
Joined
Oct 1, 2009
Messages
40
Reaction score
1
Guys, I've made two teleports..

Lua:
-- Starter Teleporter

function onStepIn(cid, item, frompos, itemEx, topos)
local toStarter = {x=1020, y=1022, z=7}
local toEqroom = {x=1069, y=1022, z=7}

	if getPlayerVocation(cid) < 1 then
	local fromStarter = {x=1010, y=1016, z=7}
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING,"You don't have a vocation yet. Ask one of the NPCs to grant you a vocation.")
		doTeleportThing(cid, toStarter)
		doSendMagicEffect(toStarter, CONST_ME_TELEPORT)
		doSendMagicEffect(fromStarter, CONST_ME_TELEPORT)

	else 	local fromStarter = {x=10, y=1030, z=7}
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE,"So you've made your decision, pilgrim. Now it's time to get yourself some clothes.")
		doTeleportThing(cid, toEqroom)
		doSendMagicEffect(toEqroom, CONST_ME_TELEPORT)
		doSendMagicEffect(fromStarter, CONST_ME_TELEPORT)
	end
end

-- Test Teleporter

function onStepIn(cid, item, frompos, itemEx, topos)
local fromtest = {x=1020, y=1022, z=7}
local totest = {x= 1025, y=1022, z=7}

	if getPlayerPosition(cid) == fromtest then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING,"YO! IT WORKS!")
		doTeleportThing(cid, totest)
		doSendmagicEffect(totest, CONST_ME_TELEPORT)
		doSendMagicEffect(fromtest, CONST_ME_TELEPORT)
	end
end

Yes the teleport functions are in one document.

The problem now is, both teleports don't work.

Code:
<movevent event="StepIn" itemid="1387" script="teleport.lua"/>

I've referred it well (I guess) and the GUI isn't giving any errors so I can't figure out what the problem is.

Can you guys perhaps help me out a bit?

ALSO:

If I want to add the same script to another teleport should I use it this way?

Lua:
-- Starter Teleporter

function onStepIn(cid, item, frompos, itemEx, topos)
local toStarter = {x=1020, y=1022, z=7}
local toEqroom = {x=1069, y=1022, z=7}

	if getPlayerVocation(cid) < 1 then
	local fromStarter = {x=1010, y=1016, z=7; x=1020, y=1016, z=7} -- I've edited right here
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING,"You don't have a vocation yet. Ask one of the NPCs to grant you a vocation.")
		doTeleportThing(cid, toStarter)
		doSendMagicEffect(toStarter, CONST_ME_TELEPORT)
		doSendMagicEffect(fromStarter, CONST_ME_TELEPORT)

	else 	local fromStarter = {x=10, y=1030, z=7}
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE,"So you've made your decision, pilgrim. Now it's time to get yourself some clothes.")
		doTeleportThing(cid, toEqroom)
		doSendMagicEffect(toEqroom, CONST_ME_TELEPORT)
		doSendMagicEffect(fromStarter, CONST_ME_TELEPORT)
	end
end

I'm not sure though, kinda trying some things out hehe

Thanks in advance!
 
Guys, I've made two teleports..

Lua:
-- Starter Teleporter

function onStepIn(cid, item, frompos, itemEx, topos)
local toStarter = {x=1020, y=1022, z=7}
local toEqroom = {x=1069, y=1022, z=7}

	if getPlayerVocation(cid) < 1 then
	local fromStarter = {x=1010, y=1016, z=7}
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING,"You don't have a vocation yet. Ask one of the NPCs to grant you a vocation.")
		doTeleportThing(cid, toStarter)
		doSendMagicEffect(toStarter, CONST_ME_TELEPORT)
		doSendMagicEffect(fromStarter, CONST_ME_TELEPORT)

	else 	local fromStarter = {x=10, y=1030, z=7}
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE,"So you've made your decision, pilgrim. Now it's time to get yourself some clothes.")
		doTeleportThing(cid, toEqroom)
		doSendMagicEffect(toEqroom, CONST_ME_TELEPORT)
		doSendMagicEffect(fromStarter, CONST_ME_TELEPORT)
	end
end

-- Test Teleporter

function onStepIn(cid, item, frompos, itemEx, topos)
local fromtest = {x=1020, y=1022, z=7}
local totest = {x= 1025, y=1022, z=7}

	if getPlayerPosition(cid) == fromtest then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING,"YO! IT WORKS!")
		doTeleportThing(cid, totest)
		doSendmagicEffect(totest, CONST_ME_TELEPORT)
		doSendMagicEffect(fromtest, CONST_ME_TELEPORT)
	end
end

Yes the teleport functions are in one document.

The problem now is, both teleports don't work.

Code:
<movevent event="StepIn" itemid="1387" script="teleport.lua"/>

I've referred it well (I guess) and the GUI isn't giving any errors so I can't figure out what the problem is.

Can you guys perhaps help me out a bit?

ALSO:

If I want to add the same script to another teleport should I use it this way?

Lua:
-- Starter Teleporter

function onStepIn(cid, item, frompos, itemEx, topos)
local toStarter = {x=1020, y=1022, z=7}
local toEqroom = {x=1069, y=1022, z=7}

	if getPlayerVocation(cid) < 1 then
	local fromStarter = {x=1010, y=1016, z=7; x=1020, y=1016, z=7} -- I've edited right here
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING,"You don't have a vocation yet. Ask one of the NPCs to grant you a vocation.")
		doTeleportThing(cid, toStarter)
		doSendMagicEffect(toStarter, CONST_ME_TELEPORT)
		doSendMagicEffect(fromStarter, CONST_ME_TELEPORT)

	else 	local fromStarter = {x=10, y=1030, z=7}
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE,"So you've made your decision, pilgrim. Now it's time to get yourself some clothes.")
		doTeleportThing(cid, toEqroom)
		doSendMagicEffect(toEqroom, CONST_ME_TELEPORT)
		doSendMagicEffect(fromStarter, CONST_ME_TELEPORT)
	end
end

I'm not sure though, kinda trying some things out hehe

Thanks in advance!

I'm not a scripting genious.. but you have two of the same local's defined with different parameters..

Lua:
	local fromStarter = {x=1010, y=1016, z=7; x=1020, y=1016, z=7} -- I've edited right here
	else 	local fromStarter = {x=10, y=1030, z=7}

Assuming I know what happened - Try this. (this will let 1 teleport when walked into teleport player away from teleport saying they need a vocation , and if they have a vocation will teleport them to reward room. A single Teleport with the Action ID 30000 in your map should accomplish this.)
Lua:
-- Starter Teleporter

function onStepIn(cid, item, frompos, itemEx, topos)
if item.actionid == 30000 then -- set this to whatever you want, just make sure no other objects have the same ActionID
local toStarter = {x=1010, y=1020, z=7} -- set this to a position 3 squares away from teleporter and it will make the player teleport away from the teleporter
local toEqroom = {x=10, y=1030, z=7} -- set this to the equipment room/reward room if they have a vocation

	if getPlayerVocation(cid) < 1 then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING,"You don't have a vocation yet. Ask one of the NPCs to grant you a vocation.")
		doTeleportThing(cid, toStarter)
		doSendMagicEffect(toStarter, CONST_ME_TELEPORT)
		doSendMagicEffect(fromStarter, CONST_ME_TELEPORT)

	else 	doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE,"So you've made your decision, pilgrim. Now it's time to get yourself some clothes.")
		doTeleportThing(cid, toEqroom)
		doSendMagicEffect(toEqroom, CONST_ME_TELEPORT)
		doSendMagicEffect(fromStarter, CONST_ME_TELEPORT)
	end
end
 
Alright mate! Thanks for the reply, I'll check it out tomorrow. I'll be heading to bed for now :)

-- Edit --

I've used it and it works.

ps: You needed to put 3 "end" there.

Thank you! :)
 
Last edited:
Back
Top