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

Lua script - Trainers teleport

Mjmackan

Mapper ~ Writer
Premium User
Joined
Jul 18, 2009
Messages
1,424
Solutions
15
Reaction score
177
Location
Sweden
Any idea what's wrong with this script?

Gives this error below and when entering the training teleport it doesn't tp me anywhere but it sends the message 'Training'.
Lua:
[0:48:11.179] [Error - MoveEvents Interface] 
[0:48:11.179] data/movements/scripts/Teleports/Trainers Teleport.lua:onStepIn
[0:48:11.179] Description: 
[0:48:11.179] (luaGetThingPosition) Thing not found

Script:
Lua:
function onStepIn(cid, item, position, fromPosition)
	for i = 17000, 17100 do
		local pos = getThingPos(i)
		if not isPlayer(getTopCreature(pos).uid) then
			doTeleportThing(cid, pos)
	 		doCreatureSay(cid, 'Training', 19, false, cid)
			doSendMagicEffect(position, CONST_ME_TELEPORT)
			doSendMagicEffect(pos, CONST_ME_TELEPORT)
			return
		end
	end
	doTeleportThing(cid, fromPosition, true)
	doCreatureSay(cid, 'All training slots are taken', 19, false, cid)
	doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
end
 
Edit the position
PHP:
local t = {
	a = { --"posY"
		[1] = {x="982", y="1002", z="7"},
		[2] = {x="983", y="1002", z="7"},
		[3] = {x="984", y="1002", z="7"}
	},
	b = 0,
	c = {x="981", y="1006", z="7"} --"posZ"
	}
 
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
 
@mhamad Yeah i am using that script but i need to have a lot of training spots, 100+ and there for it gets extremly long and also starts acting weird.

@Cykotitan I have put out those ids and it didn't work..
 
Back
Top