• 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 Event... for TFS 0.3.

EvulMastah

๏̯͡๏﴿
Premium User
Joined
Aug 19, 2007
Messages
4,941
Solutions
11
Reaction score
352
Hi.
It was requested by darkhaos here. You can see what it is about.

data/globalevents/globalevents.xml:
Code:
	<globalevent name="event" interval="10800" script="event.lua"/> <!-- 3 hours -->

data/globalevents/scripts/event.lua:
Code:
local timeToCreate = 20 -- minutes
local walls = {
	{ x = 229, y = 562, z = 6, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE },
	{ x = 230, y = 562, z = 6, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE }
}

function removeWalls(item, position)
	doBroadcastMessage("Event is open!")
	addEvent(createWalls, timeToCreate * 1000 * 60)
	for i = 1, table.maxn(walls) do
		doRemoveItem(getThingfromPos(walls[i]).uid)
		doSendMagicEffect(walls[i], CONST_ME_MAGIC_RED)
	end
	return TRUE
end

function createWalls(item, position)
	for i = 1,table.maxn(walls) do
		doCreateItem(1039, 1, walls[i])
		doSendMagicEffect(walls[i], CONST_ME_MAGIC_GREEN)
	end
	return TRUE
end

function onThink(interval, lastExecution)
	doBroadcastMessage("Next event in 3 hours.")
	addEvent(removeWalls, 1000)
	return TRUE
end

Improved Elfs version:
Code:
local config = {
	timeToCreate = 20 * 60 * 1000
}
local walls = {
	{ x = 229, y = 562, z = 6, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE },
	{ x = 230, y = 562, z = 6, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE }
}

local function doRemoveWalls()
	addEvent(doCreateWalls, config.timeToCreate)
	for i = 1, table.maxn(walls) do
		local tmp = getThingFromPos(walls[i])
		if(tmp.itemid > 0) then
			doRemoveItem(tmp.uid)
			doSendMagicEffect(walls[i], CONST_ME_MAGIC_GREEN)
		end
	end
end

local function doCreateWalls()
	for i = 1, table.maxn(walls) do
		doCreateItem(1039, 1, walls[i])
		doSendMagicEffect(walls[i], CONST_ME_MAGIC_RED)
	end
end

function onThink(interval, lastExecution)
	doBroadcastMessage("Event is open!")
	addEvent(doRemoveWalls, 1000)
	return TRUE
end

Have fun... :O!!!
 
Last edited:
Help me Marcinek Paladinek... i'm using TFS v0.3 (patch 18) and this patch don't have the folder globalevents =S!

What can i do?

Download the lastest version of TFS or what?

Sorry my bad english!
 
That is a cool event. I would like to know what kind of ideas i can use it?
 
Nice, but how to make NPC spawn instead of wall? And after event NPC is deleted..
 
and if i wanna make other item, not a wall?
Code:
local config = {
        Wallid = XXXX
	timeToCreate = 20 * 60 * 1000
}
local walls = {
	{ x = 229, y = 562, z = 6, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE },
	{ x = 230, y = 562, z = 6, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE }
}

local function doRemoveWalls()
	addEvent(doCreateWalls, config.timeToCreate)
	for i = 1, table.maxn(walls) do
		local tmp = getThingFromPos(walls[i])
		if(tmp.itemid > 0) then
			doRemoveItem(tmp.uid)
			doSendMagicEffect(walls[i], CONST_ME_MAGIC_GREEN)
		end
	end
end

local function doCreateWalls()
	for i = 1, table.maxn(walls) do
		doCreateItem(config.Wallid, 1, walls[i])
		doSendMagicEffect(walls[i], CONST_ME_MAGIC_RED)
	end
end

function onThink(interval, lastExecution)
	doBroadcastMessage("Event is open!")
	addEvent(doRemoveWalls, 1000)
	return TRUE
end

It will works?
and
Sorry for my english.. :)
 
In my opnion, I must say about the script is helpful. for what it is use and your action when used.

/Bye
 
i need one when the event starts after 5minutes it makes a wall back :(


Sorry for my bad english..
 
Code:
21/06/2009 00:58:54] > Broadcasted message: "Event is open!".

[21/06/2009 00:58:55] Lua Script Error: [GlobalEvent Interface] 
[21/06/2009 00:58:55] in a timer event called from: 
[21/06/2009 00:58:55] data/globalevents/scripts/event.lua:onThink

[21/06/2009 00:58:55] luaDoRemoveItem(). Item not found



my error :( when the event's open..

can u guys make a capture the flag script?
 
Rudolf Czarodziej can you make event that will create a teleport? and xx players can enter :>
 
How to me use this to SUMMON monster, but after xxxx time remove monster if dont killed????
 
Back
Top