• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Server AutoChange Map? Possible?

Eldin

Eldin Projects
Joined
Jun 12, 2008
Messages
1,334
Reaction score
615
Location
Sweden
Greets!

This has been spoked of alot of times before, and I might be at the wrong section, kinda uhm. ;)
I did also try to search but found no answers.

So...
Is it possible to make the Server AutoChange the WorldMap every X Minutes/Hours at "Simple" LUA/Scripting?
1-2 of my ideas would need this to work perfectly. One is about "Fast" Seasons and one is for War Maps.
How about the Spawns then? Everyone would need to be "teleported" to their hometown once this happens and
I guess it also requires an auto server restart/reload?

I hope I wont bury those ideas. ;)
Thank You for reading.

Kind Regards,
Eldin.
 
Nice idea Diath, sounds kinda simple compared to my idea, could be a way!
Would it then set a new temple position for every player at X minutes? Online players aswell as they're not online?
A "new" world on the map would require a new temple position if it changes.

/Eldin
 
And honestly, I don't know how to do that, been away for some time from OT.
But i like the idea, got any links for scripts like that? I'll start searching.

/Eldin
 
I mean, you could just have a large map. Say The size of real tibia. 32,000x32,000 Then make each continent a storage value to hold each players current position. After your amount of time that passes, it teleports you to that exact spot on a new continent, with different season. And you can have the same temple and everything with different coords. Like each season that changes would give you the different temple.

For example, if thais (spring) coords were x-15000, y-15000, z-7 and the thais (fall) coords were x25000y25000z7 then you would just have their temple position as a storage and change along with their map position. It'd be some hard work but it would be a flawless system if done correctly.
 
I mean, you could just have a large map. Say The size of real tibia. 32,000x32,000 Then make each continent a storage value to hold each players current position. After your amount of time that passes, it teleports you to that exact spot on a new continent, with different season. And you can have the same temple and everything with different coords. Like each season that changes would give you the different temple.

For example, if thais (spring) coords were x-15000, y-15000, z-7 and the thais (fall) coords were x25000y25000z7 then you would just have their temple position as a storage and change along with their map position. It'd be some hard work but it would be a flawless system if done correctly.
Maybe like
LUA:
local t = {
	thais1(x250000y25000z7)= 3000, -- (global storage)
	thais2(x500000y25000z7) = 3001,
	thais3(x750000y25000z7) = 3002,
	m = .x+25000
}
function onThink(interval, lastExecution, thinkInterval)
	for _, pid in ipairs(getPlayersOnline()) do
		if getGlobalStorageValue(t.thais1) == 1 then
		doTeleportThing(pid, (getCreaturePosition(pid)t.m))
		setGlobalStorageValue(t.thais1, -1)
		setGlobalStorageValue(t.thais2, 1)
		doPlayerSetTown(pid, t.thais2)
			elseif getGlobalStorageValue(t.thais2) == 1 then
				setGlobalStorageValue(t.thais2, -1)
				setGlobalStorageValue(t.thais3, 1)
				doPlayerSetTown(pid, t.thais3)
				doTeleportThing(pid, (getCreaturePosition(pid)t.m))
				elseif getGlobalStorage(t.thais3) == 1 then
					setGlobalStorageValue(t.thais3, -1)
					setGlobalStorageValue(t.thais1, 1)
					doPlayerSetTown(pid, t.thais1)
					doTeleportThing(pid, (getCreaturePosition(pid).x-500000)
		end
	end
return TRUE
end
etc, don't really know if .x*2 or 3 will work.
 
Last edited:
No I mean like you could localize their temples, but you would need to change their temple spawn when the map switches. And you could just summon them all to their respective temples when the seasons changed You would just need to be able to get their temples as it is, and then change it when the seasons change.
 
No I mean like you could localize their temples, but you would need to change their temple spawn when the map switches. And you could just summon them all to their respective temples when the seasons changed You would just need to be able to get their temples as it is, and then change it when the seasons change.

hmm, but I'm trying to do it as Diath's first post idea.

Forgot I was quoting you tho.
 
Code:
local towns = {
	[id] = Position(x, y, z)
}

function onLogin(cid)
	local v = getStorage(1234)
	doTeleportThing(cid, towns[v])
	doPlayerSetTown(cid, v)
	return true
end

Code:
local towns = {
	[id] = Position(x, y, z)
}

function onThink(interval)
	local v = getStorage(1234) + 1
	if v > #towns then
		v = 1
	end
	setStorage(1234, v)

	for _, p in pairs(getPlayersOnline()) do
		doTeleportThing(cid, towns[v])
		doPlayerSetTown(cid, v)
	end
	return true
end

It is for 0.4, if you are running older TFS replace Position() function with normal table ({ x = x , y = y, z = z}).
 
globalevent:
LUA:
local towns = {1,2,3,4,5} --here you put the id of towns
function onThink(interval, lastExecution, thinkInterval)
	local ids = {}
	local st = math.random (#towns)
	local town = towns[st]
	local pos = getTownTemplePosition(town)
	local name = getTownName(town)
 
	for _, pid in ipairs (getPlayersOnline()) do
		local id = getPlayerGUID(pid)
		doPlayerSetTown(pid, town)
		doTeleportThing(pid, pos)
		doPlayerSendTextMessage(pid, 22, "The map it has been changed  to " ..name)
		doPlayerSendCancel(pid, id)
		table.insert(ids, id )
	end
 
	db.executeQuery("UPDATE `players` SET `town_id` ="..town.." where `id` NOT IN ("..table.concat(ids, ", ")..") ;") 
	return true
end

in creaturescripts/login.lua before return true put this line:
LUA:
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
 
Last edited:
@Jetro:
1. You do not define towns as local variable.
2. Instead of random element of an array you just pick random number between 1 and elements of the array.
3. You do not use constants for messages.
4. You execute query on all players while it is unecessary, execute it only on offline players.

Not that I whine, just pointing out your mistakes.
 
Code:
local towns = {
	[id] = Position(x, y, z)
}

function onLogin(cid)
	local v = getStorage(1234)
	doTeleportThing(cid, towns[v])
	doPlayerSetTown(cid, v)
	return true
end

It is for 0.4, if you are running older TFS replace Position() function with normal table ({ x = x , y = y, z = z}).

LUA:
local towns = {
	[id] = Position(x, y, z)
}

function onLogin(cid)
	local v,s = getStorage(1234),1234
	if getPlayerStorageValue(cid,s) ~= v then
		doTeleportThing(cid, towns[v])
		doPlayerSetTown(cid, v)
		setPlayerStorageValue(cid,s,v)
	end
	return true
end

so they can't relog and respawn at temple each time :)
 
LUA:
local towns = {
	[id] = Position(x, y, z)
}

function onLogin(cid)
	local v,s = getStorage(1234),1234
	if getPlayerStorageValue(cid,s) ~= v then
		doTeleportThing(cid, towns[v])
		doPlayerSetTown(cid, v)
		setPlayerStorageValue(cid,s,v)
	end
	return true
end

so they can't relog and respawn at temple each time :)

Stop making a fool of yourself, if the map changes, the global storage changes too but it won't affect players' storage, therefore your script won't work.
 
or you could do some smart mapping and relocate sector by sector (32x32 tiles each time?), say if you use seasons
Code:
if(season() == SEASON_WINTER)then
    x = x + 16000
else if(season() == SEASON_SPRING)then
    y = y + 16000
-- etc etc
end

I hope you get the point.
 
@Jetro:
1. You do not define towns as local variable.
2. Instead of random element of an array you just pick random number between 1 and elements of the array.
3. You do not use constants for messages.
4. You execute query on all players while it is unecessary, execute it only on offline players.

Not that I whine, just pointing out your mistakes.
thanks for the corrections, i just used that query for change the town of offline players, i know that it doesn't affect the online players, i used doPlayerSetTown for them.

edit: i have edited the query for exclude online players, i'm not sure if it is the correct way xD.
 
Last edited:
Stop making a fool of yourself, if the map changes, the global storage changes too but it won't affect players' storage, therefore your script won't work.

This was just for the login script, stop making a fool out of yourself, lmao.
Can't you read/understand scripts? if you don't understand how it works I'll explain it to you ;)
 
Back
Top