• 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 1.1 & 1.2 !portal (create portal to xyz)

Itutorial

Excellent OT User
Joined
Dec 23, 2014
Messages
1,974
Solutions
52
Reaction score
673
Use it by typing !portal x, y, z

!portal 1000, 1000, 7

It will create the portal in the direction you are looking. It will not create the portal on top of an item or a player.

Lua:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    local split = param:split(",")
    if split[3] == nil then
        player:sendCancelMessage("Insufficient parameters.")
        return false
    end

    x = split[1]
    y = split[2]
    z = split[3]
 
    x = tonumber(x)
    y = tonumber(y)
    z = tonumber(z)
 
    local DIR = player:getDirection()
 
    if DIR == DIRECTION_NORTH then
        portal_pos = {x = player:getPosition().x, y = player:getPosition().y - 1, z = player:getPosition().z}
    elseif DIR == DIRECTION_EAST then
        portal_pos = {x = player:getPosition().x + 1, y = player:getPosition().y, z = player:getPosition().z}
    elseif DIR == DIRECTION_SOUTH then
        portal_pos = {x = player:getPosition().x, y = player:getPosition().y + 1, z = player:getPosition().z}
    elseif DIR == DIRECTION_WEST then
        portal_pos = {x = player:getPosition().x - 1, y = player:getPosition().y, z = player:getPosition().z}
    end
 
    if isCreature(Tile(portal_pos):getTopCreature()) then
        return player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You cannot create a teleport on top of a player.")
    end
 
    if Tile(portal_pos):getTopDownItem() then
        return player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You cannot create a teleport on top of an item.")
    end
 
    doCreateTeleport(1387, {x = x, y = y, z = z}, portal_pos)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Teleport created to cordinates: {X: "..x.." Y: "..y.." Z: "..z.."}.")
    return false
end
 
Last edited by a moderator:

belal112

Basic Lua scripter
Joined
Dec 20, 2012
Messages
96
Solutions
1
Reaction score
11
THIS IS AMAZING! I always wished for a command like that one! thank youu! :D :D
 

Omni Cloud

Banned User
Joined
May 31, 2016
Messages
308
Reaction score
149
Code:
function onSay(player, words, param)
    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return true
    end

    local split = param:split(",")
    if tonumber(split[3]) == nil then
        player:sendCancelMessage("Insufficient parameters.")
        return false
    end
   
    local msg = nil

    for i = 1, #split do
        split[i] = tonumber(split[i])
    end

    local direction = {
        [0] = function(ps) ps.y = ps.y - 1 return ps end,
        [1] = function(ps) ps.x = ps.x + 1 return ps end,
        [2] = function(ps) ps.y = ps.y + 1 return ps end,
        [3] = function(ps) ps.x = ps.x - 1 return ps end
    }

    local teleporter = direction[player:getDirection()](player:getPosition())

    if isCreature(Tile(teleporter):getTopCreature()) then
        msg = "You cannot create a teleport on top of a player."
    end
 
    if Tile(teleporter):getTopDownItem() then
        msg = "You cannot create a teleport on top of an item."
    end
   
    if not msg then
        msg = "Teleport created to cordinates: {X: "..split[1].." Y: "..split[2].." Z: "..split[3].."}."
        doCreateTeleport(1387, {x = split[1], y = split[2], z = split[3]}, teleporter)
    end
   
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, msg)
    return false
end
 
OP
OP
Itutorial

Itutorial

Excellent OT User
Joined
Dec 23, 2014
Messages
1,974
Solutions
52
Reaction score
673
Mines better though

Code:
local msg = nil

why?
 

tim26

New Member
Joined
Aug 12, 2008
Messages
532
Reaction score
2
Location
Poland
Can u make it like some rune or item/crystal when u used it then crfeate portal to some x, y
 
OP
OP
Itutorial

Itutorial

Excellent OT User
Joined
Dec 23, 2014
Messages
1,974
Solutions
52
Reaction score
673
Im not sure you might be able to change 1387 to the itemid you want it to look like in this part:

Code:
doCreateTeleport(1387, {x = split[1], y = split[2], z = split[3]}, teleporter)
 
Top