<?xml version="1.0" encoding="UTF-8"?>
<mod name="Map Change" version="2.0" author="Syntax" contact="[email protected]" enabled="yes">
<description>
This should teleport all players to a new random town in intervals.
</description>
<config name="mapchange_config"><![CDATA[
config = {
access = 3, -- minimum access to bypass teleportation.
temples = {1,2,5,3}, -- townids to teleport to.
storage = 3454, -- number to store map status in.
changetime = 900 -- time to change in seconds (change in globalevents too)
}
]]></config>
<event type="login" name="Map Login" event="script"><![CDATA[
domodlib('mapchange_config')
function onLogin(cid)
doPlayerSetTown(cid, getGlobalStorageValue(config.storage))
doTeleportThing(cid, getPlayerMasterPos(cid))
return true
end
]]></event>
[COLOR="Magenta"][B]<globalevent name="Map Change" interval="900" event="script"><![CDATA[[/B][/COLOR]
domodlib('mapchange_config')
function onThink(interval, lastExecution, thinkInterval)
repeat
RDM = math.random(1,#config.temples)
until RDM ~= getGlobalStorageValue(config.storage) and isInArray(config.temples, RDM)
if getWorldCreatures(0) > 0 then
for _, pid in ipairs(getPlayersOnline()) do
if getPlayerAccess(pid) < config.access and getPlayerAccountManager(pid) == MANAGER_NONE then
doPlayerSetTown(pid, config.temples[RDM])
doTeleportThing(pid, getTownTemplePosition(config.temples[RDM]), false)
doSendMagicEffect(getCreaturePosition(pid), 37)
doCreatureAddHealth(pid, getCreatureMaxHealth(pid))
doCreatureAddMana(pid, getCreatureMaxMana(pid))
doRemoveConditions(pid, FALSE)
end
doBroadcastMessage("Round over. Map switched to " ..getTownName(config.temples[RDM]).. ".", MESSAGE_EVENT_ADVANCE)
setGlobalStorageValue(config.storage, config.temples[RDM])
end
else
print ("[MAP] No players online, aborting map change!")
end
return true
end
]]></globalevent>
</mod>