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

Put 2 wall in one lever

Stewie

Family Guy # ;3
Joined
May 3, 2010
Messages
786
Reaction score
12
Location
TV
Hi,how i can add other wall in this lever:

Lua:
local gatepos = {x=485, y=450, z=6, stackpos=1}

function onUse(cid, item, frompos, item2, topos)
local getgate = getThingfromPos(gatepos)

	if item.itemid == 1945 and getgate.itemid == 1061 then
		doRemoveItem(getgate.uid, 1)
		doTransformItem(item.uid, item.itemid+1)
	elseif item.itemid == 1946 and getgate.itemid == 0 then
		doCreateItem(1061, 1, gatepos)
		doTransformItem(item.uid, item.itemid-1)
	else
		doPlayerSendCancel(cid,"Sorry, not possible.")
	end
return 1
end
 
Lua:
local t = {
	[1] = {x=485, y=450, z=6, stackpos=1},
	[2] = {x=485, y=450, z=6, stackpos=1}
	}
function onUse(cid, item, fromPosition, itemEx, toPosition)
for v = t[1], #t do
local getgate = getThingfromPos(v)
	if item.itemid == 1945 and getgate.itemid == 1061 then
		doRemoveItem(getgate.uid, 1)
		doTransformIem(item.uid, item.itemid+1)
	elseif item.itemid == 1946 and getgate.itemid == 0 then
		doCreateItem(1061, 1, gatepos)
		doTransformItem(item.uid, item.itemid-1)
	else
		doPlayerSendCancel(cid, "Sorry, not possibrrrruuuu")
	end
return TRUE
end
thread moved to requests.
 
@up a little bugged

another version:
Lua:
local p = { -- how many positions you want
	{x=485, y=450, z=6},
	{x=486, y=450, z=6}
}
local r = {x=487, y=450, z=6} -- relocate position
function onUse(cid, item, fromPosition, itemEx, toPosition)
	for _, v in ipairs(p) do
		local tmp = getTileItemById(v, 1061).uid
		if tmp >= 1 then
			doRemoveItem(tmp, 1)
		else
			doRelocate(v, r)
			doCreateItem(1061, 1, v)
		end
	end
	doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
 
	return true
end
 
Last edited:
@andypsylon

Ok,this remove walls but don't create on places.

Code:
[13/12/2011 02:36:32] [Error - Action Interface] 
[13/12/2011 02:36:32] data/actions/scripts/lever4.lua:onUse
[13/12/2011 02:36:32] Description: 
[13/12/2011 02:36:32] (luaDoRemoveItem) Item not found
 
@andypsylon

Ok,this remove walls but don't create on places.

Code:
[13/12/2011 02:36:32] [Error - Action Interface] 
[13/12/2011 02:36:32] data/actions/scripts/lever4.lua:onUse
[13/12/2011 02:36:32] Description: 
[13/12/2011 02:36:32] (luaDoRemoveItem) Item not found

Did you try mine? if you didn't, add an end before the first end.
 
@Bogart i have tested yours but don't work,simple no error only don't work.

@andypsylon

Code:
[13/12/2011 13:04:52] [Error - Action Interface] 
[13/12/2011 13:04:52] data/actions/scripts/lever.lua:onUse
[13/12/2011 13:04:52] Description: 
[13/12/2011 13:04:52] data/actions/scripts/lever.lua:11: attempt to compare number with boolean
[13/12/2011 13:04:52] stack traceback:
[13/12/2011 13:04:52] 	data/actions/scripts/lever.lua:11: in function <data/actions/scripts/lever.lua:4>

[13/12/2011 13:04:53] [Error - Action Interface] 
[13/12/2011 13:04:53] data/actions/scripts/lever.lua:onUse
[13/12/2011 13:04:53] Description: 
[13/12/2011 13:04:53] (luaDoRemoveItem) Item not found
 
Lua:
local t = {
      {x=485, y=450, z=6, stackpos = 1},
      {x=x,y=y,z=z, stackpos = 1}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
for i = 1, #t do
    if getThingfromPos(t[i]).itemid == 1061 then
       doRemoveItem(getThingfromPos(t[i]).uid, 1)
    else
        doCreateItem(1061, 1, t[i])
    end
end
return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945) and true
end
 
agrees :)
Lua:
local p = { -- how many positions you want
	{x=485, y=450, z=6},
	{x=486, y=450, z=6}
}
local r = {x=487, y=450, z=6} -- relocate position
function onUse(cid, item, fromPosition, itemEx, toPosition)
	for _, v in ipairs(p) do
		local tmp = getTileItemById(v, 1061).uid
		if tmp >= 1 then
			doRemoveItem(tmp, 1)
		else
			doRelocate(v, r)
			doCreateItem(1061, 1, v)
		end
	end
	doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
 
	return true
end
 
Back
Top