LucasFerraz
Systems Analyst
Thank you to Bogart for sharing this script.
or in globalevents
Recent solution:
[MOD] Map Change (for war servers)
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Map Change" version="2.0" author="Syntax" contact="otland.net" enabled="yes">
<description>
This should teleport all players to a new random town in intervals.
</description>
<config name="mapchange_config"><![CDATA[
config = {
access = 10, -- minimum access to bypass teleportation.
temples = {1,2,3} --townids to teleport to.
}
]]></config>
<event type="login" name="Map Login" event="script"><![CDATA[
function onLogin(cid)
doPlayerSetTown(cid, getGlobalStorageValue(3454))
doTeleportThing(cid, getPlayerMasterPos(cid))
return true
end
]]></event>
<globalevent name="Map Change" interval="1500000" event="script"><![CDATA[
domodlib('mapchange_config')
function onThink(interval, lastExecution, thinkInterval)
repeat
RDM = math.random(1,#config.temples)
until RDM ~= getGlobalStorageValue(3454) and isInArray(config.temples, RDM)
for _, pid in ipairs(getPlayersOnline()) do
if getPlayerAccess(pid) < config.access and
doPlayerSetTown(pid, config.temples[RDM])
doTeleportThing(pid, getTownTemplePosition(config.temples[RDM]), false)
doSendMagicEffect(getCreaturePosition(pid), 37)
doRemoveCondition(pid, CONDITION_INFIGHT)
doCreatureAddHealth(pid, getCreatureMaxHealth(pid))
doCreatureAddMana(pid, (getCreatureMaxMana(pid) - getCreatureMana(pid)))
doBroadcastMessage("Map has been changed! Next map change will be in 25 minutes!", MESSAGE_STATUS_WARNING)
setGlobalStorageValue(3454, config.temples[RDM])
end
end
return true
end
]]></globalevent>
</mod>
or in globalevents
XML:
<globalevent name="changemap" interval="1500000" event="script" value="changemap.lua"/>
Lua:
local config, new = {
minTownId = 1,
maxTownId = 3
}, 0
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)
end
db.executeQuery("UPDATE players SET town_id = ".. new ..", posx = 0, posy = 0, posz = 0;")
return true
end
Recent solution:
[MOD] Map Change (for war servers)
Last edited: