• 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!

GlobalEvent [MOD] Map Changing

Syntax

Developer
Joined
Oct 10, 2007
Messages
2,890
Reaction score
458
Location
Texas
Ok on request I made this, its in mod form and it has been tested with two different temples. Basically it picks a random Town ID from the config list and changes everyone above the access in config to that position and town. Great for war servers, but probably needs to be modified to fit two teams. Only supports all players atm.

Checks if random number is in array (so towns dont have to be in order and there can be gaps between towns...EX: 1,4,5)

Checks if the random number was the same as last time, and tries again if it is. So you never play the same town twice.

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} --townids to teleport to.
		}
 ]]>[/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[
	function onLogin(cid)
		doPlayerSetTown(cid, getGlobalStorageValue(3454))
		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"]"10" [/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(3454) and isInArray(config.temples, RDM)
			for _, pid in ipairs(getPlayersOnline()) do
				if getPlayerAccess(pid) < config.access 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) - getCreatureMana(pid)))
					doRemoveConditions(pid, FALSE)
					setGlobalStorageValue(3454, config.temples[RDM])
				end
			end
		return true
		end
]]>[/COLOR][COLOR="Blue"]</globalevent>
</mod>[/COLOR]

Enjoy, I tested and it works with 2 maps set, so it should work with all. This is just basic map switching, you need to put the messages and other stuff in yourself, or ill post a better version later. Enjoy, oh and btw it took alot to make syntax coloring in that code box, so better rep++ me ;p
\
 
Last edited:
Hello. Nice to see! One question more only :/ Shall i put all this code into globalevents/scripts? Then make like <globalevent name="map change" interval="300" script="mapchange.lua"/> into globalevents.xml? If so i got an error in the console.. Sry for asking so much question. Im new at this :p. Repped u++ will donate to ur paypal aswell. Thanks much mate!


Edit: The money has been sent!
 
Actually no you just need to either make a file named

mapchange.xml in your mods folder
or download the zip file from my website and unzip the .xml file and paste in your mods folder.

Your mods folder should be in the same place as your config.lua

This is for TFS 0.3.5 only. and thankyou for donating
 
Man, U f******king pwn. Works like a charm!!!!!!!!!!!!! Thanks really :)

Edit: Aff a bug.. If u log in after mapchange, u will be on the old map and the other players will be on the changed ;/
 
oh ok, ill fix that at once, didn't think it all through. ^.^ ill post soon with update
 
updated and tested. Works, also fixed another bug with it not working with more than one player. should all work now.
 
Not working now. When i try login i get kicked instantly. And much error goes in the console :S

armadillo logged in.
Lua script error: [creatureScript interface]
buffer:eek:nLogin

attempt to index a boolean value
stack traceback:
[c]: in function 'doteleportthing'
[string "loadBuffer"]:3: in function <[string "loadBuffer"]:1>
armadillo logged out.

edit: i have write this down from the console.
 
make sure you restarted TFS fully, not just reloaded mods. if that aint it ill see
 
hmm.. it works in the server im testing it on. I did have that error before though. But I thought I fixed it...
 
tripled checked, and compared but heres the exact file im using
mapchange.xml

edit: test it at this ip 64.234.94.96
 
aww, not working for me :( Thanks anyway mate. Dont know why it worked with the old one but not with this :/ Will try find another solution
 
its the login script for some reason, but ill make it work dont worry :) but hardest script to fix is the one that works lol.
 
try the first post script again. Updated it.

going to bed, fix tomorrow if it dont work
 
Last edited:
You colored the code box? Why didnt you just use [lua] [/code] instead of [code] [/code] or [php] [/php] :p That way it would automatically color the code.

ontopic, thanks for your share. :)
 
because i colored it xml syntax colors ;p the way mods are colored. ;p
 
Back
Top