Hello, well here is a simple script. That people can use in their War Server. This will change map every 30 minutes, but you can decide for how long until it changes.
In globalevents/globalevents.xml, paste this line:
And now into globalevents/scripts and create new lua and name it "changeMap.lua" and paste the code below:
Now go into creaturescripts/scripts/login.lua and paste this before the return true:
Cheers.
In globalevents/globalevents.xml, paste this line:
Code:
<globalevent name="ChangeMap" interval="300000" script="changeMap.lua"/>
And now into globalevents/scripts and create new lua and name it "changeMap.lua" and paste the code below:
Code:
local config = {
townIds = {
[1] = "Thais",
[2] = "Carlin",
[3] = "Venore"
},
globalStorage = 100
}
function onThink(interval, lastExecution)
local players = Game.getPlayers()
if #players == 0 then
return true
end
Game.setStorageValue(config.globalStorage, math.max(1, Game.getStorageValue(config.globalStorage) or 1) + 1)
local towns = config.townIds[Game.getStorageValue(config.globalStorage)]
if not towns then
Game.setStorageValue(config.globalStorage, 1)
towns = config.townIds[Game.getStorageValue(config.globalStorage)]
end
local position, player = Town(Game.getStorageValue(config.globalStorage)):getTemplePosition()
for i = 1, #players do
player = players[i]
player:teleportTo(position)
player:addHealth(player:getMaxHealth())
player:addMana(player:getMaxMana())
player:sendTextMessage(MESSAGE_STATUS_WARNING, "The map has been changed to ".. towns .." and all players have been teleported to the respective temple. Next map change will be in 30 minutes!")
end
position:sendMagicEffect(CONST_ME_TELEPORT)
print("The map has been changed to ".. towns .." and all players have been teleported to the respective temple. Next map change will be in 30 minutes!")
return true
end
Now go into creaturescripts/scripts/login.lua and paste this before the return true:
Code:
local currentTown = Game.getStorageValue(100) or 1
if currentTown then
player:teleportTo(Town(currentTown):getTemplePosition())
end
Cheers.