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

item upgrader

alectrona94

Member
Joined
Aug 10, 2019
Messages
143
Reaction score
7
Location
Egypt
was looking for a script regarding this but all what ive found is + in the item level or attack, i wanted a script to upgrade an item to another item using something like magic powder and used by lever
 
Solution
Both yeah, i will try ur script when i get home thanks
Alright.
Here's my version of this script.

Put ACTIONID onto lever.

In-game.
-> Place items on opposite sides of lever
-> flop lever

-- Note. If itemid_dust is not stackable, then amount_required must be 1.
-- Note2. If itemid_dust is stackable, then amount_required max is 100.

Untested.
XML:
<action actionid="45001" event="script" value="item_upgrader.lua"/>
Lua:
local config = {
    projectile = CONST_ANI_ENERGY,
    fail = CONST_ME_MAGIC_RED,
    success = CONST_ME_MAGIC_GREEN,
    leverIDs = {1945, 1946}, -- {left, right}
    remove_base_item_on_fail = true
}
local items = {
    -- [itemid_plate_legs] = {{itemid_dust...
This one should be working with all items, You want one for specific items?
 
Try this one, don't forget changing items ids
add like this to your actions.xml and add on the lever action id 45001 with map editor.

XML:
<action actionid="45001" event="script" value="Upgrade.lua"/>

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   if item.itemid == 1946 then
       doPlayerSendTextMessage(cid, 22, "Switch reset.")
       doTransformItem(item.uid, 1945)
       return true
       end
  
        if getPlayerItemCount(cid,2496,1) < 200 then
            doPlayerAddItem(cid,2501,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,2496,1)
            doPlayerSendTextMessage(cid,21,"Your Helmet has been upgraded!")

 
        elseif getPlayerItemCount(cid,2505,1) < 200 then
            doPlayerAddItem(cid,2503,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,2505,1)
            doPlayerSendTextMessage(cid,21,"Your Armor has been upgraded!")
    
  
        elseif getPlayerItemCount(cid,2507,1) < 200 then
            doPlayerAddItem(cid,2504,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,2507,1)
            doPlayerSendTextMessage(cid,21,"Your Legs has been upgraded!")
  
        elseif getPlayerItemCount(cid,2538,1) < 200 then
            doPlayerAddItem(cid,8905,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,2538,1)
            doPlayerSendTextMessage(cid,21,"Your Shield has been upgraded!")
    

        elseif getPlayerItemCount(cid,2641,1) < 200 then
            doPlayerAddItem(cid,2358,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,2641,1)
            doPlayerSendTextMessage(cid,21,"Your Boots has been upgraded!")
    

        elseif getPlayerItemCount(cid,5907,1) < 200 then
            doPlayerAddItem(cid,7438,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,5907,1)
            doPlayerSendTextMessage(cid,21,"Your Slingshot has been upgraded!")
    


        elseif getPlayerItemCount(cid,7417,1) < 200 then
            doPlayerAddItem(cid,8931,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,7417,1)
            doPlayerSendTextMessage(cid,21,"Your Sword has been upgraded!")
    

        elseif getPlayerItemCount(cid,7429,1) < 200 then
            doPlayerAddItem(cid,2437,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,7429,1)
            doPlayerSendTextMessage(cid,21,"Your Club has been upgraded!")
    

        elseif getPlayerItemCount(cid,8924,1) < 200 then
            doPlayerAddItem(cid,8926,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,8924,1)
            doPlayerSendTextMessage(cid,21,"Your Axe has been upgraded!")
    

        elseif getPlayerItemCount(cid,7424,1) < 200 then
            doPlayerAddItem(cid,7958,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,7424,1)
            doPlayerSendTextMessage(cid,21,"Your Wand has been upgraded!")
    
    
       else
           doPlayerSendCancel(cid, "This Item You Try To Uprgade Not Rich !")
           end
  
       return 1
   end
 
Try now
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   if item.itemid == 1946 then
       doPlayerSendTextMessage(cid, 22, "Switch reset.")
       doTransformItem(item.uid, 1945)
       return true
       end
 
        if getPlayerItemCount(cid,2496,1) >= 1 then
            doPlayerAddItem(cid,2501,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,2496,1)
            doPlayerSendTextMessage(cid,21,"Your Helmet has been upgraded!")

 
        elseif getPlayerItemCount(cid,2505,1) >= 1 then
            doPlayerAddItem(cid,2503,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,2505,1)
            doPlayerSendTextMessage(cid,21,"Your Armor has been upgraded!")
    
 
        elseif getPlayerItemCount(cid,2507,1) >= 1 then
            doPlayerAddItem(cid,2504,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,2507,1)
            doPlayerSendTextMessage(cid,21,"Your Legs has been upgraded!")
 
        elseif getPlayerItemCount(cid,2538,1) >= 1 then
            doPlayerAddItem(cid,8905,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,2538,1)
            doPlayerSendTextMessage(cid,21,"Your Shield has been upgraded!")
    

        elseif getPlayerItemCount(cid,2641,1) >= 1 then
            doPlayerAddItem(cid,2358,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,2641,1)
            doPlayerSendTextMessage(cid,21,"Your Boots has been upgraded!")
    

        elseif getPlayerItemCount(cid,5907,1) >= 1 then
            doPlayerAddItem(cid,7438,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,5907,1)
            doPlayerSendTextMessage(cid,21,"Your Slingshot has been upgraded!")
    


        elseif getPlayerItemCount(cid,7417,1) >= 1 then
            doPlayerAddItem(cid,8931,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,7417,1)
            doPlayerSendTextMessage(cid,21,"Your Sword has been upgraded!")
    

        elseif getPlayerItemCount(cid,7429,1) >= 1 then
            doPlayerAddItem(cid,2437,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,7429,1)
            doPlayerSendTextMessage(cid,21,"Your Club has been upgraded!")
    

        elseif getPlayerItemCount(cid,8924,1) >= 1 then
            doPlayerAddItem(cid,8926,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,8924,1)
            doPlayerSendTextMessage(cid,21,"Your Axe has been upgraded!")
    

        elseif getPlayerItemCount(cid,7424,1) >= 1 then
            doPlayerAddItem(cid,7958,1)
            doPlayerRemoveItem(cid,8306,1)
            doPlayerRemoveItem(cid,7424,1)
            doPlayerSendTextMessage(cid,21,"Your Wand has been upgraded!")
    
    
       else
           doPlayerSendCancel(cid, "This Item You Try To Uprgade Not Rich !")
           end
 
       return 1
   end
 
Try this one
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   if item.itemid == 1946 then
       doPlayerSendTextMessage(cid, 22, "Switch reset.")
       doTransformItem(item.uid, 1945)
       return true
       end
 
        if getPlayerItemCount(cid,2496,1) >= 1 then
          if  doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,2496,1) == TRUE then
            doPlayerAddItem(cid,2501,1)
            doPlayerSendTextMessage(cid,21,"Your Helmet has been upgraded!")

 
        elseif getPlayerItemCount(cid,2505,1) >= 1 then
          if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,2505,1) == TRUE then
            doPlayerAddItem(cid,2503,1)
            doPlayerSendTextMessage(cid,21,"Your Armor has been upgraded!")
    
 
        elseif getPlayerItemCount(cid,2507,1) >= 1 then
            if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,2507,1) == TRUE then
            doPlayerAddItem(cid,2504,1)
            doPlayerSendTextMessage(cid,21,"Your Legs has been upgraded!")
 
        elseif getPlayerItemCount(cid,2538,1) >= 1 then
            if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,2538,1) == TRUE then
            doPlayerAddItem(cid,8905,1)
            doPlayerSendTextMessage(cid,21,"Your Shield has been upgraded!")
    

        elseif getPlayerItemCount(cid,2641,1) >= 1 then
            if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,2641,1) == TRUE then
            doPlayerAddItem(cid,2358,1)
            doPlayerSendTextMessage(cid,21,"Your Boots has been upgraded!")
    

        elseif getPlayerItemCount(cid,5907,1) >= 1 then
            if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,5907,1) == TRUE then
            doPlayerAddItem(cid,7438,1)
            doPlayerSendTextMessage(cid,21,"Your Slingshot has been upgraded!")
    


        elseif getPlayerItemCount(cid,7417,1) >= 1 then
            if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,7417,1) == TRUE then
            doPlayerAddItem(cid,8931,1)
            doPlayerSendTextMessage(cid,21,"Your Sword has been upgraded!")
    

        elseif getPlayerItemCount(cid,7429,1) >= 1 then
            if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,7429,1) == TRUE then
            doPlayerAddItem(cid,2437,1)
            doPlayerSendTextMessage(cid,21,"Your Club has been upgraded!")
    

        elseif getPlayerItemCount(cid,8924,1) >= 1 then
            if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,8924,1) == TRUE then
            doPlayerAddItem(cid,8926,1)
            doPlayerSendTextMessage(cid,21,"Your Axe has been upgraded!")
    

        elseif getPlayerItemCount(cid,7424,1) >= 1 then
            if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,7424,1) == TRUE then
            doPlayerAddItem(cid,7958,1)
            doPlayerSendTextMessage(cid,21,"Your Wand has been upgraded!")
    
    
       else
           doPlayerSendCancel(cid, "This Item You Try To Uprgade Not Rich !")
           end
           end
           end
           end
           end
           end
           end
           end
           end
           end
           end
 
       return 1
   end
 
thumbs up working fine, wondering could it have a failure chance?
Sorry to jump in here.. but can you tell me how the script is supposed to work?

Have plate legs in inventory, along with another item (dust), click a lever, and the plate legs & dust disappear and turn into, like crown legs?

aka
Have item X & Y, pull lever, get item Z?
 
Sorry to jump in here.. but can you tell me how the script is supposed to work?

Have plate legs in inventory, along with another item (dust), click a lever, and the plate legs & dust disappear and turn into, like crown legs?

aka
Have item X & Y, pull lever, get item Z?
yes kinda, but i want to place a dust and an item on a counter an pull the lever so the dust disappear and the old item and turns into the new one, that if it success ed
 
Try this one
Lua:
local config = {
    brokeChance = 5
    }
function onUse(cid, item, fromPosition, itemEx, toPosition)
   if item.itemid == 1946 then
       doPlayerSendTextMessage(cid, 22, "Switch reset.")
       doTransformItem(item.uid, 1945)
       return true
       end
        if getPlayerItemCount(cid,2496,1) >= 1 then
          if  doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,2496,1) == TRUE and config.brokeChance <= math.random(100) then
            doPlayerAddItem(cid,2501,1)
            doPlayerSendTextMessage(cid,21,"Your Helmet has been upgraded!")


        elseif getPlayerItemCount(cid,2505,1) >= 1 then
          if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,2505,1) == TRUE and config.brokeChance <= math.random(100) then
            doPlayerAddItem(cid,2503,1)
            doPlayerSendTextMessage(cid,21,"Your Armor has been upgraded!")
   

        elseif getPlayerItemCount(cid,2507,1) >= 1 then
            if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,2507,1) == TRUE and config.brokeChance <= math.random(100) then
            doPlayerAddItem(cid,2504,1)
            doPlayerSendTextMessage(cid,21,"Your Legs has been upgraded!")

        elseif getPlayerItemCount(cid,2538,1) >= 1 then
            if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,2538,1) == TRUE and config.brokeChance <= math.random(100) then
            doPlayerAddItem(cid,8905,1)
            doPlayerSendTextMessage(cid,21,"Your Shield has been upgraded!")
   

        elseif getPlayerItemCount(cid,2641,1) >= 1 then
            if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,2641,1) == TRUE and config.brokeChance <= math.random(100) then
            doPlayerAddItem(cid,2358,1)
            doPlayerSendTextMessage(cid,21,"Your Boots has been upgraded!")
   

        elseif getPlayerItemCount(cid,5907,1) >= 1 then
            if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,5907,1) == TRUE and config.brokeChance <= math.random(100) then
            doPlayerAddItem(cid,7438,1)
            doPlayerSendTextMessage(cid,21,"Your Slingshot has been upgraded!")
   


        elseif getPlayerItemCount(cid,7417,1) >= 1 then
            if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,7417,1) == TRUE and config.brokeChance <= math.random(100) then
            doPlayerAddItem(cid,8931,1)
            doPlayerSendTextMessage(cid,21,"Your Sword has been upgraded!")
   

        elseif getPlayerItemCount(cid,7429,1) >= 1 then
            if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,7429,1) == TRUE and config.brokeChance <= math.random(100) then
            doPlayerAddItem(cid,2437,1)
            doPlayerSendTextMessage(cid,21,"Your Club has been upgraded!")
   

        elseif getPlayerItemCount(cid,8924,1) >= 1 then
            if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,8924,1) == TRUE and config.brokeChance <= math.random(100) then
            doPlayerAddItem(cid,8926,1)
            doPlayerSendTextMessage(cid,21,"Your Axe has been upgraded!")
   

        elseif getPlayerItemCount(cid,7424,1) >= 1 then
            if doPlayerRemoveItem(cid,8306,1) == TRUE and doPlayerRemoveItem(cid,7424,1) == TRUE and config.brokeChance <= math.random(100) then
            doPlayerAddItem(cid,7958,1)
            doPlayerSendTextMessage(cid,21,"Your Wand has been upgraded!")
   
   
       else
           doPlayerSendTextMessage(cid, 22, "Failed")
           end
           end
           end
           end
           end
           end
           end
           end
           end
           end
           end

       return 1
   end
 
yes kinda, but i want to place a dust and an item on a counter an pull the lever so the dust disappear and the old item and turns into the new one, that if it success ed
One last question.
Does the dust & plate legs disappear when you fail? or just the dust?
 
Both yeah, i will try ur script when i get home thanks
Alright.
Here's my version of this script.

Put ACTIONID onto lever.

In-game.
-> Place items on opposite sides of lever
-> flop lever

-- Note. If itemid_dust is not stackable, then amount_required must be 1.
-- Note2. If itemid_dust is stackable, then amount_required max is 100.

Untested.
XML:
<action actionid="45001" event="script" value="item_upgrader.lua"/>
Lua:
local config = {
    projectile = CONST_ANI_ENERGY,
    fail = CONST_ME_MAGIC_RED,
    success = CONST_ME_MAGIC_GREEN,
    leverIDs = {1945, 1946}, -- {left, right}
    remove_base_item_on_fail = true
}
local items = {
    -- [itemid_plate_legs] = {{itemid_dust, amount_required}, itemid_of_upgraded_item, chance/10000}
    [1111] = {{2222, 1}, 3333, 10000}, -- 10000 = 100% chance
    [1111] = {{2222, 1}, 3333, 1}, ---------- 1 = 0.01% chance
    [1111] = {{2222, 1}, 3333, 5000}
}

-----------------------------------------------
local function resetLever(position)
    doTransformItem(getTileItemById(position, config.leverIDs[2]).uid, config.leverIDs[1])
end

local positions = {{-1, 0},{-1, -1},{0, -1},{1, -1},{1, 0},{1, 1},{0, 1},{-1, 1}}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == config.leverIDs[2] then
        doPlayerSendCancel(cid, "Sorry not possible. Please wait a moment.")
        return true
    end
    local temp, temp2 = 0, 0
    local found = false
    for i = 1, 8 do
        for n = 1, 10 do
            local check_pos = {x = toPosition.x + positions[i][1], y = toPosition.y + positions[i][2], z = toPosition.z, stackpos = n}
            if getThingFromPos(check_pos).itemid == 0 then
                temp = {x = check_pos.x, y = check_pos.y, z = check_pos.z, stackpos = n - 1}
                break
            end
        end
        local thing = getTileThingByPos(temp)
        if items[thing.itemid] then
            found = true
            local j = i + 4
            if j > 8 then
                j = j - 8
            end        
            for n = 1, 10 do
                local check_pos = {x = toPosition.x + positions[j][1], y = toPosition.y + positions[j][2], z = toPosition.z, stackpos = n}
                if getThingFromPos(check_pos).itemid == 0 then
                    temp2 = {x = check_pos.x, y = check_pos.y, z = check_pos.z, stackpos = n - 1}
                    break
                end
            end
            local thing2 = getTileThingByPos(temp2)
            if thing2.itemid ~= items[thing.itemid][1][1] then
                doSendMagicEffect(toPosition, CONST_ME_POFF)
                doPlayerSendCancel(cid, "Item upgrade material not found.")
                break
            end
            local thing2_count = 1
            if isItemStackable(thing2.itemid) == true then
                thing2_count = thing2.type
            end
            if thing2_count < items[thing.itemid][1][2] then
                doSendMagicEffect(toPosition, CONST_ME_POFF)
                doPlayerSendCancel(cid, "Not enough upgrade material.")
                break
            end
            doSendDistanceShoot(toPosition, temp, config.projectile)
            doSendDistanceShoot(toPosition, temp2, config.projectile)
            addEvent(doSendDistanceShoot, 350, temp, toPosition, config.projectile)
            addEvent(doSendDistanceShoot, 350, temp2, toPosition, config.projectile)
            doRemoveItem(thing2.uid, items[thing.itemid][1][2])
            local rand = math.random(10000)
            if rand > items[thing.itemid][3] then
                addEvent(doSendMagicEffect, 500, toPosition, config.fail)
                if config.remove_base_item_on_fail == true then
                    doRemoveItem(thing.uid, 1)
                end
                break
            end
            addEvent(doSendMagicEffect, 500, toPosition, config.success)
            doRemoveItem(thing.uid, 1)
            addEvent(doCreateItem, 500, items[thing.itemid][2], 1, toPosition)
            break
        end
    end
    doTransformItem(item.uid, config.leverIDs[2])
    addEvent(resetLever, 1000, toPosition)
    if found == false then
        doSendMagicEffect(toPosition, CONST_ME_POFF)
        doPlayerSendCancel(cid, "Upgradeable item not found.")
    end
    return true
end
 
Solution
so ive wrote the dust id in the
= {{2222, 1}, instead of 2222, and the item after upgrade replaced with 3333, and the old item replaced with
1111
, it says upgrade item is not found
EDITED
okay so everything worked fine after i knew that i had to put the lever in between the items, thanks to you <3
and thank you for that perfect script been looking for 2 days, thanks bud ^^
 
Last edited:
Back
Top