Action Removing Walls with Time

Gilahof

RepzorMe
Joined
Dec 11, 2007
Messages
87
Best answers
0
Reaction score
1
Location
Brazil
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...
 
Last edited:

cbrm

Top Class brunet scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,585
Best answers
3
Reaction score
852
Location
Caribbean Sea
if the item comes back, then rep for you
 

QuaS

Cykotitan Pwned =/
Joined
Sep 11, 2008
Messages
833
Best answers
0
Reaction score
26
Location
Poland/ Wroclaw
Lua:
-- Removing walls with time (By Conde Sapo) // Edit by QuaS~

function del(wall)
thing = getThingfromPos(wall)
doRemoveItem(thing.uid,1)
end

reset_walls(wall,id)
walle = getTileItemById(wall, id)
if walle > 0 then
doCreateItem(id,1,wall)
end
end


reset_lever(pos)
lev = getTileItemById(pos, 1946)
if lev > 0 then
doTransformItem(lev.uid,1945)
end

function onUse(cid, item, pos)

pausa = 2000 -- 2 sec.
reset_after = 60 * 1000 -- 60 seconds
wall_id = 0000
-- wall positions - don't change stackpos.
walls = {{x=48, y=38, z=7, stackpos=1},
{x=50, y=38, z=7, stackpos=1},
{x=52, y=38, z=7, stackpos=1},
{x=54, y=38, z=7, stackpos=1}
}

if item.itemid == 1945 then
doTransformItem(item.uid,1946)
for i=1, #walls do
addEvent(del,pausa*i,walls[i])
addEvent(reset_walls,reset_after + (pausa*i),walls[i], wall_id)
end
addEvent(reset_lever,reset_after,pos)
elseif item.itemid == 1946 then
for i=1, #walls do
addEvent(reset_walls,pausa*i,walls[i], id)
end
doTransformItem(item.uid,1945)
end

return true
end
??
 

Nanashi

New Member
Joined
May 2, 2010
Messages
241
Best answers
0
Reaction score
2
Location
Sweden
I'd like this one but with this condition:
if
{ mwall return && player on same sqm
TP player to pos xy }

Then it could be used in a quest like, mwalls disappear and players have to run through with outh getting 'caught'
 

kariman

New Member
Joined
Jul 22, 2009
Messages
6
Best answers
0
Reaction score
0
Hi, good script here.I need a lil' help please..

My script it's whit a lever, a dead body, and a wall.
Code:
function onUse(cid, item, frompos, item2, topos)
 
	local switchUniqueID = 12621  -- uniqueID of switch
	local switchID = 1945
	local switch2ID = 1946
	local itemID = 3058
	local itempos = {x=1505, y=1564, z=6, stackpos=1} 
	local wallpos = {x=1508, y=1564, z=6, stackpos=1}
 
	local playername = getPlayerName(cid)
	local getitem = getThingfromPos(itempos)
	local wallchk = getThingfromPos(wallpos)
 
	if item.uid == switchUniqueID and item.itemid == switchID and getitem.itemid == itemID and wallchk.itemid == 1497 then
			doSendMagicEffect(itempos,10)
			doSendMagicEffect(wallchk,10)
			doRemoveItem(getitem.uid,1)
			doRemoveItem(wallchk.uid,1)
			doTransformItem(item.uid,item.itemid+1)
			addEvent(onTimer3, 2*60*1000)
	elseif item.uid == switchUniqueID and item.itemid == switch2ID then
			doTransformItem(item.uid,item.itemid-1)
	else
			doPlayerSendCancel(cid,"You need to place the corpse of the leader hunter.")
end
	return 1
end


function onTimer3()

wallnewpos = {x=1508, y=1564, z=6} 
		doCreateItem(1497,1,wallnewpos)
end
This script have a problem, because the addEvent function, doesn't work, i need to put time to the wall.
Thanks
 

Knight God

Member
Joined
Oct 19, 2008
Messages
1,180
Best answers
0
Reaction score
20
Error

[03/08/2010 15:48:25] [Error - Action Interface]
[03/08/2010 15:48:25] data/actions/scripts/Test1.lua
[03/08/2010 15:48:25] Description:
[03/08/2010 15:48:25] data/actions/scripts/Test1.lua:8: attempt to call global 'reset_walls' (a nil value)
[03/08/2010 15:48:25] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/Test1.lua)
Script

-- Removing walls with time (By Conde Sapo) // Edit by QuaS~

function del(wall)
thing = getThingfromPos(wall)
doRemoveItem(thing.uid,1)
end

reset_walls(wall,id)
walle = getTileItemById(wall, id)
if walle > 0 then
doCreateItem(id,1,wall)
end

reset_lever(pos)
lev = getTileItemById(pos, 1946)
if lev > 0 then
doTransformItem(lev.uid,1945)
end

function onUse(cid, item, pos)


pausa = 5000 -- 5 sec.
reset_after = 60 * 1000 -- 60 seconds
wall_id = 1304
-- wall positions - don't change stackpos.
walls = {{x=561, y=1328, z=8, stackpos=1},
{x=560, y=1328, z=8, stackpos=1}
}

if item.itemid == 1945 then
doTransformItem(item.uid,1946)
for i=1, #walls do
addEvent(del,pausa*i,walls)
addEvent(reset_walls,reset_after + (pausa*i),walls, wall_id)
end
addEvent(reset_lever,reset_after,pos)
elseif item.itemid == 1946 then
for i=1, #walls do
addEvent(reset_walls,pausa*i,walls, id)
end
doTransformItem(item.uid,1945)
end

return true
end
 
Last edited:

Knight God

Member
Joined
Oct 19, 2008
Messages
1,180
Best answers
0
Reaction score
20
need solutions soon
I need to fix my server
and this script is essential
 

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,894
Best answers
4
Reaction score
817
Code:
function del(pos, id)
	local thing = getTileItemById(pos, id).uid
	if thing > 0 then
		doRemoveItem(thing)
	end
end

function reset_walls(pos, id)
	local thing = getTileItemById(pos, id).uid
	if thing < 1 then
		doCreateItem(id, 1, pos)
	end
end

function reset_lever(pos)
	local lev = getTileItemById(pos, 1946).uid
	if lev > 0 then
		doTransformItem(lev, 1945)
	end
end

local eventLever = 0
local eventDel = {}
local eventReset = {}

local pause = 5000 -- 5 sec.
local reset_after = 60 * 1000 -- 60 seconds
local wall_id = 1304 -- itemid of the walls
local walls = { -- wall positions
	{x=561, y=1328, z=8},
	{x=560, y=1328, z=8}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		doTransformItem(item.uid, 1946)
		for i  = 1, #walls do
			eventDel[i] = addEvent(del, pause * i, walls[i], wall_id)
			eventReset[i] = addEvent(reset_walls, reset_after + pause * i, walls[i], wall_id)
		end
		eventLever = addEvent(reset_lever, reset_after + pause * #walls, fromPosition)
	elseif item.itemid == 1946 then
		stopEvent(eventLever)
		for i = 1, #eventDel do
			stopEvent(eventDel[i])
		end
		for i = 1, #eventReset do
			stopEvent(eventReset[i])
		end
		for i = 1, #walls do
			reset_walls(walls[i], id)
		end
		doTransformItem(item.uid, 1945)
	end
	return true
end
 

Knight God

Member
Joined
Oct 19, 2008
Messages
1,180
Best answers
0
Reaction score
20
could also be saying "you have only five minutes to get out"
???
 
Top