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

TFS 0.X Check X position, if is empty then teleport player there

gmstrikker

Well-Known Member
Joined
Jul 30, 2014
Messages
458
Solutions
1
Reaction score
50
i want to make training monks more friendly to players

its too boring to need to walk until a free trainer room

how to check a few positions, if have no player on that position, teleport the player to this position, else if shows: the trainers room are full


401,101,7
405,101,7
409,101,7
413,101,7
417,101,7


???
 
Solution
Why not using this one? Posted on forum instead of writing all X Y Z
Add any unique ID on the SQM where players supposed to stand from range 17000 to 18015.
Add to movements/scripts
Lua:
function onStepIn(cid, item, position, fromPosition)
for i = 17000, 18015 do
local pos = getThingPos(i)
if not isPlayer(getTopCreature(pos).uid) then
doTeleportThing(cid, pos)
doCreatureSay(cid, 'Training time!.', TALKTYPE_ORANGE_1, false, cid)
doSendMagicEffect(position, CONST_ME_TELEPORT)
doSendMagicEffect(pos, CONST_ME_TELEPORT)
return true
end
end
doTeleportThing(cid, fromPosition, true)
doCreatureSay(cid, 'All training slots are taken', TALKTYPE_ORANGE_1, false, cid)
doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
end
then add this to...
Haven't tested:

Lua:
local t = {
    {x=401, y=101, z=7},
    {x=405, y=101, z=7},
    {x=409, y=101, z=7},
    {x=413, y=101, z=7},
    {x=417, y=101, z=7},
}

function onStepIn(cid, item, toPosition, fromPosition)
    for _, v in ipairs(t) do
        local n = getTopCreature(v).uid
        if not isPlayer(n) then
            if isCreature(n) then
                doRemoveCreature(n)
            end
            doTeleportThing(cid, v)
            return true
        end
    end
    doRelocate(toPosition, fromPosition)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The trainers room are full.")
    return true
end
 
Why not using this one? Posted on forum instead of writing all X Y Z
Add any unique ID on the SQM where players supposed to stand from range 17000 to 18015.
Add to movements/scripts
Lua:
function onStepIn(cid, item, position, fromPosition)
for i = 17000, 18015 do
local pos = getThingPos(i)
if not isPlayer(getTopCreature(pos).uid) then
doTeleportThing(cid, pos)
doCreatureSay(cid, 'Training time!.', TALKTYPE_ORANGE_1, false, cid)
doSendMagicEffect(position, CONST_ME_TELEPORT)
doSendMagicEffect(pos, CONST_ME_TELEPORT)
return true
end
end
doTeleportThing(cid, fromPosition, true)
doCreatureSay(cid, 'All training slots are taken', TALKTYPE_ORANGE_1, false, cid)
doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
end
then add this to movements.xml
XML:
<movevent type="StepIn" uniqueid="xxxx" event="script" value="xxxx.lua" />
and add your unique ID to training room teleport using map editor.
 
Solution
Back
Top