• 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 to different location depending on their vocation

Dridia

New Member
Joined
Jan 17, 2012
Messages
49
Reaction score
1
Location
Sweden
Hi! i've been trying to make a script that will work like this.
When a Sorcerer enters a tile with the action id "125" it will be teleported to x: 1000 y:1000 z:7
but when a druid enters the tile it will be teleported to x: 1001 y:1000 z:7
and the same with all the vocations. I'm using Crying Damson 0.3.6 (8.6) v3
The script i got this far is:
Lua:
function onStepIn(cid, item, pos)
	if item.actionid == 125 then
	if isPlayer(cid) == TRUE then
		doPlayerSetVocation(cid,1)
		newpos = {x=1105, y=989, z=7}
		doTeleportThing(cid,newpos)
		doPlayerSendTextMessage(cid,22,"Welcome Sorcerer Please, pick your items.")
	end
	if item.actionid == 125 then
	if isPlayer(cid) == TRUE then
doPlayerSetVocation(cid,2)
newpos = {x=1105, y=989, z=7}
doTeleportThing(cid,newpos)
doPlayerSendTextMessage(cid,22,"Welcome Druid. Please, pick your items.")
end
if item.actionid == 125 then
if isPlayer(cid) == TRUE then
doPlayerSetVocation(cid,3)
newpos = {x=1105, y=989, z=7}
doTeleportThing(cid,newpos)
doPlayerSendTextMessage(cid,22,"Welcome Paladin. Please, pick your items.")
if item.actionid == 125 then
if isPlayer(cid) == TRUE then
doPlayerSetVocation(cid,4)
newpos = {x=1105, y=989, z=7}
doTeleportThing(cid,newpos)
doPlayerSendTextMessage(cid,22,"Welcome Knight. Please, pick your items.")
end


else
return false
end
return true
end
end
end
end

function onStepOut(cid, item, pos)
return true
end
end
Mokerhamer posted this on another thread, so i haven't made it! NO CREDITS TO ME!
 
Lua:
local t = {
	{x=100, y=100, z=7}, --sorcerer
	{x=100, y=100, z=7}, --druid
	{x=100, y=100, z=7}, --paladin
	{x=100, y=100, z=7} --knight
	}
function onStepIn(cid, item, fromPosition, itemEx, toPosition)
local k = t[getPlayerVocation(cid)]
	if isPlayer(cid) then
		if k then
			doTeleportThing(cid, k)
		else
			print('ERROR: '..getCreatureName(cid)..'\'s vocation not identified by script o_o')
		end
	end
end
 
Last edited:
Lua:
local t = {
	{x=100, y=100, z=7}, --sorcerer
	{x=100, y=100, z=7}, --druid
	{x=100, y=100, z=7}, --paladin
	{x=100, y=100, z=7} --knight
	}
function onStepIn(cid, item, fromPosition, itemEx, toPosition)
local k = t[getPlayerVocation(cid)]
	if isPlayer(cid) then
		if k then
			doTeleportThing(cid, k)
		else
			print('ERROR: '..getCreatureName(cid)..'\'s vocation not indentified by script o_o')
		end
	end
end

Thank you so much!!! rep++ to you my friend!
 
Lua:
local t = {
	[{1, 5}] = {x = 100, y = 100, z = 7},
	[{2, 6}] = {x = 100, y = 100, z = 7},
	[{3, 7}] = {x = 100, y = 100, z = 7},
	[{4, 8}] = {x = 100, y = 100, z = 7}
}

local backpack = 1988
function onStepIn(cid, item, fromPosition, toPosition)
	if(isPlayer(cid)) then
		for voc, k in pairs(t) do
			if(isInArray(voc, getPlayerVocation(cid))) then
				doTeleportThing(cid, k, false)
				doPlayerAddItem(cid, backpack, 1, false)
			end
		end
	end
	return true
end
 
Lua:
local t = {
	[{1, 5}] = {x = 100, y = 100, z = 7},
	[{2, 6}] = {x = 100, y = 100, z = 7},
	[{3, 7}] = {x = 100, y = 100, z = 7},
	[{4, 8}] = {x = 100, y = 100, z = 7}
}

local backpack = 1988
function onStepIn(cid, item, fromPosition, toPosition)
	if(isPlayer(cid)) then
		for voc, k in pairs(t) do
			if(isInArray(voc, getPlayerVocation(cid))) then
				doTeleportThing(cid, k, false)
				doPlayerAddItem(cid, backpack, 1, false)
			end
		end
	end
	return true
end

It don't get any errors or something like that, but i still don't get the item. I do get teleport to the right spot.
 
Lua:
local t = {
	{x=100, y=100, z=7}, --sorcerer
	{x=100, y=100, z=7}, --druid
	{x=100, y=100, z=7}, --paladin
	{x=100, y=100, z=7}, --knight
	item = 1234
	}
function onStepIn(cid, item, fromPosition, itemEx, toPosition)
local k = t[getPlayerVocation(cid)]
	if isPlayer(cid) then
		if k then
			doTeleportThing(cid, k)
			doPlayerAddItem(cid, t.item, 1, false)
		else
			print('ERROR: '..getCreatureName(cid)..'\'s vocation not identified by script o_o')
		end
	end
end
 
Lua:
local t = {
	{x=100, y=100, z=7}, --sorcerer
	{x=100, y=100, z=7}, --druid
	{x=100, y=100, z=7}, --paladin
	{x=100, y=100, z=7}, --knight
	item = 1234
	}
function onStepIn(cid, item, fromPosition, itemEx, toPosition)
local k = t[getPlayerVocation(cid)]
	if isPlayer(cid) then
		if k then
			doTeleportThing(cid, k)
			doPlayerAddItem(cid, t.item, 1, false)
		else
			print('ERROR: '..getCreatureName(cid)..'\'s vocation not identified by script o_o')
		end
	end
end

But, is posible book + text and not item?
(es posible envez de un item, agregar un libro mas texto? )
 
But, is posible book + text and not item?
(es posible envez de un item, agregar un libro mas texto? )

Lua:
local t = {
	{x=100, y=100, z=7}, --sorcerer
	{x=100, y=100, z=7}, --druid
	{x=100, y=100, z=7}, --paladin
	{x=100, y=100, z=7}, --knight
	book = 2325,
	text = 'Hello!'
	}
function onStepIn(cid, item, fromPosition, itemEx, toPosition)
local k = t[getPlayerVocation(cid)]
local x = doPlayerAddItem(cid, t.book, 1, false)
	if isPlayer(cid) then
		if k then
			doTeleportThing(cid, k)
			doSetItemText(x.uid, t.text)
		else
			print('ERROR: '..getCreatureName(cid)..'\'s vocation not identified by script o_o')
		end
	end
end
 
Last edited:
nevermind. I fixed but it's doesnt show book with text ;s



[14:15:55.190] [Error - MoveEvents Interface]
[14:15:55.190] data/movements/scripts/tp.lua:eek:nStepIn
[14:15:55.190] Description:
[14:15:55.190] (luaDoPlayerAddItem) Item not found
 
Last edited:
Lua:
local t = {
	{x=100, y=100, z=7}, --sorcerer
	{x=100, y=100, z=7}, --druid
	{x=100, y=100, z=7}, --paladin
	{x=100, y=100, z=7} --knight
	}
function onStepIn(cid, item, fromPosition, itemEx, toPosition)
local k = t[getPlayerVocation(cid)]
	if isPlayer(cid) then
		if k then
			doTeleportThing(cid, k)
		else
			print('ERROR: '..getCreatureName(cid)..'\'s vocation not identified by script o_o')
		end
	end
end

Bogart, Can you tell me what should I put on movements.xml?
 
Back
Top