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

One lever make two things

Tarielle

New Member
Joined
Nov 4, 2007
Messages
214
Reaction score
0
Location
Sweden
Hi, how can I make so one lever make two things from two different scripts?

I got four levers, each lever makes a wall move.
And I got another script when you pulled all the four levers a teleport appears.
Both of them works but I can't make them work the same time..
 
You don't need to place them in different files!

However, paste the script that creates a teleport and I'll fix this for ya :)
 
Ok, thank you <3

Here's the teleport thing:
--config--

local positions = {
[{x=2903, y=2511, z=9, stackpos=1}] = 1946,
[{x=2901, y=2511, z=9, stackpos=1}] = 1946,
[{x=2901, y=2509, z=9, stackpos=1}] = 1946,
[{x=2903, y=2509, z=9, stackpos=1}] = 1946
}


local npos1 = {x=2942, y=2510, z=9}



function onUse(cid, item, frompos, item2, topos)
tile1 = {x=2902, y=2510, z=9, stackpos=1} --change tilepos
gettile1 = getThingfromPos(tile1)
doTransformLever(item)
for position, itemid in pairs(positions) do
if (getThingfromPos(position).itemid ~= itemid) then
doRemoveItem(gettile1.uid)
return 1
end
end
doCreateTeleport(1387, npos1, tile1)
return 1
end

function doTransformLever(lever)
lever.itemid = lever.itemid == 1945 and 1946 or 1945
doTransformItem(lever.uid, lever.itemid)
return lever.itemid
end

(Could you make the doRemoveItem(gettile1.uid) so it only removes when there is a teleport there? :p)


And here's the wall removing script:
function onUse(cid, item, frompos, item2, topos)

tile1 = {x=2903, y=2512, z=9, stackpos=1}
tile2 = {x=2902, y=2512, z=9, stackpos=1}
tile3 = {x=2901, y=2512, z=9, stackpos=1}
tile4 = {x=2900, y=2512, z=9, stackpos=1}
tile5 = {x=2900, y=2511, z=9, stackpos=1}
tile6 = {x=2900, y=2510, z=9, stackpos=1}
tile7 = {x=2900, y=2509, z=9, stackpos=1}
tile8 = {x=2900, y=2508, z=9, stackpos=1}
tile9 = {x=2901, y=2508, z=9, stackpos=1}
tile10 = {x=2902, y=2508, z=9, stackpos=1}
tile11 = {x=2903, y=2508, z=9, stackpos=1}
tile12 = {x=2904, y=2508, z=9, stackpos=1}
tile13 = {x=2904, y=2509, z=9, stackpos=1}
tile14 = {x=2904, y=2510, z=9, stackpos=1}
tile15 = {x=2904, y=2511, z=9, stackpos=1}
tile16 = {x=2904, y=2512, z=9, stackpos=1}


gettile1 = getThingfromPos(tile1)
gettile2 = getThingfromPos(tile2)
gettile3 = getThingfromPos(tile3)
gettile4 = getThingfromPos(tile4)
gettile5 = getThingfromPos(tile5)
gettile6 = getThingfromPos(tile6)
gettile7 = getThingfromPos(tile7)
gettile8 = getThingfromPos(tile8)
gettile9 = getThingfromPos(tile9)
gettile10 = getThingfromPos(tile10)
gettile11 = getThingfromPos(tile11)
gettile12 = getThingfromPos(tile12)
gettile13 = getThingfromPos(tile13)
gettile14 = getThingfromPos(tile14)
gettile15 = getThingfromPos(tile15)
gettile16 = getThingfromPos(tile16)


if item.uid == 2006 and item.itemid == 1945 then
doRemoveItem(gettile1.uid,1)
doRemoveItem(gettile2.uid,1)
doRemoveItem(gettile3.uid,1)
doTransformItem(item.uid,item.itemid+1)
elseif item.uid == 2006 and item.itemid == 1946 then
doCreateItem(1026,1,tile1)
doCreateItem(1026,1,tile2)
doCreateItem(1026,1,tile3)
doTransformItem(item.uid,item.itemid-1)

elseif item.uid == 2007 and item.itemid == 1945 then
doRemoveItem(gettile4.uid,1)
doRemoveItem(gettile5.uid,1)
doRemoveItem(gettile6.uid,1)
doRemoveItem(gettile7.uid,1)
doRemoveItem(gettile8.uid,1)
doTransformItem(item.uid,item.itemid+1)
elseif item.uid == 2007 and item.itemid == 1946 then
doCreateItem(1025,1,tile4)
doCreateItem(1025,1,tile5)
doCreateItem(1025,1,tile6)
doCreateItem(1025,1,tile7)
doCreateItem(1027,1,tile8)
doTransformItem(item.uid,item.itemid-1)

elseif item.uid == 2008 and item.itemid == 1945 then
doRemoveItem(gettile9.uid,1)
doRemoveItem(gettile10.uid,1)
doRemoveItem(gettile11.uid,1)
doRemoveItem(gettile12.uid,1)
doTransformItem(item.uid,item.itemid+1)
elseif item.uid == 2008 and item.itemid == 1946 then
doCreateItem(1026,1,tile9)
doCreateItem(1026,1,tile10)
doCreateItem(1026,1,tile11)
doCreateItem(1026,1,tile12)
doTransformItem(item.uid,item.itemid-1)

elseif item.uid == 2009 and item.itemid == 1945 then
doRemoveItem(gettile13.uid,1)
doRemoveItem(gettile14.uid,1)
doRemoveItem(gettile15.uid,1)
doRemoveItem(gettile16.uid,1)
doTransformItem(item.uid,item.itemid+1)
elseif item.uid == 2009 and item.itemid == 1946 then
doCreateItem(1025,1,tile13)
doCreateItem(1025,1,tile14)
doCreateItem(1025,1,tile15)
doCreateItem(1029,1,tile16)
doTransformItem(item.uid,item.itemid-1)


else
doPlayerSendCancel(cid,"Sorry, not possible.")
end

end

Thanks
 
Alright, try this:
PHP:
local wallPositions = {
	{{x=2903, y=2512, z=9}, 1026},
	{{x=2902, y=2512, z=9}, 1026},
	{{x=2901, y=2512, z=9}, 1026},
	{{x=2900, y=2512, z=9}, 1025},
	{{x=2900, y=2511, z=9}, 1025},
	{{x=2900, y=2510, z=9}, 1025},
	{{x=2900, y=2509, z=9}, 1025},
	{{x=2900, y=2508, z=9}, 1027},
	{{x=2901, y=2508, z=9}, 1026},
	{{x=2902, y=2508, z=9}, 1026},
	{{x=2903, y=2508, z=9}, 1026},
	{{x=2904, y=2508, z=9}, 1026},
	{{x=2904, y=2509, z=9}, 1025},
	{{x=2904, y=2510, z=9}, 1025},
	{{x=2904, y=2511, z=9}, 1025},
	{{x=2904, y=2512, z=9}, 1029}
}

local leverPositions = { -- the positions of each lever 
    [{x=2903, y=2511, z=9}] = 1946,
	[{x=2901, y=2511, z=9}] = 1946,
	[{x=2901, y=2509, z=9}] = 1946,
	[{x=2903, y=2509, z=9}] = 1946
} 
local newPos = {x=2942, y=2510, z=9}
local teleportPos = {x=2902, y=2510, z=9}

function onUse(cid, item, frompos, item2, topos)
    doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
	handleWall(wallPositions, item, 2006, 1, 3)
	handleWall(wallPositions, item, 2007, 4, 8)
	handleWall(wallPositions, item, 2008, 9, 12)
	handleWall(wallPositions, item, 2009, 13, 16)
    for position, itemid in pairs(leverPositions) do
        if (getThingfromPos(position).itemid ~= itemid) then
			local getTeleport = getThingfromPos(teleportPos)
			if getTeleport.itemid == TELEPORT_ITEMID then
				doRemoveItem(getTeleport.uid)
			end
            return 1
        end
    end
    doCreateTeleport(1387, newPos, teleportPos)
    return 1
end  

function handleWall(positions, item, uid, nFrom, nTo)
	if item.uid == uid then
		for key=nFrom, nTo do
			if item.itemid == 1945 then
				positions[key][1].stackpos = 1
				doRemoveItem(getThingfromPos(positions[key][1]).uid, 1)
			else
				doCreateItem(positions[key][2], 1, positions[key][1])
			end
		end
	end
end
 
Last edited:
Uhm, the switches when I pull them, they transform into itemid 65535, that looks like void. And the walls aint getting removed and the teleport wont appear
 
it works for me without any trouble, thanks!
Does the teleport appear and the walls disappear? Also do the teleport get removed and the walls appear again etc?


AND REMOVE THAT DAMN IMAGE IN YOUR SIGNATURE! How many images does it contain? 40? It lags the shit outta my comp :@
 
Last edited:
Back
Top