• 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 [TFS 1.4.2] Help command /send nickname, x, y, z

darkangel1

New Member
Joined
Oct 31, 2023
Messages
53
Reaction score
4
I added the /send script, but when I start the server an error message pops up...
Lua:
local talk = TalkAction("/send", "!send")

function talk.onSay(player, words, param)
    if not player:getGroup():getAccess() then return true end
  local split = param:split(",")
  if split[4] then
    local p = Player(split[1])
    if p then
      p:teleportTo(Position(split[2], split[3], split[4]))
      p:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
  end
  return false
end

talk:separator(" ")
talk:register()
 

Attachments

I added the /send script, but when I start the server an error message pops up...
Lua:
local talk = TalkAction("/send", "!send")

function talk.onSay(player, words, param)
    if not player:getGroup():getAccess() then return true end
  local split = param:split(",")
  if split[4] then
    local p = Player(split[1])
    if p then
      p:teleportTo(Position(split[2], split[3], split[4]))
      p:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
  end
  return false
end

talk:separator(" ")
talk:register()
This is no ordinary talkaction; is a revscript. Just look at the code to understand immediately.
 
It looks like you are not using data/scripts and just importing code directly to talkaction, this quick code i wrote should do the job
Lua:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    local split = param:split(",")

    if #split == 4 then
        local target = Player(split[1])

        if target then
            local posX = split[2]
            local posY = split[3]
            local posZ = split[4]

            target:teleportTo(Position(posX, posY, posZ))
            target:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Teleported " .. target:getName() .. " to coordinates: " .. posX .. ", " .. posY .. ", " .. posZ)
          
            target:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have been teleported by " .. player:getName() .. " to coordinates: " .. posX .. ", " .. posY .. ", " .. posZ)
        end
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Invalid format. Please use: /teleport PLAYERNAME, X, Y, Z")
    end

    return false
end
 
Last edited:
Your script seems to be a rescript rather than a traditional talk action. Move it to the 'data/scripts' folder instead of 'data/talkactions/scripts' for it to work correctly. Adjust the code structure accordingly.
 
Back
Top