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

Solved /town "Town does not exists or has invalid temple position." - TFS 0.4 - 8.6

hanzoha

New Member
Joined
May 8, 2016
Messages
87
Reaction score
2
Hello guys.

I have problems with this God Command. The error is this... When I type "/town 1" , "/town Yalahar", "/town yalahar" it says:

"Town 1 does not exists or has invalid temple position." (same with Yalahar and yalahar) and yes, with other towns too.

I've search a lot about this problem in here and in different sources and the common solution to this, is that many people does not have the cities in the map file but this is not the case. My cities have the correct id and temple position.

I've checked my website, database and map and I just can't make it work.

Does someone had this problem before? Do you know what can I do to fix?

Thanks in advance!
 
If something doesn't work, you have to make it work :p
This is the script which the talkaction references, save this in
data/talkactions/scripts/teleporttown.lua
This is a modified version of it.
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
 
I just had this problem, a simple edit in teleporttown.lua fixed it

Lua:
change
local pos = getTownTemplePosition(tmp, false)

to
local pos = getTownTemplePosition(tmp)

In case any1 encounters the same issue :p
 
Back
Top