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

Help me with this training room script plz, i dont understand it

Celsish

New Member
Joined
Apr 6, 2009
Messages
74
Reaction score
0
Hi, I use this script, you walk into the tp and get teleported to an empty spot in training room. but nothing happens when i walk into the tp, what do i need to? what to do with playerposition = {x=400, y=400, z=7, stackpos=253}
?

Lua:
function onStepIn(cid, item, pos)
if cid > 0 then
    if item.actionid == 30001 then
        if(item.itemid == 5024) then
            local location = {
                {x=32067, y=32162, z=7, stackpos=253},
                {x=32071, y=32162, z=7, stackpos=253},
                {x=32075, y=32162, z=7, stackpos=253},
                {x=32079, y=32162, z=7, stackpos=253},
                {x=32083, y=32162, z=7, stackpos=253},
                {x=32087, y=32162, z=7, stackpos=253},
                {x=32091, y=32162, z=7, stackpos=253},
                {x=32095, y=32162, z=7, stackpos=253},
                {x=32099, y=32162, z=7, stackpos=253},
                {x=32103, y=32162, z=7, stackpos=253},
                {x=32107, y=32162, z=7, stackpos=253},
                {x=32067, y=32172, z=7, stackpos=253},
                {x=32071, y=32172, z=7, stackpos=253},
                {x=32075, y=32172, z=7, stackpos=253},
                {x=32079, y=32172, z=7, stackpos=253},
                {x=32083, y=32172, z=7, stackpos=253},
                {x=32087, y=32172, z=7, stackpos=253},
                {x=32091, y=32172, z=7, stackpos=253},
                {x=32095, y=32172, z=7, stackpos=253},
                {x=32099, y=32172, z=7, stackpos=253},
                {x=32103, y=32172, z=7, stackpos=253},
                {x=32107, y=32172, z=7, stackpos=253},
                {x=32068, y=32162, z=8, stackpos=253},
                {x=32072, y=32162, z=8, stackpos=253},
                {x=32076, y=32162, z=8, stackpos=253},
                {x=32080, y=32162, z=8, stackpos=253},
                {x=32084, y=32162, z=8, stackpos=253},
                {x=32088, y=32162, z=8, stackpos=253},
                {x=32092, y=32162, z=8, stackpos=253},
                {x=32096, y=32162, z=8, stackpos=253},
                {x=32100, y=32162, z=8, stackpos=253},
                {x=32104, y=32162, z=8, stackpos=253},
                {x=32108, y=32162, z=8, stackpos=253},
                {x=32068, y=32172, z=8, stackpos=253},
                {x=32072, y=32172, z=8, stackpos=253},
                {x=32076, y=32172, z=8, stackpos=253},
                {x=32080, y=32172, z=8, stackpos=253},
                {x=32084, y=32172, z=8, stackpos=253},
                {x=32088, y=32172, z=8, stackpos=253},
                {x=32092, y=32172, z=8, stackpos=253},
                {x=32096, y=32172, z=8, stackpos=253},
                {x=32100, y=32172, z=8, stackpos=253},
                {x=32104, y=32172, z=8, stackpos=253},
                {x=32108, y=32172, z=8, stackpos=253},
                {x=32066, y=32162, z=7, stackpos=253},
                {x=32070, y=32162, z=7, stackpos=253},
                {x=32074, y=32162, z=7, stackpos=253},
                {x=32078, y=32162, z=7, stackpos=253},
                {x=32082, y=32162, z=7, stackpos=253},
                {x=32086, y=32162, z=7, stackpos=253},
                {x=32090, y=32162, z=7, stackpos=253},
                {x=32094, y=32162, z=7, stackpos=253},
                {x=32098, y=32162, z=7, stackpos=253},
                {x=32102, y=32162, z=7, stackpos=253},
                {x=32106, y=32162, z=7, stackpos=253},
                {x=32066, y=32172, z=7, stackpos=253},
                {x=32070, y=32172, z=7, stackpos=253},
                {x=32074, y=32172, z=7, stackpos=253},
                {x=32078, y=32172, z=7, stackpos=253},
                {x=32082, y=32172, z=7, stackpos=253},
                {x=32086, y=32172, z=7, stackpos=253},
                {x=32090, y=32172, z=7, stackpos=253},
                {x=32094, y=32172, z=7, stackpos=253},
                {x=32098, y=32172, z=7, stackpos=253},
                {x=32102, y=32172, z=7, stackpos=253},
                {x=32106, y=32172, z=7, stackpos=253}
            }
            playerposition = {x=32366, y=32236, z=7, stackpos=253}
            i2 = 0
            local playerteleported = 1
            for i=0,23 do
                i2 = i2 +1
                getplayer = getThingfromPos(location[i2])
                if getplayer.itemid > 0 then
                    playerteleported = 1
                else
                    doTeleportThing(cid,location[i2])
                    playerteleported = 0
                    break
                end
            end
            if playerteleported > 0 then
                doTeleportThing(cid,{x=32369, y=32241, z=7})
                doPlayerSendTextMessage(cid,22,"There was no empty training spot.")
            end
        end
    end
end
end
 
Last edited by a moderator:
Two questions.
Is your map really 32000x32000+? I've never teleported using lua so forgive me if you have to use the Tibia values instead of the map ones.

And have you set the actionid of the space the teleporter is on? (or perhaps the actionid of the tp)
 
I tested this one, it works for me.
Lua:
local t = {
	a = {
		{x=32067, y=32162, z=7},
		{x=32071, y=32162, z=7},
		{x=32075, y=32162, z=7},	
		{x=32079, y=32162, z=7},
		{x=32083, y=32162, z=7},
		{x=32087, y=32162, z=7},
		{x=32091, y=32162, z=7},
		{x=32095, y=32162, z=7},
		{x=32099, y=32162, z=7},
		{x=32103, y=32162, z=7},
		{x=32107, y=32162, z=7},
		{x=32067, y=32172, z=7},
		{x=32071, y=32172, z=7},
		{x=32075, y=32172, z=7},
		{x=32079, y=32172, z=7},
		{x=32083, y=32172, z=7},
		{x=32087, y=32172, z=7},
		{x=32091, y=32172, z=7},
		{x=32095, y=32172, z=7},
		{x=32099, y=32172, z=7},
		{x=32103, y=32172, z=7},
		{x=32107, y=32172, z=7},
		{x=32068, y=32162, z=8},
		{x=32072, y=32162, z=8},
		{x=32076, y=32162, z=8},
		{x=32080, y=32162, z=8},
		{x=32084, y=32162, z=8},
		{x=32088, y=32162, z=8},
		{x=32092, y=32162, z=8},
		{x=32096, y=32162, z=8},
		{x=32100, y=32162, z=8},
		{x=32104, y=32162, z=8},
		{x=32108, y=32162, z=8},
		{x=32068, y=32172, z=8},
		{x=32072, y=32172, z=8},
		{x=32076, y=32172, z=8},
		{x=32080, y=32172, z=8},
		{x=32084, y=32172, z=8},
		{x=32088, y=32172, z=8},
		{x=32092, y=32172, z=8},
		{x=32096, y=32172, z=8},
		{x=32100, y=32172, z=8},
		{x=32104, y=32172, z=8},
		{x=32108, y=32172, z=8},
		{x=32066, y=32162, z=7},
		{x=32070, y=32162, z=7},
		{x=32074, y=32162, z=7},
		{x=32078, y=32162, z=7},
		{x=32082, y=32162, z=7},
		{x=32086, y=32162, z=7},
		{x=32090, y=32162, z=7},
		{x=32094, y=32162, z=7},
		{x=32098, y=32162, z=7},
		{x=32102, y=32162, z=7},
		{x=32106, y=32162, z=7},
		{x=32066, y=32172, z=7},
		{x=32070, y=32172, z=7},
		{x=32074, y=32172, z=7},
		{x=32078, y=32172, z=7},
		{x=32082, y=32172, z=7},
		{x=32086, y=32172, z=7},
		{x=32090, y=32172, z=7},
		{x=32094, y=32172, z=7},
		{x=32098, y=32172, z=7},
		{x=32102, y=32172, z=7},
		{x=32106, y=32172, z=7}
	},
	b = 0,
	c = {x="981", y="1006", z="7"}
	}
	
function onStepIn(cid, item, fromPosition, itemEx)
	if isPlayer(cid) then
		repeat
			t.b = t.b+1
		until t.b >= #t.a or getTopCreature(t.a[t.b]).type ~= 1
			if getTopCreature(t.a[t.b]).type == 1 then
					doTeleportThing(cid, t.c)
					doCreatureSay(cid, "Sorry, all the training rooms are occupied", TALKTYPE_ORANGE_1)
				else
					doTeleportThing(cid, t.a[t.b])
					doCreatureSay(cid, "Training...", TALKTYPE_ORANGE_1)
			end
	end
	t.b = 0
end
Not tested:
Lua:
local t = {
	a = {
		{x=1000, y=1000, z=7}, --TOP LEFT training monk spot pos
		{x=1000, y=1006, z=7}, --TOP RIGHT training monk spot pos
		{x=1003, y=1006, z=7} --last training monk spot
		},
	b = {
		{4}, --tiles between trianing spots from north to south.
		{4} --tiles between trianing spots from west to east.
		}
	}
local i, a, b, c, d, e = 0, t.a[1], t.a[2], t.a[3], t.b[1], t.b[2]
function onStepIn(cid, item, fromPosition, toPosition)
i = a
if isPlayer(cid) then
	if getTopCreature(a).type == 1 then
		check(cid, fromPosition)
	else
		doTeleportThing(cid, a)
	end
end
a = i
i = 0
return TRUE
end

function check(w, s)
repeat
	a.x = a.x+e
until a.x == b.x or a == c or getTopCreature(a).type ~= 1
	if a.x == b.x then
		a.y = a.y+d
		check(w, s)
	end
	if getTopCreature(a).type == 1 then
		doPlayerSendTextMessage(w, 21, 'Sorry, all training spots are occupied')
		doTeleportThing(w, s)
	else
		doTeleportThing(w, a)
	end
end
If you could make all the training rooms in one floor, and they all have the same sqms between them use this script /\
 
Last edited:
Back
Top