Lineage 2 Tower Forum

Full Version: Auto Enchant Script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, can someone help me. The auto enchant script works fine until item fails then it stops.

Code:
function enchantResult()
  return GetEnchantManager():getLastResult()
end

function getItemByName(name, maxenchant)
    invList = GetInventory();
    for item in invList.list do
        if item.Name == name and item.Enchanted < maxenchant then
            -- ShowToClient("ITEM", item.Name .. " (ID: " .. item.displayId  .. ")");
            return item
        end
    end
end

maxenchant = 20
GetEnchantManager():setDelay(200)

while true do
    -- weapon = getItemByName("Draconic Leather Boots", maxenchant)
    -- enchant = getItemByName("Scroll: Enchant Armor (Grade S)", maxenchant)
    Sleep ( 1000 ) -- sleep so item data is updated
    weapon = getItemByName("Draconic Leather Boots", maxenchant)
    enchant = getItemByName("Scroll: Enchant Armor (Grade S)", maxenchant)

    if ( weapon.Enchanted > maxenchant ) then
        ShowToClient("Enchant:", "Reached desired enchant")
        break
    end

    GetEnchantManager():setEnchantId(enchant.objectId)
    GetEnchantManager():setItemId(weapon.objectId)
    GetEnchantManager():Enchant()
    -- ShowToClient(">>>>",  "Waiting for result...");
    while ( enchantResult() == Enchant.ENCHANT_PENDING ) do
        Sleep(200)
    end
    if ( enchantResult() == Enchant.ENCHANT_SUCCESS ) then    
        Sleep ( 100 ) -- sleep so item data is updated
        weapon = GetInventory():FindById(weapon.objectId)
        ShowToClient("Enchant",  weapon.Name .. " is now +" .. weapon.Enchanted);
    end
end
Some help plx?
by default when you update l2tower you get 2 scripts to enchant ites, they dont works for you?
Its the same they work, until item fails. Then it stops and i have to restart the script to start again.
Reference URL's