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

[Need] Script to 8.6

Place lever_id 1945 on map.
Put ActionID from actions.xml onto lever.
Save map.
Restart server.


Cheers!

data/actions/actions.xml

Code:
<action actionid="45001" event="script" value="multiple_item_convert_lever.lua"/>
data/actions/scripts/multiple_item_convert_lever.lua
Code:
local items_player_needs = {
   [1] = {itemID = 111111, itemCount = 1111},
   [2] = {itemID = 111111, itemCount = 1111},
   [3] = {itemID = 111111, itemCount = 1111}
}

local what_player_receives = {
   item_ID = 111111,
   item_count = 1111
}

local config = {
   lever_reset_time_in_seconds = 60
}

local function reset(p)
   doTransformItem(getTileItemById(p, 1946).uid, 1945)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)

   -- check if lever is currently used
   if item.itemid == 1946 then
     return doPlayerSendTextMessage(cid, 22, "Wait for switch to reset.")
   end
  
   -- check player inventory to see what items they have
   count = 0
   for i = 1, #items_player_needs do
     if getPlayerItemCount(cid, items_player_needs[i].itemID) >= items_player_needs[i].itemCount then
       count = count + 1
     else
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You require more ".. getItemNameById(items_player_needs[i].itemID) .."'s to successfully convert items.")
       break
     end
   end
  
   -- check amount of items in table
   table_count = 0
   for k,v in pairs(items_player_needs) do
     table_count = table_count + 1
   end

   -- check if count = tableCount
   if table_count ~= count then
     return true
   end
  
   -- remove required items
   for i = 1, #items_player_needs do
     doPlayerRemoveItem(cid, items_player_needs[i].itemID, items_player_needs[i].itemCount)
   end
  
   -- give player item
   stack = 0
   if isItemStackable(what_player_receives.item_ID) == true then
     stack = stack + 1
   end
  
   if stack == 1 then
     doPlayerAddItem(cid, what_player_receives.item_ID, what_player_receives.item_count, true)
   else
     repeat
       doPlayerAddItem(cid, what_player_receives.item_ID, 1, true)
       stack = stack + 1
     until stack == (what_player_receives.item_count)
   end
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have received ".. what_player_receives.item_count .." ".. getItemNameById(what_player_receives.item_ID) ..".")
  
   -- transform lever, and add reset
   doTransformItem(item.uid, item.itemid + 1)
   addEvent(reset, config.lever_reset_time_in_seconds * 1000, toPosition)

   return true
end
 
Change these two lines.
1945 = switch facing left.
1946 = switch facing right.
Code:
local function reset(p)
   doTransformItem(getTileItemById(p, 1946).uid, 1945)
end

if item.itemid == 1946 then
If for some reason the left facing switch is not 1 number down from the right facing switch, change this line.
Code:
doTransformItem(item.uid, item.itemid + 1)
Can edite for no use switch and use a another id like: 8046
 
Back
Top