• 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 Move players to temple after update

zakius

Enter the Ninja!
Joined
Apr 30, 2009
Messages
2,635
Reaction score
65
Location
with Taiga
It was requested few times, so I post it

if you have not edited your start.lua replace it with this one
Code:
dofile("config.lua")
function onStartup()
	db.executeQuery("UPDATE `players` SET `online` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
	if (updated) then
		db.executeQuery("UPDATE `players` SET `posx` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
		db.executeQuery("UPDATE `players` SET `posy` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
		db.executeQuery("UPDATE `players` SET `posz` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
		local f = io.open('config.lua','r')
		if f then
			local str = f:read(-1)
			f:close()
			local ae = string.match(str,"updated=true(.+)")
			if ae then
				file = 'updated=false'..ae 
				local f = io.open('config.lua','w')
				if f then
					f:write(file)
					f:close()
				end
			end
		end      
	end
	return true
end

if you edited it, put
Code:
dofile("config.lua")
in first line of it
and
Code:
if (updated) then
		db.executeQuery("UPDATE `players` SET `posx` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
		db.executeQuery("UPDATE `players` SET `posy` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
		db.executeQuery("UPDATE `players` SET `posz` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
		local f = io.open('config.lua','r')
		if f then
			local str = f:read(-1)
			f:close()
			local ae = string.match(str,"updated=true(.+)")
			if ae then
				file = 'updated=false'..ae 
				local f = io.open('config.lua','w')
				if f then
					f:write(file)
					f:close()
				end
			end
		end      
	end
before return true


and in both cases add in the begining of your config lua

Code:
updated=false

and if you want to send players to temples change updated=false to updatet=true and start server
players will login in hometown temples and script will change updated back to false

EDIt: lol, sth got crazy now, w8 until I'll fix it

ok, fixed
 
Last edited:
This script will take no vocation to the main ^ ^

should move to a town player id
 
if pos is 0,0,0 player logs in inhometown temple, I tested it
just no vocation have to be citizen of rook like city(its normal, if its not like that dead will send char to main too)
 
Nice man, I always do query, but that'd be way nicer, I'll test it later, if it's not fixed yet, I'll try to help.
 
With query you can do it with pressing one button. If you want to change the pos with this, you gotta dig in your scripts, change it, save, reload it, and then restart server. I think with query its a lot faster, but nice job anyway ;)
 
umm, change config.lua, start serv(after map update its normal that u have t start serv...) and its done, config is back to normal after executing it, also I wonder if its possible to get modification date of file in lua, to make it 100% auto :D
 
Back
Top