Phemus
Member
- Joined
- Jun 16, 2012
- Messages
- 150
- Solutions
- 2
- Reaction score
- 13
Hello! I was working on a script for a friend where the map has to change on a certain time, but if someone is doing a quest, they don't get teleported to the new town.
Here is the script:
How this has to work is that if a player is doing a quest, they don't get teleported to the new town. In other words, if the player is inside of the are of fromPos toPos they can't get telepoted.
However, I don't think the script is right. I get this error:

I hope you understand and someone can help me. Thank you and sorry for my bad english.
Here is the script:
PHP:
local config, new = {
minTownId = 1,
maxTownId = 3
}, 0
local t = {
fromPos = {x = 1004, y = 1023, z = 7},
toPos = {x = 1015, y = 1032, z = 7}
}
function onThink(interval, lastExecution)
for _, pid in ipairs(getPlayersOnline()) do
local town = getPlayerTown(pid)
new = town < config.maxTownId and town + 1 or config.minTownId
doPlayerSetTown(pid, new)
doTeleportThing(pid, getTownTemplePosition(new))
doRemoveConditions(pid)
doCreatureAddHealth(pid, getCreatureMaxHealth(pid))
doCreatureAddMana(pid, getCreatureMaxMana(pid))
doBroadcastMessage("Map has been changed! Next map change will be in 25 minutes!", MESSAGE_STATUS_WARNING)
elseif isInRange(getThingPos(cid), t.fromPos, t.toPos) then
db.executeQuery("UPDATE players SET town_id = ".. new ..", posx = 0, posy = 0, posz = 0;")
end
db.executeQuery("UPDATE players SET town_id = ".. new ..", posx = 0, posy = 0, posz = 0;")
return true
end
How this has to work is that if a player is doing a quest, they don't get teleported to the new town. In other words, if the player is inside of the are of fromPos toPos they can't get telepoted.
However, I don't think the script is right. I get this error:

I hope you understand and someone can help me. Thank you and sorry for my bad english.