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

Lua [TFS1.3] /goto {x = 1420, y = 1911, z = 4}

srunobantana

Member
Joined
Oct 24, 2021
Messages
43
Reaction score
19
Could someone provide a talkactions action so I can teleport to positions using the following format? Example:/goto {x = 1420, y = 1911, z = 4}
 
LUA:
local talkAction = TalkAction("!gotonew")

function talkAction.onSay(player, words, param, type)
    if player:getAccountType() <= ACCOUNT_TYPE_SENIORTUTOR then
        return true
    end
    local x, y, z = param:match("x = (%d+), y = (%d+), z = (%d+)")
    player:teleportTo(Position(x, y, z))
    return false
end

talkAction:separator(" ")
talkAction:register()
 
Apologies for the delay in responding. To provide a reply, I need to open Google Translate and compose the message, but I couldn't find the time. Additionally, the code did not work as intended.
@srunobantana Atleast say something like it's working or like the comment instead of ignoring lol
People help you for free and you just ignore them
 
Try this code is from otserver global (scripts/talkactions):

LUA:
local position = TalkAction("/pos", "!pos")

function position.onSay(player, words, param)

    if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then
        return true
    end

    local param = string.gsub(param, "%s+", "")
    local position = player:getPosition()
    local tile = load("return "..param)()
    local split = param:split(",")
    if type(tile) == "table" and tile.x and tile.y and tile.z then
        player:teleportTo(Position(tile.x, tile.y, tile.z))
    elseif split and param ~= "" then
        player:teleportTo(Position(split[1], split[2], split[3]))
    elseif param == "" then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your current position is: \z
        " .. position.x .. ", " .. position.y .. ", " .. position.z .. ".")
    end
    return false
end

position:separator(" ")
position:register()

If works, use comands: /pos or !pos and Params: x, y, z or {x=pos.x, y=pos.y, z=pos.z}

Ex: !pos {x=32202, y=32300, z=7} or !pos 32202, 32300, 7
Ex: /pos {x=32202, y=32300, z=7} or /pos 32202, 32300, 7

Note: If you use brackets "{}" you need to put numbers after axes(x,y,z) exactly as in the example above.
 
Try this code is from otserver global (scripts/talkactions):

LUA:
local position = TalkAction("/pos", "!pos")

function position.onSay(player, words, param)

    if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then
        return true
    end

    local param = string.gsub(param, "%s+", "")
    local position = player:getPosition()
    local tile = load("return "..param)()
    local split = param:split(",")
    if type(tile) == "table" and tile.x and tile.y and tile.z then
        player:teleportTo(Position(tile.x, tile.y, tile.z))
    elseif split and param ~= "" then
        player:teleportTo(Position(split[1], split[2], split[3]))
    elseif param == "" then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your current position is: \z
        " .. position.x .. ", " .. position.y .. ", " .. position.z .. ".")
    end
    return false
end

position:separator(" ")
position:register()

If works, use comands: /pos or !pos and Params: x, y, z or {x=pos.x, y=pos.y, z=pos.z}

Ex: !pos {x=32202, y=32300, z=7} or !pos 32202, 32300, 7
Ex: /pos {x=32202, y=32300, z=7} or /pos 32202, 32300, 7

Note: If you use brackets "{}" you need to put numbers after axes(x,y,z) exactly as in the example above.
LUA:
Lua Script Error: [Test Interface]
data/talkactions/scripts/pos.lua
LuaScriptInterface::luaCreateTalkaction(). TalkActions can only be registered in the Scripts interface.
stack traceback:
        [C]: in function 'TalkAction'
        data/talkactions/scripts/pos.lua:1: in main chunk

Lua Script Error: [Test Interface]
data/talkactions/scripts/pos.lua
data/talkactions/scripts/pos.lua:3: attempt to index local 'position' (a nil value)
stack traceback:
        [C]: in function '__newindex'
        data/talkactions/scripts/pos.lua:3: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/pos.lua


There was also an error. I attempted alternative approaches, but it seems that TFS 1.3 does not recognize the existence of teleportation by position.
 
Você provavelmente está usando a base TFS 1.3 do MovieBR, certo? Esse script existe desde a 1.3... Por que você não verificou isso? Eu testei no meu 1.3, e tudo está funcionando bem. oo
I am not familiar with MovieBR. I use the repository GitHub - OTCv8/forgottenserver: A free and open-source MMORPG server emulator written in C++, compatible with OTClientV8 (https://github.com/OTCv8/forgottenserver), but I am still encountering some errors. Perhaps the TFS 1.3 version of OTCLIENTV8 may not be the best option.


LUA:
Lua Script Error: [Test Interface]
data/talkactions/scripts/pos.lua
LuaScriptInterface::luaCreateTalkaction(). TalkActions can only be registered in the Scripts interface.
stack traceback:
        [C]: in function 'TalkAction'
        data/talkactions/scripts/pos.lua:1: in main chunk

Lua Script Error: [Test Interface]
data/talkactions/scripts/pos.lua
data/talkactions/scripts/pos.lua:3: attempt to index local 'talk' (a nil value)
stack traceback:
        [C]: in function '__newindex'
        data/talkactions/scripts/pos.lua:3: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/pos.lua
 
Hey, TFS 1.3 is very outdated, but you're using version 10.98, right? Why didn't you choose TFS 1.4.2, which is more updated? Or better yet, you could use the BlackTek base, which is also version 10.98. It's more up-to-date and still being developed, making it ideal for DBO, NTO, Pokémon, and similar projects.


TFS 1.4.2 1098

Black tek 1098

So, I took Marko's script and adjusted some functions.

If the error persists, it seems your 1.3 base, although more updated, doesn't fully support RevScript. I recommend trying without RevScript—just use the direct path data/talkaction/filename.lua and test it. It should work.

data/talkactions/scripts/pos.lua
LUA:
function onSay(player, words, param, type)
    if player:getAccountType() <= ACCOUNT_TYPE_SENIORTUTOR then
        return true
    end

    if param == "" then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Usage: !gotonew 1000 1000 7")
        return false
    end

    local x, y, z = param:match("(%d+)%s+(%d+)%s+(%d+)")

    if not x or not y or not z then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Invalid coordinates. Usage: !gotonew 1000 1000 7")
        return false
    end

    x = tonumber(x)
    y = tonumber(y)
    z = tonumber(z)

    local position = Position(x, y, z)
    if player:teleportTo(position) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("Teleported to: %d %d %d", x, y, z))
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Unable to teleport to this position.")
    end

    return false
end
Post automatically merged:

data/talkactions/scripts/pos.lua:3: attempt to index local 'talk' (a nil value)
Now let me explain: you took the script, which is a RevScript, and placed it directly in data/talkaction/filename, and that’s why it gave an error. That’s why Marko and someone else mentioned it’s a RevScript. You should have some understanding before testing. It’s good for you to know how RevScript works. So, I posted the latest script, which is a regular talkaction and not a RevScript.


 
Last edited:
Hey, TFS 1.3 is very outdated, but you're using version 10.98, right? Why didn't you choose TFS 1.4.2, which is more updated? Or better yet, you could use the BlackTek base, which is also version 10.98. It's more up-to-date and still being developed, making it ideal for DBO, NTO, Pokémon, and similar projects.


TFS 1.4.2 1098

Black tek 1098

So, I took Marko's script and adjusted some functions.

If the error persists, it seems your 1.3 base, although more updated, doesn't fully support RevScript. I recommend trying without RevScript—just use the direct path data/talkaction/filename.lua and test it. It should work.

data/talkactions/scripts/pos.lua
LUA:
function onSay(player, words, param, type)
    if player:getAccountType() <= ACCOUNT_TYPE_SENIORTUTOR then
        return true
    end

    if param == "" then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Usage: !gotonew 1000 1000 7")
        return false
    end

    local x, y, z = param:match("(%d+)%s+(%d+)%s+(%d+)")

    if not x or not y or not z then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Invalid coordinates. Usage: !gotonew 1000 1000 7")
        return false
    end

    x = tonumber(x)
    y = tonumber(y)
    z = tonumber(z)

    local position = Position(x, y, z)
    if player:teleportTo(position) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("Teleported to: %d %d %d", x, y, z))
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Unable to teleport to this position.")
    end

    return false
end
Post automatically merged:


Now let me explain: you took the script, which is a RevScript, and placed it directly in data/talkaction/filename, and that’s why it gave an error. That’s why Marko and someone else mentioned it’s a RevScript. You should have some understanding before testing. It’s good for you to know how RevScript works. So, I posted the latest script, which is a regular talkaction and not a RevScript.


Thank you, my friend! I have always worked with TFS 0.4, and I am deeply grateful for your guidance. You are truly a kind person. I sincerely appreciate it! Everything is working perfectly now; you truly know how to help others.
Post automatically merged:

Hey, TFS 1.3 is very outdated, but you're using version 10.98, right? Why didn't you choose TFS 1.4.2, which is more updated? Or better yet, you could use the BlackTek base, which is also version 10.98. It's more up-to-date and still being developed, making it ideal for DBO, NTO, Pokémon, and similar projects.


TFS 1.4.2 1098

Black tek 1098

So, I took Marko's script and adjusted some functions.

If the error persists, it seems your 1.3 base, although more updated, doesn't fully support RevScript. I recommend trying without RevScript—just use the direct path data/talkaction/filename.lua and test it. It should work.

data/talkactions/scripts/pos.lua
LUA:
function onSay(player, words, param, type)
    if player:getAccountType() <= ACCOUNT_TYPE_SENIORTUTOR then
        return true
    end

    if param == "" then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Usage: !gotonew 1000 1000 7")
        return false
    end

    local x, y, z = param:match("(%d+)%s+(%d+)%s+(%d+)")

    if not x or not y or not z then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Invalid coordinates. Usage: !gotonew 1000 1000 7")
        return false
    end

    x = tonumber(x)
    y = tonumber(y)
    z = tonumber(z)

    local position = Position(x, y, z)
    if player:teleportTo(position) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("Teleported to: %d %d %d", x, y, z))
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Unable to teleport to this position.")
    end

    return false
end
Post automatically merged:


Now let me explain: you took the script, which is a RevScript, and placed it directly in data/talkaction/filename, and that’s why it gave an error. That’s why Marko and someone else mentioned it’s a RevScript. You should have some understanding before testing. It’s good for you to know how RevScript works. So, I posted the latest script, which is a regular talkaction and not a RevScript.


 
Last edited:
Thank you, my friend! I have always worked with TFS 0.4, and I am deeply grateful for your guidance. You are truly a kind person. I sincerely appreciate it! Everything is working perfectly now; you truly know how to help others.
Post automatically merged:


So, if the problem is solved, please upvote as the best answer so that others who are still looking for a solution can find it more easily.
 
Back
Top