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

Solved Lever script problem - autoswitch two levers

xardas33

New Member
Joined
Jan 28, 2010
Messages
83
Reaction score
0
Hello guys. Can you help me with edit my script? I used script on two levers and i want to do this:
When I switch first lever, second lever with same ID (action, unique) automatically switches too. How to do that ? Or if I switch second lever, first switches automatically too. (switches back too)

Here is my script:
Code:
function onUse(cid, item, frompos, item2, topos)
  bridge1 = {x=32099, y=32205, z=8, stackpos=1}
  getbridge1 = getThingfromPos(bridge1)
  bridge2 = {x=32100, y=32205, z=8}
  getbridge2 = getThingfromPos(bridge2)
  bridge3 = {x=32101, y=32205, z=8, stackpos=1}
  getbridge3 = getThingfromPos(bridge3)
   
    if item.actionid == 60002 and item.itemid == 1946 then
  doCreateItem(4645,1,bridge1)
     doCreateItem(351,1,bridge1)
  doCreateItem(4666,1,bridge2)
  doCreateItem(4647,1,bridge3)
     doCreateItem(351,1,bridge3)
     doTransformItem(item.uid,item.itemid-1)
     
    elseif item.actionid == 60002 and item.itemid == 1945 then
  doRemoveItem(getbridge1.uid,1)
  doCreateItem(5770,1,bridge1)
  doRemoveItem(getbridge2.uid,1)
  doCreateItem(5770,1,bridge2)
  doRemoveItem(getbridge3.uid,1)
  doCreateItem(5770,1,bridge3)
     doTransformItem(item.uid,item.itemid+1)   
  else
  doPlayerSendCancel(cid,"Sorry, not possible.")
  end

  return 1
end
 
Just wrote it, post errors if u get any

Code:
function onUse(cid, item, topos, frompos)
   -- Lever 1 Unique id 1000, level 2 unique id 1001
     local c = {
         [1] = {x=32099, y=32205, z=8, stackpos=1},
         [2] = {x=32100, y=32205, z=8},
         [3] = {x=32101, y=32205, z=8, stackpos=1}
     }
    
     if item.itemid == 1946 then
         local t = {1, 3}
         for i = 1, #t do
             doCreateItem(351, 1, c[i])
         end
         doCreateItem(4645, 1, c[1])
         doCreateItem(4646, 1, c[2])
         doCreateItem(4647, 1, c[3])
         for i = 1000, 1001 do
             doTransformItem(i, 1945)
         end
     elseif item.itemid == 1945 then
         for i = 1, 3 do
             doCreateItem(5770, 1, c[i])
             doRemoveItem(getThingfromPos(c[i]).uid, 1)
         end
         for i = 1000, 1001 do
             doTransformItem(i, 1946)
         end
     end
     return true
end
 
I do some changes and now it's work perfectly :)
Here is code:
Code:
function onUse(cid, item, topos, frompos)
   -- Lever 1 Unique id 1000, level 2 unique id 1001
          local c = {
               [1] = {x=32099, y=32205, z=8, stackpos=1},
               [2] = {x=32100, y=32205, z=8},
               [3] = {x=32101, y=32205, z=8, stackpos=1}
}

if item.itemid == 1946 then
         local t = {1, 3}
         for i = 1, 3, #t do
                 doCreateItem(351, 1, c[i])
         end
         doCreateItem(4645, 1, c[1])
         doCreateItem(4666, 1, c[2])
         doCreateItem(4647, 1, c[3])
         for i = 1000, 1001 do
               doTransformItem(i, 1945)
         end
  elseif item.itemid == 1945 then
         for i = 1, 3 do
               doCreateItem(5770, 1, c[i])
               doCreateItem(5770, 1, c[2])
               doRemoveItem(getThingfromPos(c[i]).uid, 1)
         end
          for i = 1000, 1001 do
                doTransformItem(i, 1946)
         end
  end
  return true
end

Changes:
for i = 1, #t do --> for i = 1, 3, #t (because i need to create grounds in two places)
doCreateItem(4646, 1, c[2]) --> doCreateItem(4666,1,c[2]) (because i need here water)
doCreateItem(5770, 1, c[2]) (added because i need to create bridge in this place too.

Thanks for your help :)
 
Last edited:
Back
Top