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

Help putting many scripts in one

Fumobix

New Member
Joined
Sep 6, 2007
Messages
154
Reaction score
0
Hello, im trying to do poi like RL i did almost everything now but im having problems with the levers,i dont want to do 15 scripts for the 15 levers...

This is what the script does:
Push the lever, check if the lever was pulled in order if not it doesnt move , then a message ( doCreatureSay(cid, "Hurry up and get to the next lever!", TALKTYPE_ORANGE_1)...

Seemed quite easy when i tried to do it but found some ways of the bug getting screwed plus i couldnt get it to work, if you put any item on the lever the script would detect the gps and not the lever, now i though about using =~ so i would detect if the lever wasnt to the left, but people could abuse it putting gps not being in the correct order and jump just to the last lever that open the stones

So anyone could help me "melting" the 16 scripts in one (16 levers, 15 do the same and the last one opens a stone

Got all the positions of every lever already
Lua:
local gatepos = {x=459, y=1386, z=11, stackpos=1}
    local lever1 = {x=453, y=1371, z=11, stackpos=1} --change tilepos
	local lever2 = {x=454, y=1385, z=12, stackpos=1} --change tilepos
    local lever3 = {x=496, y=1402, z=14, stackpos=1} --change tilepos
    local lever4 = {x=450, y=1412, z=11, stackpos=1} --change tilepos
	local lever5 = {x=457, y=1419, z=12, stackpos=1} --change tilepos
	local lever6 = {x=450, y=1405, z=13, stackpos=1} --change tilepos
	local lever7 = {x=460, y=1412, z=13, stackpos=1} --change tilepos
	local lever8 = {x=498, y=1381, z=13, stackpos=1} --change tilepos
	local lever9 = {x=481, y=1407, z=13, stackpos=1} --change tilepos
	local lever10 = {x=467, y=1417, z=12, stackpos=1} --change tilepos
	local lever11 = {x=481, y=1418, z=12, stackpos=1} --change tilepos
	local lever12 = {x=494, y=1408, z=12, stackpos=1} --change tilepos
	local lever13 = {x=450, y=1405, z=13, stackpos=1} --change tilepos
	local lever14 = {x=460, y=1412, z=13, stackpos=1} --change tilepos
function onUse(cid, item, frompos, item2, topos)
	local getlever1 = getThingfromPos(lever1)
	local getlever2 = getThingfromPos(lever2)
	local getlever3 = getThingfromPos(lever3)
	local getlever4 = getThingfromPos(lever4)
	local getlever5 = getThingfromPos(lever5)
	local getlever6 = getThingfromPos(lever6)
	local getlever7 = getThingfromPos(lever7)
	local getlever8 = getThingfromPos(lever8)
	local getlever9 = getThingfromPos(lever9)
	local getlever10 = getThingfromPos(lever10)
	local getlever11 = getThingfromPos(lever11)
	local getlever12 = getThingfromPos(lever12)
	local getlever13 = getThingfromPos(lever13)
	local getlever14 = getThingfromPos(lever14)
	local getgate = getThingfromPos(gatepos)
 
PHP:
local config = {
levers = {
	[2000] = {2000, "first"},
	[2001] = {2001, "second"},
	[2002] = {2002, "third"},
	[2003] = {2003, "fourth"},
	[2004] = {2004, "fift"},
	[2005] = {2005, "sixth"},
	[2006] = {2006, "seventh"},
	[2007] = {2007, "eight"},
	[2008] = {2008, "ninth"},
	[2009] = {2009, "tenth"},
	[2010] = {2010, "eleventh"},
	[2011] = {2011, "twelfth"},
	[2012] = {2012, "thirteenth"},
	[2013] = {2013, "fourteenth"},
	[2014] = {2014, "fifteenth"}
},
storages = {
2000,
2001,
2002,
2003,
2004,
2005,
2006,
2007,
2008,
2009,
2010,
2011,
2012,
2013,
2014
},
stonepos1 = {
{x=1639,y=1252,z=11},
{x=1640,y=1252,z=11}
},
stonepos2 = {
{x=1639,y=1252,z=11,stackpos=1},
{x=1640,y=1252,z=11,stackpos=1}
}
}

function doCreateStone()
for i = 1, table.maxn(config.stonepos1) do
	doCreateItem(1304, config.stonepos1[i])
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition) 

local getstone = {
	getThingFromPos(config.stonepos2[1]),
	getThingFromPos(config.stonepos2[2])
}
	for type, variable in pairs(config.levers) do
		if item.uid == type then
			if item.itemid == 1945 then
			if getGlobalStorageValue(variable[1]) == -1 then
				setGlobalStorageValue(variable[1], 1)
				doCreatureSay(cid, "You have flipped "..variable[2].." lever. Hurry up and find the next one!", TALKTYPE_ORANGE_1)
				doTransformItem(item.uid, 1946)
			end
			elseif item.itemid == 1946 and getGlobalStorageValue(variable[1]) == -1 then
				doTransformItem(item.uid, 1945)
			else
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It doesn't work.")
			end
		end
	end  
	if item.uid == 2030 then
		if item.itemid == 1945 then
			if getGlobalStorageValue(config.storages[1]) == 1 and getGlobalStorageValue(config.storages[2]) == 1 and getGlobalStorageValue(config.storages[3]) == 1 and getGlobalStorageValue(config.storages[4]) == 1 and getGlobalStorageValue(config.storages[5]) == 1 and getGlobalStorageValue(config.storages[6]) == 1 and getGlobalStorageValue(config.storages[7]) == 1 and getGlobalStorageValue(config.storages[8]) == 1 and getGlobalStorageValue(config.storages[9]) == 1 and getGlobalStorageValue(config.storages[10]) == 1 and getGlobalStorageValue(config.storages[11]) == 1 and getGlobalStorageValue(config.storages[12]) == 1 and 
getGlobalStorageValue(config.storages[13]) == 1 and getGlobalStorageValue(config.storages[14]) == 1 and getGlobalStorageValue(config.storages[15]) == 1 then
			setGlobalStorageValue(config.storages[1], -1)
			setGlobalStorageValue(config.storages[2], -1)
			setGlobalStorageValue(config.storages[3], -1)
			setGlobalStorageValue(config.storages[4], -1)
			setGlobalStorageValue(config.storages[5], -1)
			setGlobalStorageValue(config.storages[6], -1)
			setGlobalStorageValue(config.storages[7], -1)
			setGlobalStorageValue(config.storages[8], -1)
			setGlobalStorageValue(config.storages[9], -1)
			setGlobalStorageValue(config.storages[10], -1)
			setGlobalStorageValue(config.storages[11], -1)
			setGlobalStorageValue(config.storages[12], -1)
			setGlobalStorageValue(config.storages[13], -1)
			setGlobalStorageValue(config.storages[14], -1)
			setGlobalStorageValue(config.storages[15], -1)
			addEvent(doCreateStone, 10000)
			for i = 1, table.maxn(config.stonepos1) do
				doSendMagicEffect(config.stonepos1[i], CONST_ME_EXPLOSIONAREA)
			end
			for i = 1, table.maxn(getstone) do
				doRemoveItem(getstone[i].uid, 1)
			end
				doTransformItem(item.uid, 1946)
			else
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You haven't flipped all levers. Hurry up and find them!")
			end
		elseif item.itemid == 1946 then
			doTransformItem(item.uid, 1945)
		end
	end
	return TRUE
end
Everyone knows what it is. Rep me. :)
here
 
Back
Top