• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Trainers Auto Warp

Ahead

New Member
Joined
Dec 27, 2013
Messages
165
Reaction score
2
I played recently a OTServ in which you entered in a trainer warp and it directly sent you to an EMPTY TRAINING CELL.

I mean, it avoids you to search walking for these empties cells. It was configured to teletransport you directly to them. I imagine it is a script, do you know about this?.

Oh, i forgot, if there is no empties cells it teletransport you to the DP, doing them limited.

Thaaaaank you ^^.
 
Ok, i thought i got it but no. Sorry for doubleposting.

From there: http://otland.net/threads/random-teleport-and-check-if-player-is-on-sqm.10487/

I tested this:

Code:
function onStepIn(cid, item, pos)
local location = {
{x=480, y=463, z=8, stackpos=253}, -- Location 1
{x=484, y=463, z=8, stackpos=253}, -- Location 2
{x=488, y=463, z=8, stackpos=253}, -- Location 3
{x=492, y=463, z=8, stackpos=253}, -- Location 4
{x=496, y=463, z=8, stackpos=253},
{x=500, y=463, z=8, stackpos=253},
{x=480, y=469, z=8, stackpos=253},
{x=484, y=469, z=8, stackpos=253},
{x=488, y=469, z=8, stackpos=253},
{x=492, y=469, z=8, stackpos=253},
{x=496, y=469, z=8, stackpos=253},
{x=500, y=469, z=8, stackpos=253},
{x=480, y=473, z=8, stackpos=253},
{x=484, y=473, z=8, stackpos=253},
{x=488, y=473, z=8, stackpos=253},
{x=492, y=473, z=8, stackpos=253},
{x=496, y=473, z=8, stackpos=253},
{x=500, y=473, z=8, stackpos=253},
{x=480, y=479, z=8, stackpos=253},
{x=484, y=479, z=8, stackpos=253},
{x=488, y=479, z=8, stackpos=253},
{x=492, y=479, z=8, stackpos=253},
{x=496, y=479, z=8, stackpos=253},
{x=500, y=479, z=8, stackpos=253} -- Last Location. Add more locations above if needed or remove. Keep this line as last one.
}


for i=1,#location do
getplayer = getThingfromPos(location[i])
if getplayer.itemid > 0 then
playerteleported = 1
else
doTeleportThing(cid,location[i])
doPlayerSendTextMessage(cid,22,"Welcome to the training monks! Step in the portal to leave. (Made by TheTobbe)")
doPlayerSendTextMessage(cid,21,"Do not macro train, you will get banned!")
playerteleported = 0
break
end
end

if playerteleported > 0 then
doTeleportThing(cid,{x=469, y=471, z=8})
doPlayerSendTextMessage(cid,22,"There was no empty training spot.")
end
end

And this

Code:
local location = {
{x=480, y=463, z=8},
{x=484, y=463, z=8},
{x=488, y=463, z=8},
{x=492, y=463, z=8},
{x=496, y=463, z=8},
{x=500, y=463, z=8},
{x=480, y=469, z=8},
{x=484, y=469, z=8},
{x=488, y=469, z=8},
{x=492, y=469, z=8},
{x=496, y=469, z=8},
{x=500, y=469, z=8},
{x=480, y=473, z=8},
{x=484, y=473, z=8},
{x=488, y=473, z=8},
{x=492, y=473, z=8},
{x=496, y=473, z=8},
{x=500, y=473, z=8},
{x=480, y=479, z=8},
{x=484, y=479, z=8},
{x=488, y=479, z=8},
{x=492, y=479, z=8},
{x=496, y=479, z=8},
{x=500, y=479, z=8}
}
function onStepIn(cid, item, pos)
for i = 1, #location do
if getTopCreature(location[i]).uid > 0 then
playerteleported = 1
else
doTeleportThing(cid,location[i])
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Welcome to the training monks! Step in the portal to leave. (Made by TheTobbe)")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Do not macro train, you will get banned!")
playerteleported = 0
break
end
end
if playerteleported > 0 then
doTeleportThing(cid, {x=469, y=471, z=8})
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "There was no empty training spot.")
end
return TRUE
end

They run properly but it does not works ingame for me.

By the way, somebody could explain me this?

Code:
if playerteleported > 0 then
doTeleportThing(cid, {x=469, y=471, z=8})

Does it means the coords of the position where you will be teleported if there is not any spot empty?

Thank you.
 
I got a headache trying to read your code, so I took what matters and made a new one, should work for you :)

Code:
local locations = {
    {x=480, y=463, z=8},
    {x=484, y=463, z=8},
    {x=488, y=463, z=8},
    {x=492, y=463, z=8},
    {x=496, y=463, z=8},
    {x=500, y=463, z=8},
    {x=480, y=469, z=8},
    {x=484, y=469, z=8},
    {x=488, y=469, z=8},
    {x=492, y=469, z=8},
    {x=496, y=469, z=8},
    {x=500, y=469, z=8},
    {x=480, y=473, z=8},
    {x=484, y=473, z=8},
    {x=488, y=473, z=8},
    {x=492, y=473, z=8},
    {x=496, y=473, z=8},
    {x=500, y=473, z=8},
    {x=480, y=479, z=8},
    {x=484, y=479, z=8},
    {x=488, y=479, z=8},
    {x=492, y=479, z=8},
    {x=496, y=479, z=8},
    {x=500, y=479, z=8}
}
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    for _, pos in pairs(locations) do
        if(getTopCreature(pos).uid == 0) then
            doTeleportThing(cid, pos)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Welcome to the training monks! Step in the portal to leave.")
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Do not macro train, you will get banned!")
            return true
        end
    end
    doTeleportThing(cid, fromPosition, true)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "There was no empty training spot.")
    return true
end

P.S.
Next time you post a code make sure its tabbed (it really helps make things readable)
 
By the way, somebody could explain me this?

Code:
if playerteleported > 0 then
doTeleportThing(cid, {x=469, y=471, z=8})

Does it means the coords of the position where you will be teleported if there is not any spot empty?

Thank you.
Yes. If a player is using a room, playerteleported will be = 1, if not, it will be 0.
Then it checks if there is no room avaiable and send a cancel.

They run properly but it does not works ingame for me.
Did you edit the locations?
 
Ok guys, i am trying a new script i found because all the others were not working properly. I still do not know why.

But i have a doubt now, in the .xml is shown this:

Code:
-- TPTRAINER SYSTEM BY LEDTHERON --
function onStepIn(cid, item, position, fromPosition)
for i=1, table.maxn(trainers) do
local trainer = trainers[i]
local position = {x=trainer.x,y=trainer.y,z=trainer.z,stackpos=255}
local thing = getThingFromPos(position)
if (thing.itemid == 0) then
doTeleportThing(cid, position)
doSendMagicEffect(position, 14)
return true
end
end
doPlayerSendCancel(cid, "Todos los trainers estan llenos")
doTeleportThing(cid, fromPosition, false)
doSendMagicEffect(fromPosition, 13)
return true
end

What do that 13 and 14 mean? ^^

Thank you, this is almost done, because it is working for me!

Did you edit the locations?

Of course mate :).
 
Last edited:
Back
Top