• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

[MOD] Advanced Map Changing

Syntax

Developer
Joined
Oct 10, 2007
Messages
2,890
Reaction score
458
Location
Texas
DESCRIPTION
Teleports all players that meet requirements to new temple, great for a pvpe server.
Tested on 0.4dev Private SVN (should work for latest public release)
Easy configuration
Uses new mod system for easy installation

Code:
[COLOR="Red"]<?[/COLOR][COLOR="Blue"]xml[/COLOR] [COLOR="red"]version[/COLOR]=[COLOR="DarkOrchid"]"1.0"[/COLOR] [COLOR="red"]encoding[/COLOR]=[COLOR="DarkOrchid"]"UTF-8"[/COLOR][COLOR="red"]?>[/COLOR]
[COLOR="blue"]<mod[/COLOR] [COLOR="red"]name[/COLOR]=[COLOR="DarkOrchid"]"Map Change"[/COLOR] [COLOR="red"]version[/COLOR]=[COLOR="DarkOrchid"]"2.0" [/COLOR][COLOR="red"]author[/COLOR]=[COLOR="DarkOrchid"]"Syntax"[/COLOR] [COLOR="red"]contact[/COLOR]=[COLOR="DarkOrchid"]"[email protected]"[/COLOR] [COLOR="red"]enabled[/COLOR]=[COLOR="DarkOrchid"]"yes"[/COLOR]>
   [COLOR="blue"]<description>[/COLOR]
        [B]This should teleport all players to a new random town in intervals.[/B]
   [COLOR="blue"]</description>[/COLOR]
	[COLOR="blue"]<config[/COLOR] [COLOR="Red"]name[/COLOR]=[COLOR="DarkOrchid"]"mapchange_config"[/COLOR][COLOR="blue"]>[/COLOR][COLOR="Orange"]<![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)
		}
 ]]>[/COLOR][COLOR="Blue"]</config>[/COLOR]
  [COLOR="blue"]   <event[/COLOR] [COLOR="Red"]type[/COLOR]=[COLOR="DarkOrchid"]"login"[/COLOR] [COLOR="red"]name[/COLOR]=[COLOR="DarkOrchid"]"Map Login" [/COLOR][COLOR="red"]event[/COLOR]=[COLOR="DarkOrchid"]"script"[/COLOR][COLOR="blue"]>[/COLOR][COLOR="Orange"]<![CDATA[
	loadmodlib('mapchange_config')
		function onLogin(cid)
			doPlayerSetTown(cid, getGlobalStorageValue(config.storage))
			doTeleportThing(cid, getPlayerMasterPos(cid))
		return true
		end
]]>[/COLOR][COLOR="blue"]</event>[/COLOR]
	[COLOR="blue"]<globalevent[/COLOR] [COLOR="Red"]name[/COLOR]=[COLOR="DarkOrchid"]"Map Change" [/COLOR][COLOR="red"]interval[/COLOR]=[COLOR="DarkOrchid"]"900" [/COLOR][COLOR="red"]event[/COLOR]=[COLOR="DarkOrchid"]"script"[/COLOR][COLOR="blue"]>[/COLOR][COLOR="Orange"]<![CDATA[
	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
]]>[/COLOR][COLOR="Blue"]</globalevent>
</mod>[/COLOR]
 
Last edited:
Thanks, some noob was saying I was a noob and didn't do anything so I decided to release some things for the fun of it.
 
is there a new mod system than 0.3.5pl1?
and how are the XML quotes?
 
Nah theres not, I'm just saying I haven't tested on the public release, I may have used a function that wasn't there or something.

And I color coded a text box to make reading easier.
 
i thought it was
XML:
 
nope, you gotta do it the long way, its not really worth it but I was bored.
 
i wonder why tala'n hasn't implemented it yet
 
Dunno, seems pretty important to have XML, its a pretty generic language. Ahwell. If you have any suggestions let me know, there is a more advanced version of this script im using for a war server, but I'm willing to addon any features anyone requests.
 
But when new player logins It logins in town 1 not in town where all other all playing...=/ could you fix that?
 
Thanks, its old and outdated though, made a much better system since.
 
Back
Top