• 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 Item+item = new item

freaked1

Active Member
Joined
Jan 30, 2008
Messages
486
Solutions
5
Reaction score
30
Location
Sweden
Hello! I have a script for this buy it only works once on the server. Could someone please fix this code?

Code:
    local config = {
        recipes = {
                5890,
                5902
        },
        positions = {
                {x = 968, y = 1047, z = 6, stackpos = 255},
                {x = 970, y = 1047, z = 6, stackpos = 255}
        },
        newItem = {5891, 1} -- {id, count}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
        local items = {}
        for i = 1, #config.positions do
                local recipe = getThingFromPos(config.positions[i])
                if isInArray(config.recipes, recipe.itemid) then
                        table.insert(items, recipe)
                        table.remove(config.recipes, table.find(config.recipes, 

recipe.itemid))
                else
                        local recipeString = "You need ".. 

getItemArticleById(config.recipes[1]) .." ".. getItemNameById(recipe.itemid)
                        for r = 2, #config.recipes do
                                recipeString = recipeString ..", ".. 

getItemArticleById(config.recipes[r]) .." ".. getItemNameById(config.recipes[r])
                        end
                        doPlayerSendTextMessage(cid, 22, recipeString ..".")
                       
                        return FALSE
                end
        end
       
        if item.itemid == 1945 then
                doTransformItem(item.uid, item.itemid + 1)
        elseif item.itemid == 1946 then
                doTransformItem(item.uid, item.itemid - 1)
        end
       
        for item = 1, #items do
                doRemoveItem(items[item].uid, 1)
                doSendMagicEffect(getThingPos(items[item]), 2)
        end

        doPlayerAddItem(cid, unpack(config.newItem))
        doSendMagicEffect(fromPosition, 14)
        doPlayerSendTextMessage(cid, 22, "You have found ".. config.newItem[2] .." ".. 

getItemArticleById(config.newItem[1]) .. " " .. getItemNameById(config.newitem[1]) .. ".")

        return TRUE
end

It is making enchanted chicken wings out of Chicken feather and a honeycomb. But only once, after that it says that I need either Chicken feather or Honeycomb.
I have to restart the server if I want to do it again.
 
Back
Top