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

Action (Solved)

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,857
Reaction score
96
Location
Brazil
This is the Dreamer's Challenge Quest script, part of Death ring, Life ring ..
OnUse.
I made this script myself.
Is possible to simplify? It's too much lines
LUA:
function onUse(cid, item, frompos, item2, topos)

gatepos = {x=32996, y=32272, z=10, stackpos=1}
getgate = getThingfromPos(gatepos)
gatepos2 = {x=32999, y=32269, z=10, stackpos=1}
getgate2 = getThingfromPos(gatepos2)
gatepos3 = {x=33002, y=32272, z=10, stackpos=1}
getgate3 = getThingfromPos(gatepos3)
gatepos4 = {x=32999, y=32275, z=10, stackpos=1}
getgate4 = getThingfromPos(gatepos4)
gatepos5 = {x=32999, y=32272, z=10, stackpos=1}
getgate5 = getThingfromPos(gatepos5)
gatepos6 = {x=32992, y=32265, z=10, stackpos=1}
getgate6 = getThingfromPos(gatepos6)
gatepos7 = {x=32993, y=32265, z=10, stackpos=1}
getgate7 = getThingfromPos(gatepos7)
gatepos8 = {x=32992, y=32266, z=10, stackpos=1}
getgate8 = getThingfromPos(gatepos8)
gatepos9 = {x=32993, y=32266, z=10, stackpos=1}
getgate9 = getThingfromPos(gatepos9)
gatepos10 = {x=32997, y=32270, z=10, stackpos=1}
getgate10 = getThingfromPos(gatepos10)
gatepos11 = {x=33001, y=32270, z=10, stackpos=1}
getgate11 = getThingfromPos(gatepos11)
gatepos12 = {x=32997, y=32274, z=10, stackpos=1}
getgate12 = getThingfromPos(gatepos12)
gatepos13 = {x=33001, y=32274, z=10, stackpos=1}
getgate13 = getThingfromPos(gatepos13)

if item.uid == 34582 and getgate2.itemid == 2168 and getgate3.itemid == 1492 and getgate4.itemid == 6300 and getgate6.itemid == 3729 and getgate7.itemid == 3730 and getgate8.itemid == 3731 and getgate9.itemid == 3732 then
doRemoveItem(getgate2.uid,1)
doRemoveItem(getgate3.uid,1)
doRemoveItem(getgate4.uid,1)
doRemoveItem(getgate6.uid,1)
doRemoveItem(getgate7.uid,1)
doRemoveItem(getgate8.uid,1)
doRemoveItem(getgate9.uid,1)
doCreateItem(3733,1,gatepos6)
doCreateItem(3734,1,gatepos7)
doCreateItem(3735,1,gatepos8)
doCreateItem(3736,1,gatepos9)
doCreateItem(5070,1,gatepos10)
doCreateItem(5070,1,gatepos11)
doCreateItem(5070,1,gatepos12)
doCreateItem(5070,1,gatepos13)
else
end
end
 
Last edited:
XML:
<action uniqueid="7500" event="script" value="dream.lua"/>
LUA:
local t = {
	{ {x=32996, y=32272, z=10}, {2016, 1} },
	{ {x=32999, y=32269, z=10}, 2168 },
	{ {x=33002, y=32272, z=10}, 1492 },
	{ {x=32999, y=32275, z=10}, 6300 },

	{ {x=32992, y=32265, z=10}, 3729, 3733 },
	{ {x=32993, y=32265, z=10}, 3730, 3734 },
	{ {x=32992, y=32266, z=10}, 3731, 3735 },
	{ {x=32993, y=32266, z=10}, 3732, 3736 },

	{ {x=32997, y=32270, z=10}, 0, 5070},
	{ {x=33001, y=32270, z=10}, 0, 5070},
	{ {x=32997, y=32274, z=10}, 0, 5070},
	{ {x=33001, y=32274, z=10}, 0, 5070}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local r = item.itemid == 1945
	local a, b, n = r and 2 or 3, r and 3 or 2, true
	for i = 1, #t do
		local v = t[i]
		if v[a] == 0 then
			doCreateItem(v[b], 1, v[1])
		elseif v[b] == 0 then
			doRemoveItem(getTileItemById(v[1], v[a]).uid)
		elseif v[3] then
			doTransformItem(getTileItemById(v[1], v[a]).uid, v[b])
		elseif n and not v[3] then
			local k = getTileItemById(v[1], type(v[2]) == 'table' and v[2][1] or v[2])
			if k.uid == 0 or (type(v[2]) == 'table' and v[2][2] ~= k.type) then
				n = nil
			end
		end
	end
	if n or not r then
		local it = getTileItemById({x=32999, y=32272, z=10}, r and 1355 or 1387).uid
		if it ~= 0 then
			doRemoveItem(it)
			if r then
				doItemSetAttribute(doCreateItem(1387, 1, {x=32999, y=32272, z=10}), 'uid', 7505)
				doSendMagicEffect({x=32999, y=32272, z=10}, CONST_ME_MAGIC_BLUE)
			else
				doCreateItem(1355, 1, {x=32999, y=32272, z=10})
			end
		end
	end	
	return doTransformItem(item.uid, r and 1946 or 1945)
end
XML:
<movevent type="AddItem" tileitem="1" fromuid="7501" touid="7504" event="script" value="dream.lua"/>
<movevent type="StepIn" uniqueid="7505" event="script" value="dream.lua"/>
LUA:
local t = {
	[7501] = {2016, 1},
	[7502] = 2168,
	[7503] = 1492,
	[7504] = 6300
}

function onAddItem(item, tile, pos, cid)
	local v = t[tile.uid]
	if ((type(v) == 'table' and item.itemid == v[1] and item.type == v[2]) or item.itemid == v) and getThing(7500).itemid == 1946 then
		local it = getTileItemById({x=32999, y=32272, z=10}, 1355).uid
		if it ~= 0 then
			for i = 7501, 7504 do
				if i ~= tile.uid then
					local v = getTileItemById(getThingPos(i), type(t[i]) == 'table' and t[i][1] or t[i])
					if v.uid == 0 or (type(t[i]) == 'table' and t[i][2] ~= v.type) then
						return
					end
				end
			end
			doRemoveItem(it)
			doItemSetAttribute(doCreateItem(1387, 1, {x=32999, y=32272, z=10}), 'uid', 7505)
			doSendMagicEffect({x=32999, y=32272, z=10}, CONST_ME_MAGIC_BLUE)
		end
	end
end

function onStepIn(cid, item, pos, fromPos)
	if isPlayer(cid) and getThing(7500).itemid == 1946 then
		local tb, f = {}
		for i = 7501, 7504 do
			local v = getTileItemById(getThingPos(i), type(t[i]) == 'table' and t[i][1] or t[i])
			if v.uid == 0 or (type(t[i]) == 'table' and t[i][2] ~= v.type) then
				f = true
				break
			else
				table.insert(tb, v.uid)
			end
		end
		if not f then
			for i = 1, #tb do
				doRemoveItem(tb[i])
			end
			local tmp = {{x=32992, y=32265, z=10},{x=32993, y=32265, z=10},{x=32992, y=32266, z=10},{x=32993, y=32266, z=10}}
			for i = 1, #tmp do
				doTransformItem(getTileItemById(tmp[i], 3732 + i).uid, 3728 + i)
			end
			tmp = {{x=32997, y=32270, z=10},{x=33001, y=32270, z=10},{x=32997, y=32274, z=10},{x=33001, y=32274, z=10}}
			for i = 1, #tmp do
				doRemoveItem(getTileItemById(tmp[i], 5070).uid)
			end
			doTeleportThing(cid, {x=32994, y=32272, z=10}) -- edit
			doSendMagicEffect(pos, CONST_ME_TELEPORT)
			doSendMagicEffect({x=32994, y=32272, z=10}, CONST_ME_TELEPORT) -- edit
			doRemoveItem(item.uid)
			doCreateItem(1355, 1, pos)
			doTransformItem(7500, 1945)
			return
		end
	end
	doTeleportThing(cid, {x=pos.x-1, y=pos.y, z=pos.z}, true)
	doSendMagicEffect(pos, CONST_ME_TELEPORT)
	doSendMagicEffect({x=pos.x-1, y=pos.y, z=pos.z}, CONST_ME_TELEPORT)
end
 
It's a good script but I just want to know how to remove the sparks.
Will it work?
LUA:
doRemoveItem(getTileItemById({x=32997, y=32270, z=10}[1], 5070).uid)
 
"7501" to "7504" = tiles but where is life ring, where death ring..
Check the ids to the right
LUA:
	[7501] = {2016, 1}, -- water
	[7502] = 2168, -- life ring
	[7503] = 1492, -- fire
	[7504] = 6300 -- death ring
and "7505" = ?
You don't have to do anything with it except for register in movements.xml, it's the uid for the teleport.
 
Back
Top