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

gmstrikker

Intermediate OT User
Joined
Jul 30, 2014
Messages
373
Best answers
1
Reaction score
31
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


???
 

ond

Legendary OT User
Joined
Mar 24, 2008
Messages
2,691
Best answers
22
Reaction score
412
Location
Sweden
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
 

M0ustafa

Î Àm ŁĕğẹňĎ
Support Team
Joined
Mar 4, 2017
Messages
889
Best answers
94
Reaction score
318
Location
Egypt
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.
 
OP
gmstrikker

gmstrikker

Intermediate OT User
Joined
Jul 30, 2014
Messages
373
Best answers
1
Reaction score
31
I appreciate both of your helps, thank you very much
 
Top