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

How to register/add new talkaction script tfs 1.3

DreadShi

Member
Joined
May 18, 2019
Messages
180
Reaction score
7
I tried to add new talkaction script using the normal methods like a talkaction line to put in talkaction.xml and a talkaction script which is a lua file
i downloaded a map which does not contain talakction.xml , it has actually but empty and seems it works like this local talk = TalkAction("/n") and it must be added in same lua script , i tried to configure this addtp script but not working without any console errors

tfs 1.3
10.100


Code:
local talk = TalkAction("/addtp")

function comparePosition(pos1, pos2)
    return (pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z) and true or false
end

local position = false
function onSay(cid, words, param, channel)
    local pos,c = getCreatureLookPosition(cid),position
    if param == "clear" then
        position = false
        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Clear.")
    end
    if not(position) or not(comparePosition(position,pos)) then
        if position == false then
            position = pos
            return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, string.format("The teleporter's position was set. [X: %i, Y: %i, Z: %i]",pos.x, pos.y, pos.z)) and doSendMagicEffect(pos, 14)
        end
        position = false
        return  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, string.format("The teleporter was set up. From:[X: %i, Y: %i, Z: %i] To:[X: %i, Y: %i, Z: %i]",c.x, c.y, c.z, pos.x, pos.y, pos.z)) and doSendMagicEffect(pos, 14) and doCreateTeleport(1387, pos, c)
    end
    return    doPlayerSendCancel(cid,"The teleport position can't be the position where the teleporter is.")
end

talk:separator(" ")
talk:register()
 
Make a new lua file in data/scripts/ and then put the script in the file /reload scripts or restart the server and it'll work.
EDIT:
Lua:
local talk = TalkAction("/addtp")

talk.onSay = function(player, words, param, channel)
    local split = param:split(",")
    local destination = Position(split[1], split[2], split[3])
    local lookDir = player:getDirection()
    local nextPos = player:getPosition():getNextPosition(lookDir, 1)

    if nextPos then
        if nextPos ~= destination then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, string.format("The teleporter was set up. From:[X: %i, Y: %i, Z: %i] To:[X: %i, Y: %i, Z: %i]",nextPos.x, nextPos.y, nextPos.z, destination.x, destination.y, destination.z))
            destination:sendMagicEffect(14)
            doCreateTeleport(1387, nextPos, destination)
        else
            player:sendCancelMessage("The teleport position can't be the position where the teleporter is.")
        end
    end
    return false
end

talk:separator(" ")
talk:register()
/addtp 100,100,7
 
Last edited:
Make a new lua file in data/scripts/ and then put the script in the file /reload scripts or restart the server and it'll work.
EDIT:
Lua:
local talk = TalkAction("/addtp")

talk.onSay = function(player, words, param, channel)
    local split = param:split(",")
    local destination = Position(split[1], split[2], split[3])
    local lookDir = player:getDirection()
    local nextPos = player:getPosition():getNextPosition(lookDir, 1)

    if nextPos then
        if nextPos ~= destination then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, string.format("The teleporter was set up. From:[X: %i, Y: %i, Z: %i] To:[X: %i, Y: %i, Z: %i]",nextPos.x, nextPos.y, nextPos.z, destination.x, destination.y, destination.z))
            destination:sendMagicEffect(14)
            doCreateTeleport(1387, nextPos, destination)
        else
            player:sendCancelMessage("The teleport position can't be the position where the teleporter is.")
        end
    end
    return false
end

talk:separator(" ")
talk:register()
/addtp 100,100,7
Not working for me.
TFS 1.3 OTServBR Project
 
Back
Top