• 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 An example of how implement World Changes

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
This is an example script that i made to implement world changes. This one will create NPC Yasir in Liberty Bay, Ankrahmun or Carlin (Note that the script will creates only the npc, not the whole ship). Also, this shows you how to change the position of Rashid, depending of the day.

The script sets a global storage when a change is made to make Towncryer alert about the change.

(The excessive tab is made by the forum, paste it at Notepad and you'll see it normal)
Lua:
function onStartup()
	--Mini world changes
	local changes =
	{
		--[id] = {storage = x, chance = %, change = function() doTheChange end}[,]
		{storage = 61260, chance = 25, change = function()  --Yasir 25%
													local random = math.random(1, 3)
													local cities =
													{
														[1] = {x = 33101, y = 32885, z = 6}, --ankrahmun
														[2] = {x = 32323, y = 32895, z = 6},-- liberty bay
														[3] = {x = 32400, y = 31815, z = 6} --carlin
													}
													return doCreateNpc("Yasir", cities[random]) 
												end}
	}
	for _, wc in ipairs(changes) do
		if math.random(1, 100) <= wc.chance then
			wc.change()
			doSetStorage(wc.storage, 1)
		end
	end
	
	--RASHID
	local days =
	{
		[1] = {x = 32328, y = 31782, z = 6}, --Sunday // Domingo
		[2] = {x = 32207, y = 31155, z = 7}, --Monday // Lunes
		[3] = {x = 32300, y = 32837, z = 7}, --Tuesday // Martes
		[4] = {x = 32577, y = 32753, z = 7}, --Wednesday // Miercoles
		[5] = {x = 33066, y = 32879, z = 6}, --Thursday // Jueves
		[6] = {x = 33235, y = 32483, z = 7}, --Friday // Viernes
		[7] = {x = 33166, y = 31810, z = 6} --Saturday // Sabado
	}
	
	local day = os.date("*t").wday
	if days[day] then
		doCreateNpc("Rashid", days[day])
	else
		print("[!] -> Cannot create Rashid. Day: " .. day .. ".")
	end
	return true
end

Enjoy
 
Creating base globalevent is easy. Problems start when you need to map from Lua level. But probably theses someone that had on idea that globalevents can be used to do this shit. I wonder if cip implemented globaleventlikething or they still use raid executing onstepin for things like that
 
Anyone knows how to make that "ship" and "yasir" spawns at same time , and next day he take his ship with him to the other positions... so the ship is with him, if hes in ankrahmun and leaves then ship removes too..
 
Back
Top