Perun
nems.online
- Joined
- May 1, 2009
- Messages
- 378
- Solutions
- 7
- Reaction score
- 176
Teleport you to first free slot - simple version.
Tommorow i will create/upload infinity training room too. (just saw messages about that).
Tommorow i will create/upload infinity training room too. (just saw messages about that).
Lua:
local config = {
leftTopCorner = {x = 1046, y = 996},
rightDownCorner = {x = 1071, y = 1011},
zPos = 7,
tileItemId = 407, --tile item id for scanner, where you want to teleport player, ez to change for tile with uid if someone need
}
local function findFirstEmpty()
for x = config.leftTopCorner.x, config.rightDownCorner.x do
for y = config.leftTopCorner.y, config.rightDownCorner.y do
local tmpPos = {x=x, y=y, z = config.zPos};
local t = Tile(tmpPos)
if t ~= nil then
if(t:getThing():getId() == config.tileItemId and not t:getTopCreature()) then
return tmpPos
end
end
end
end
return false
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local availableTrainingSlot = findFirstEmpty()
if(availableTrainingSlot) then
cid:teleportTo(availableTrainingSlot)
cid:sendTextMessage(MESSAGE_INFO_DESCR, "Welcome.")
else
cid:sendTextMessage(MESSAGE_INFO_DESCR, "No available slots.")
end
return true
end