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

Lua Need help with switch

Donus

New Member
Joined
Jul 15, 2009
Messages
5
Reaction score
0
I need script for switch id 1945.If i change 14 switches id 1945 for 1946 stone will go down (id 1304) with position xxx. I got script but only for 2 switches can someone help me how to make for more switches?


function onUse(cid, item, frompos, item2, topos)
gatepos = {{x=1093, y=963, z=7, stackpos=1}, {x=1093, y=963, z=7, stackpos=1}}
for i=1, #gatepos do
getgate = getThingfromPos(gatepos)
if item.uid == 3001 and item.itemid == 1945 and getgate.itemid == 3361 then
doRemoveItem(getgate.uid,1)
doTransformItem(item.uid,1946)
elseif item.uid == 3001 and item.itemid == 1946 and getgate.itemid == 0 then
doCreateItem(3361,1,gatepos)
doTransformItem(item.uid,1945)
else
doPlayerSendCancel(cid,"Sorry, not possible.")
end
end
return 1
end
 
Code:
local gatepos = {
	{x = 1093, y = 963, z = 7}, {x = 1093, y = 963, z = 7}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	for i = 1, 2 do
		local check = getTileItemById(gatepos[i], 3361)
		if item.itemid == 1945 then
			if check.uid >= 1 then
				doRemoveItem(check.uid, 1)
			end
		elseif item.itemid == 1946 then
			if check.uid < 1 then
				doCreateItem(3361, 1, gatepos[i])
			end
		end
	end
	
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Back
Top