• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction TFS 0.3.6 - 0.4 Town Teleport Fix

Codex NG

Recurrent Flamer
Joined
Jul 24, 2015
Messages
2,994
Solutions
12
Reaction score
1,657
Code:
local towns = { -- place the temple position of each town
    [{1, 'yalahar'}] = {x = 0, y = 0, z = 0},
    [{2, 'carlin'}] = {x = 0, y = 0, z = 0},
    [{3, 'thais'}] = {x = 0, y = 0, z = 0}
}

function getTowns(search)
    for town, templePosition in pairs(towns) do
        if isInArray(town, search) then
            return templePosition
        end
    end
    return nil
end

function onSay(cid, words, param, channel)
    if(param == '') then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local tid = cid
    local t = string.explode(param, ",")
    if(t[2]) then
        tid = getPlayerByNameWildcard(t[2])
        if(not tid or (isPlayerGhost(tid) and getPlayerGhostAccess(tid) > getPlayerGhostAccess(cid))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[2] .. " not found.")
            return true
        end
    end

    local tmp = t[1]
    if(not tonumber(tmp)) then
        tmp = getTownId(tmp)
        if(not tmp) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Town " .. t[1] .. " does not exists.")
            return true
        end
    end

    local pos = getTowns(tmp) --getTownTemplePosition(tmp, false)
    if(not pos or isInArray({pos.x, pos.y}, 0)) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Town " .. t[1] .. " does not exists or has invalid temple position.")
        return true
    end

    pos = getClosestFreeTile(tid, pos)
    if(not pos or isInArray({pos.x, pos.y}, 0)) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Destination not reachable.")
        return true
    end

    tmp = getCreaturePosition(tid)
    if(doTeleportThing(tid, pos, true) and not isPlayerGhost(tid)) then
        doSendMagicEffect(tmp, CONST_ME_POFF)
        doSendMagicEffect(pos, CONST_ME_TELEPORT)
    end

    return true
end
 
Back
Top