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

Movement Teleports and Changing Items

Coltain13

New Member
Joined
May 4, 2008
Messages
22
Reaction score
0
So I figured that I would be able to do this on my own but I guess I was wrong. I got everything I needed to enter the Training Monks but when it comes to leaving, thats a different story.
I've got:

Code:
function onStepIn(cid, item, position, position)

local spawnMonk1 = {x = position.x-1, y = position.y-5, z = position.z}
local spawnMonk2 = {x = position.x+1, y = position.y-5, z = position.z}

if item.actionid == 5000 then
	if item.itemid == 9565 then
		doSummonCreature("Training Monk", spawnMonk1)
		doSummonCreature("Training Monk", spawnMonk2)
		doTransformItem(item.uid, item.itemid - 3)		
		local newposition = {x = position.x, y = position.y-4, z = position.z}
			doTeleportThing(cid, newposition)
			doSendMagicEffect(newposition, 12)
	else
		local newposition = {x = position.x, y = position.y, z = position.z}
			doTeleportThing(cid, newposition)
			doSendMagicEffect(newposition, 12)
	end
end
	return TRUE
end

which does

beforeentertraning.png


to

afterentertraning.png


which is what I want when you enter it. When you leave I want it to change the gem back to green and un-summon the Training Monks. The only kick is that I want to do it without giving exact coordinates because I got about 100 of the stalls and I want to be able to do it with just a few scripts and not 100.

This is all I got when you exit:

Code:
function onStepIn(cid, item, position, position)

if item.actionid == 5001 then	
		local newposition = {x = position.x, y = position.y+4, z = position.z}
			doTeleportThing(cid, newposition)
			doSendMagicEffect(newposition, 12)
end
	return TRUE
end

which does:

afterleavetraining.png


because I can't figure out a way to make it work.
So anyone that can help, thanks a ton!

_Coltain
 
Not Tested

How it works:

Enter-
Step on green tile in front of booth, you get teleported in and it disappears, and the blue tile appears with 2 training monks.
(Make sure no other GREEN tiles on map except the trainers)

Exit-
Step on the blue tile, you get teleported out, and the green tile reappears.
(Make sure no other BLUE tiles on map except the trainers)

Lua:
local monks = {
		[1] = {x = position.x-1, y = position.y-5, z = position.z},
		[2] = {x = position.x+1, y = position.y-5, z = position.z}
	}
local tele = {
		[In] = {x = position.x, y = position.y+4, z = position.z},
		[Out] = {x = position.x, y = position.y-4, z = position.z}
	}
local tiles = {
		[BLUE]= {id = XXXX},
		[GREEN] = {id = XXXX}
	}

function onStepIn(cid, item, fromPosition, toPosition)
local EFFECT_TRUE = CONST_ME_TELEPORT
	if (item.itemid == tiles[BLUE].id) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You have left the training booth.")
		doSendMagicEffect(getCreaturePosition(cid), EFFECT_TRUE)
		doRemoveItem(getTileItemById(tiles[BLUE].id))
		doCreateItem(tiles[GREEN].id, 1, tele[Out])
		doTeleportThing(cid, tele[Out])
	elseif (item.itemid == tiles[GREEN].id) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have occupied a training booth.")
		doSendMagicEffect(getCreaturePosition(cid), EFFECT_TRUE)
		doRemoveItem(getTileItemById(tiles[GREEN].id))
		doCreateItem(tiles[BLUE].id, 1, tele[In])
		doSummonMonster("Training Monk", monks[1])
		doSummonMonster("Training Monk", monks[2])
		doTeleportThing(cid, tele[In])
	end
	return true
end
 
Last edited:
I am getting:

Code:
[24/11/2009 20:21:04] data/movements/scripts/trainers/trainers.lua:7: '}' expected (to close '{' at line 5) near 'Out'

error, I thought maybe it was the comma that was left out after the In line:

Code:
local tele = {
                In = {x = position.x, y = position.y+4, z = position.z}[COLOR="Red"],[/COLOR]
                Out = {x = position.x, y = position.y-4, z = position.z}
        }

but it didn't help.
 
Code:
local tiles = {
	["BLUE"]= {id = XXXX},
	["GREEN"] = {id = XXXX}
}
local EFFECT_TRUE = CONST_ME_TELEPORT
function onStepIn(cid, item, fromPosition, toPosition)
	if (item.itemid == tiles["BLUE"].id) then
		local tele = {
			["Out"] = {x = position.x, y = position.y-4, z = position.z}
		}
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You have left the training booth.")
		doSendMagicEffect(getCreaturePosition(cid), EFFECT_TRUE)
		doRemoveItem(getTileItemById(tiles["BLUE"].id).uid)
		doCreateItem(tiles["GREEN"].id, 1, tele["Out"])
		doTeleportThing(cid, tele["Out"])
	elseif (item.itemid == tiles["GREEN"].id) then
		local tele, monks = 
		{
			["In"] = {x = position.x, y = position.y+4, z = position.z}
		}, 
		{
			{x = position.x-1, y = position.y-5, z = position.z},
			{x = position.x+1, y = position.y-5, z = position.z}
		}
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have occupied a training booth.")
		doSendMagicEffect(getCreaturePosition(cid), EFFECT_TRUE)
		doRemoveItem(getTileItemById(tiles["GREEN"].id).uid)
		doCreateItem(tiles["BLUE"].id, 1, tele["In"])
		doSummonMonster("Training Monk", monks[1])
		doSummonMonster("Training Monk", monks[2])
		doTeleportThing(cid, tele["In"])
	end
	return true
end
 
Doesn't work?
I'll make another version of mine later.
With everything you wanted, red tiles etc...
 
Back
Top