• 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 Lever script not working [rep++]

Evan

A splendid one to behold
Senator
Premium User
Joined
May 6, 2009
Messages
7,018
Solutions
1
Reaction score
1,040
Location
United States
Okay, I have one uniqueID lever, when its pulled, it checks if 4 switches are pulled to the right, if it is, then it will remove the walls. After 3 seconds, everything gets reset back to normal.
I know it's a very very messy script, but it should somehow work, but for some damn reason, it is NOT! The switch just didn't get pulled.

Here is the script:
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)  
    wall_pos1 = {x=764, y=888, z=11, stackpos=1}  
    wall1 = getThingfromPos(wall_pos1)
	wall_pos2 = {x=765, y=888, z=11, stackpos=1}  
    wall2 = getThingfromPos(wall_pos2)
	switch1_pos = {x=755, y=892, z=11, stackpos=1}
	switch1 = getThingfromPos(switch1_pos)
	switch2_pos = {x=755, y=900, z=11, stackpos=1}
	switch2 = getThingfromPos(switch2_pos)
	switch3_pos = {x=774, y=892, z=11, stackpos=1}
	switch3 = getThingfromPos(switch3_pos)
	switch4_pos = {x=774, y=900, z=11, stackpos=1}
	switch4 = getThingfromPos(switch4_pos)
  
    if item.itemid == 1945 and wall1.itemid == 1547 and wall2.itemid == 1547 then 
		if switch1 == 1946 and switch2 == 1946 and switch3 == 1946 and switch4 == 1946 then
            doSendMagicEffect(wall_pos1, 10)  
			doSendMagicEffect(wall_pos2, 10)  
            doRemoveItem(wall1.uid, 1)   
            doRemoveItem(wall2.uid, 1)  
            doTransformItem(item.uid, 1946)  
			addEvent(createWallent, 3 * 1000)
        else
            doPlayerSendCancel(cid,"Sorry, not possible.")
        end
	end
    return TRUE 
end
  
function createWallent()   
    doCreateItem(1547, wall_pos1) 
	doCreateItem(1547, wall_pos2) 
    doSendMagicEffect(wall_pos1, 10)		
    doSendMagicEffect(wall_pos2, 10)
	doTransformItem(item.uid, 1945)  
	doTransformItem(switch1, 1945)  
	doTransformItem(switch2, 1945)  
	doTransformItem(switch3, 1945)  
	doTransformItem(switch4, 1945)  
end
 
I think the solution is simple..
Change the leverID and leverPulledID to whatevery you use!
LUA:
local cfg = {
leverID = 0,
leverPulledID = 0
}
function onUse(cid, item, fromPosition, itemEx, toPosition)  
    if(item.itemid == leverID) then
    doTransformItem(item.uid, leverPulledID)
    elseif(item.itemid == leverPulledID) then
    doTransformItem(item.uid, leverID)
    end
    wall_pos1 = {x=764, y=888, z=11, stackpos=1}  
    wall1 = getThingfromPos(wall_pos1)
    wall_pos2 = {x=765, y=888, z=11, stackpos=1}  
    wall2 = getThingfromPos(wall_pos2)
    switch1_pos = {x=755, y=892, z=11, stackpos=1}
    switch1 = getThingfromPos(switch1_pos)
    switch2_pos = {x=755, y=900, z=11, stackpos=1}
    switch2 = getThingfromPos(switch2_pos)
    switch3_pos = {x=774, y=892, z=11, stackpos=1}
    switch3 = getThingfromPos(switch3_pos)
    switch4_pos = {x=774, y=900, z=11, stackpos=1}
    switch4 = getThingfromPos(switch4_pos)
  
    if item.itemid == 1945 and wall1.itemid == 1547 and wall2.itemid == 1547 then 
        if switch1 == 1946 and switch2 == 1946 and switch3 == 1946 and switch4 == 1946 then
            doSendMagicEffect(wall_pos1, 10)  
            doSendMagicEffect(wall_pos2, 10)  
            doRemoveItem(wall1.uid, 1)   
            doRemoveItem(wall2.uid, 1)  
            doTransformItem(item.uid, 1946)  
            addEvent(createWallent, 3 * 1000)
        else
            doPlayerSendCancel(cid,"Sorry, not possible.")
        end
    end
    return TRUE 
end
  
function createWallent()   
    doCreateItem(1547, wall_pos1) 
    doCreateItem(1547, wall_pos2) 
    doSendMagicEffect(wall_pos1, 10)        
    doSendMagicEffect(wall_pos2, 10)
    doTransformItem(item.uid, 1945)  
    doTransformItem(switch1, 1945)  
    doTransformItem(switch2, 1945)  
    doTransformItem(switch3, 1945)  
    doTransformItem(switch4, 1945)  
end
 
PHP:
function createWallent()   
    doCreateItem(1547, wall_pos1) 
	doCreateItem(1547, wall_pos2) 
    doSendMagicEffect(wall_pos1, 10)		
    doSendMagicEffect(wall_pos2, 10)
	doTransformItem(item.uid, 1945)  
	doTransformItem(switch1.uid, 1945)  
	doTransformItem(switch2.uid, 1945)  
	doTransformItem(switch3.uid, 1945)  
	doTransformItem(switch4.uid, 1945)  
end

function onUse(cid, item, fromPosition, itemEx, toPosition)  
    local wall_pos1 = {x=764, y=888, z=11, stackpos=1}  
    local wall1 = getThingfromPos(wall_pos1)
    local wall_pos2 = {x=765, y=888, z=11, stackpos=1}  
    local wall2 = getThingfromPos(wall_pos2)
	local switch1_pos = {x=755, y=892, z=11, stackpos=1}
	local switch1 = getThingfromPos(switch1_pos)
	local switch2_pos = {x=755, y=900, z=11, stackpos=1}
	local switch2 = getThingfromPos(switch2_pos)
	local switch3_pos = {x=774, y=892, z=11, stackpos=1}
	local switch3 = getThingfromPos(switch3_pos)
	local switch4_pos = {x=774, y=900, z=11, stackpos=1}
	local switch4 = getThingfromPos(switch4_pos)
  
    if item.itemid == 1945 and wall1.itemid == 1547 and wall2.itemid == 1547 then 
		if switch1.itemid == 1946 and switch2.itemid == 1946 and switch3.itemid == 1946 and switch4.itemid == 1946 then
            doSendMagicEffect(wall_pos1, 10)  
		doSendMagicEffect(wall_pos2, 10)  
            doRemoveItem(wall1.uid, 1)   
            doRemoveItem(wall2.uid, 1)  
            doTransformItem(item.uid, 1946)  
			addEvent(createWallent, 3 * 1000)    

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

You forgot .itemid on switch1 etc...

Haven't tested it but should work with this..
 
Back
Top