local conditions = {
CONDITION_POISON,
CONDITION_FIRE,
CONDITION_ENERGY,
CONDITION_CURSED,
CONDITION_DAZZLED
}
function onThink(interval, lastExecution)
local town = Game.getStorageValue(1000)
if town == 1 then
Game.setStorageValue(1000, 2)
elseif town == 2 then
Game.setStorageValue(1000, 3)
else
Game.setStorageValue(1000, 1)
end
for _, pid in ipairs(Game.getPlayers()) do
local player = Player(pid)
local town = Town(Game.getStorageValue(1000))
player:teleportTo(town:getTemplePosition())
player:removeCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
player:addHealth(player:getMaxHealth())
player:addMana(player:getMaxMana())
for i=1, #conditions do
Player(pid):removeCondition(conditions[i])
end
end
Game.broadcastMessage("Map has been changed! Next map change will be in 25 minutes!", MESSAGE_STATUS_WARNING)
db.query("UPDATE players SET town_id = ".. Game.getStorageValue(1000) ..", posx = 0, posy = 0, posz = 0;")
return true
end
function onLogin(cid)
local player = Player(cid)
local town = Town(Game.getStorageValue(1000))
player:setTown(town:getId())
player:teleportTo(player:getTown():getTemplePosition())
return true
end
where is declared new?Tested it out on my own server. Teleport back and forth between Thais, Venore and Kazordoon.
Everything seems to be working fine.
Globalevent:
Code:local conditions = { CONDITION_POISON, CONDITION_FIRE, CONDITION_ENERGY, CONDITION_CURSED, CONDITION_DAZZLED } function onThink(interval, lastExecution) local town = Game.getStorageValue(1000) if town == 1 then Game.setStorageValue(1000, 2) elseif town == 2 then Game.setStorageValue(1000, 3) else Game.setStorageValue(1000, 1) end for _, pid in ipairs(Game.getPlayers()) do local player = Player(pid) local town = Town(Game.getStorageValue(1000)) player:teleportTo(town:getTemplePosition()) player:removeCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) player:addHealth(player:getMaxHealth()) player:addMana(player:getMaxMana()) for i=1, #conditions do Player(pid):removeCondition(conditions[i]) end end Game.broadcastMessage("Map has been changed! Next map change will be in 25 minutes!", MESSAGE_STATUS_WARNING) db.query("UPDATE players SET town_id = ".. Game.getStorageValue(1000) ..", posx = 0, posy = 0, posz = 0;") return true end
Creaturescript:
Code:function onLogin(cid) local player = Player(cid) if new ~= nil then player:setTown(new) player:teleportTo(player:getTown():getTemplePosition()) else player:setTown(1) player:teleportTo(player:getTown():getTemplePosition()) end return true end
<globalevent name="MapChange" interval="100000" script="mapchange.lua"/>
<globalevent type="startup" name="MapStart" script="mapchange.lua"/>
local conditions = {
CONDITION_POISON,
CONDITION_FIRE,
CONDITION_ENERGY,
CONDITION_CURSED,
CONDITION_DAZZLED
}
function onThink(interval, lastExecution)
local town = Game.getStorageValue(1000)
if town == 1 then
Game.setStorageValue(1000, 2)
elseif town == 2 then
Game.setStorageValue(1000, 3)
else
Game.setStorageValue(1000, 1)
end
for _, pid in ipairs(Game.getPlayers()) do
local player = Player(pid)
local town = Town(Game.getStorageValue(1000))
player:teleportTo(town:getTemplePosition())
player:removeCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
player:addHealth(player:getMaxHealth())
player:addMana(player:getMaxMana())
for i=1, #conditions do
Player(pid):removeCondition(conditions[i])
end
end
Game.broadcastMessage("Map has been changed! Next map change will be in 25 minutes!", MESSAGE_STATUS_WARNING)
db.query("UPDATE players SET town_id = ".. Game.getStorageValue(1000) ..", posx = 0, posy = 0, posz = 0;")
return true
end
function onStartup()
Game.setStorageValue(1000, 3)
db.query("UPDATE players SET town_id = ".. Game.getStorageValue(1000) ..", posx = 0, posy = 0, posz = 0;")
end
function onLogin(cid)
local player = Player(cid)
player:setTown(Game.getStorageValue(1000))
player:teleportTo(player:getTown():getTemplePosition())
return true
end