• Congratulations to the OTLand January Mapping Competition Winner! The grand prize of Otland Premium goes to Andréew.
  • Sign up for February Mapping Competition! The prize includes Otland Premium time.
  • 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

Active Member
Joined
Jul 30, 2014
Messages
379
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

Veteran OT User
Joined
Mar 24, 2008
Messages
2,717
Best answers
22
Reaction score
439
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 ŁĕğẹňĎ
Premium User
Support Team
Joined
Mar 4, 2017
Messages
1,301
Best answers
153
Reaction score
477
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

Active Member
Joined
Jul 30, 2014
Messages
379
Best answers
1
Reaction score
31
I appreciate both of your helps, thank you very much
 
Top