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

Is this possible?

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
Hello!
Today I need a help.

It wanted to know if there is possible a script, in which an event or a quest is activated at every 3 hours (like the Blood Castle or Chaos Castle in Mu Online).

That at every 3 hours a npc is a respective place of the map, and that 20 minutes after the event I activate, the NPC eliminates.

So well I would conform to a script that at every 3 hours eliminates a wall in certain place of the map and 20 minutes later appear again.


Sorry My Bad English!
 
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)
	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("Event is open!")
	addEvent(removeWalls, 1000)
	return TRUE
end

I wouldnt mind a rep... yea, first time x)

//Probably small fix.
//Removed doubled message... -,-
 
Last edited:
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)
	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("Event is open!")
	addEvent(removeWalls, 1000)
	return TRUE
end

I wouldnt mind a rep... yea, first time x)

//Probably small fix.
//Removed doubled message... -,-


I tried out the script and this is what i got "[23/12/2010 07:16:47] [Error - GlobalEvent Interface]
[23/12/2010 07:16:47] In a timer event called from:
[23/12/2010 07:16:47] data/globalevents/scripts/event.lua:onThink
[23/12/2010 07:16:47] Description:
[23/12/2010 07:16:47] (luaDoRemoveItem) Item not found"

but rep++ for the script :)!
 
Do anyone know what i did wrong?:P,cause this script is really neat ^^

it is removing the walls but it is not placing the walls there again :/


:Edit: It's working as it should now :),i changed the time so it would remove and add the walls faster,but i don't know where i should change the time cause each 3th minute it removes the walls,then 3 minutes after that it sets the walls there again,but it removes them directly after again :P


:Last Edit: Well ive figured out everything now,it works perfect :D,but i just wonder why it keeps giving me this error in console "[23/12/2010 09:34:57] [Error - GlobalEvent Interface]
[23/12/2010 09:34:57] In a timer event called from:
[23/12/2010 09:34:57] data/globalevents/scripts/event.lua:onThink
[23/12/2010 09:34:57] Description:
[23/12/2010 09:34:57] (luaDoRemoveItem) Item not found"
 
Last edited:
Back
Top