Why this script not working?
/town cityname
04:03 Town carlin does not exists or has invalid temple position.
/town cityname
04:03 Town carlin does not exists or has invalid temple position.
Code:
function onSay(cid, words, param, channel)
if(param == '') then
local str = ""
for i, town in ipairs(getTownList()) do
str = str .. town.name .. "\n"
end
doShowTextDialog(cid, 2160, str)
return true
end
local t = string.explode(param, ",")
local pos = 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