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

[CreatureEvent]Remove MWall when killed Creature

Exotis

New Member
Joined
May 8, 2009
Messages
52
Reaction score
0
I just need a script that removes a magic wall when I killed a creature =/ thx
 
In this example, 4 walls will be removed with 2 seconds between them. (gives a nice visual effect)


Let's play with a lever and put it the UID 9999:
data \ actions \ actions.xml

Code:
<action uniqueid="9999" script="MagicWall.lua" />


in data\actions\scripts\MagicWall.lua

Code:
-- Removing walls with time (By Conde Sapo)

function onUse(cid, item, pos)

pausa = 2000 -- 2 sec.

-- wall positions - don't change stackpos.
wall0pos = {x=48, y=38, z=7, stackpos=1}
wall1pos = {x=50, y=38, z=7, stackpos=1}
wall2pos = {x=52, y=38, z=7, stackpos=1}
wall3pos = {x=54, y=38, z=7, stackpos=1}


if item.itemid == 1945 then
doTransformItem(item.uid,1946)
wall0 = getThingfromPos(wall0pos)
if wall0.itemid ~= 0 then
doRemoveItem(wall0.uid,1)
addEvent(wait1,pausa,wall1pos)
end
else
doTransformItem(item.uid,1945)
end
return 1
end

function wait1(wall1pos)
thing = getThingfromPos(wall1pos)
doRemoveItem(thing.uid,1)
addEvent(wait2,pausa,wall2pos)
end

function wait2(wall2pos)
thing = getThingfromPos(wall2pos)
doRemoveItem(thing.uid,1)
addEvent(wait3,pausa,wall3pos)
end

function wait3(wall3pos)
thing = getThingfromPos(wall3pos)
doRemoveItem(thing.uid,1)
-- if you want more walls , only keep adding addEvent's
end

How it works?

1 - pausa = 2000 (2 secs)
When we call an event, this parameter tells you what the waiting time until the event started running. (in our case 2 secs)
After those 2 secs, the event begins.

2 - addEvent (wait1, pause, wall1pos)
This is how you call an event
WAIT1 is the name of the event
PAUSE pause is explained above
WALL1POS is the variable that will be taken to the event.

WAIT1 the event is called (with waiting 2 secs) and takes the parameter WALL1POS (with the coordinates of the wall)

3 - function wait1 (wall1pos)
This is the event.

thing = getThingfromPos (wall1pos)
Here we take the "thing" that is in WALL1POS (in our case a wall)

I said "thing" because "getThingfromPos" means exactly "catch something of pos"

doRemoveItem remove that wall
and the next line calls the next event with the same pause for 2 secs.

4 - is going well (event calling event) until the last
only removes the wall and do not call no more events

I tried to explain the best way possible.
The other instructions in this tutorial are common and I will not explain.
(eg doTransformItem)



All credits to Conde Sapo
ty, comments...

rep++ :D
 
Code:
local interval = 2
local wallId = 1050
local walls = {
	{x=48, y=38, z=7},
	{x=50, y=38, z=7},
	{x=52, y=38, z=7},
	{x=54, y=38, z=7}
}
local function removeWall(pos)
	local v = getTileItemById(pos, wallId).uid
	return v > 0 and doRemoveItem(v)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		doTransformItem(item.uid, 1946)
		local v = getTileItemById(walls[1], wallId).uid
		if v > 0 then
			doRemoveItem(v)
			if #walls > 1 then
				for i = 2, #walls do
					addEvent(removeWall, (i - 1) * interval * 1000, walls[i])
				end
			end
		end
	else
		doTransformItem(item.uid, 1945)
	end
	return TRUE
end
 
Oh well these scripts are good but not the ones i'm looking for =S these are OnUse functions....I need a a Creature Script....when I killed a creature this event happens...
 
Back
Top