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

Craft Man.

Nani3601

elhanan
Joined
May 18, 2012
Messages
92
Reaction score
3
Location
israel
is there any one who can help me with crafting/upgrading items ?

i make custom items for some few items. i will show in picture.. ( New-Bitmap-Image-4 (https://ibb.co/Qd2tymJ) )
in this picture you will see a normal set and items that needed to upgrade them to the new custom set..
so how can i make those items to upgrade to the new custom ?
please dont mind the items i put to upgrade. that was for example :D hehe
 
Solution
i did it for example. but i didnt really understand where i put it... i tried on actions but im not sure i did it right.. i just faild.
local config = {
-- [currentItemId] -- requiredItems = {{itemid, amount}, {1111, 1}, {1111, 1}}
[2506] = { newItem = 26404, requiredItems = {{5877, 100}, {5920, 100}, {6546, 1} } },
[2492] = { newItem = 26405, requiredItems = { {5877, 100}, {5920, 100}, {6546, 1} } }
}



local item = -- grab the item however you want
local itemId = item:getId()

if config[itemId] then
local items = config[itemId].requiredItems
local hasItems = true
for i = 1, #items do
if player:getItemCount(items[1]) < items[2] then
hasItems = false
break
end
end

if hasItems...
Here is one way of doing it.
This way, you'd assume that the player has the required items in their inventory, and the newItem would be added into their inventory as well.

Just add this into whatever script you're wanting to use.

Lua:
local config = {
--  [currentItemId]        -- requiredItems = {{itemid, amount}, {1111, 1}, {1111, 1}}
    [1111] = { newItem = 2222, requiredItems = { {1111, 1}, {1111, 1}, {1111, 1} } },
    [3333] = { newItem = 4444, requiredItems = { {1111, 1}, {1111, 1}, {1111, 1} } }
}



local item = -- grab the item however you want
local itemId = item:getId()

if config[itemId] then
    local items = config[itemId].requiredItems
    local hasItems = true
    for i = 1, #items do
        if player:getItemCount(items[i][1]) < items[i][2] then
            hasItems = false
            break
        end
    end
  
    if hasItems then
        for i = 1, #items do
            player:removeItem(items[i][1], items[i][2])
        end
        item:remove(1)
        player:addItem(config[itemId].newItem, 1)
    end
end
 
this script you give me i add it to npc or where i add it ? sorry im pretty new in those things :D
You can add it anywhere you want.

npc/actions/movements/talkaction/et cetera

As long as you grab the item information at some point, you can use it anywhere.
 
i did it for example. but i didnt really understand where i put it... i tried on actions but im not sure i did it right.. i just faild.
local config = {
-- [currentItemId] -- requiredItems = {{itemid, amount}, {1111, 1}, {1111, 1}}
[2506] = { newItem = 26404, requiredItems = { {5877, 100}, {5920, 100}, {6546, 1} } },
[2492] = { newItem = 26405, requiredItems = { {5877, 100}, {5920, 100}, {6546, 1} } }
}



local item = -- grab the item however you want
local itemId = item:getId()

if config[itemId] then
local items = config[itemId].requiredItems
local hasItems = true
for i = 1, #items do
if player:getItemCount(items[1]) < items[2] then
hasItems = false
break
end
end

if hasItems then
for i = 1, #items do
player:removeItem(items[1], items[2])
end
item:remove(1)
player:addItem(config[itemId].newItem, 1)
end
end

can u show me example of where/how you put it.
 
i did it for example. but i didnt really understand where i put it... i tried on actions but im not sure i did it right.. i just faild.
local config = {
-- [currentItemId] -- requiredItems = {{itemid, amount}, {1111, 1}, {1111, 1}}
[2506] = { newItem = 26404, requiredItems = {{5877, 100}, {5920, 100}, {6546, 1} } },
[2492] = { newItem = 26405, requiredItems = { {5877, 100}, {5920, 100}, {6546, 1} } }
}



local item = -- grab the item however you want
local itemId = item:getId()

if config[itemId] then
local items = config[itemId].requiredItems
local hasItems = true
for i = 1, #items do
if player:getItemCount(items[1]) < items[2] then
hasItems = false
break
end
end

if hasItems then
for i = 1, #items do
player:removeItem(items[1], items[2])
end
item:remove(1)
player:addItem(config[itemId].newItem, 1)
end
end

can u show me example of where/how you put it.
This is a revscript action script, as an example.

We've replaced 'item' with 'target', as the intention would be to use some item on another item, and that 'other' item would attempt to be transformed, based on the config.
Lua:
local config = {
--  [currentItemId]        -- requiredItems = {{itemid, amount}, {1111, 1}, {1111, 1}}
    [1111] = { newItem = 2222, requiredItems = {{1111, 1}, {1111, 1}, {1111, 1}} },
    [3333] = { newItem = 4444, requiredItems = {{1111, 1}, {1111, 1}, {1111, 1}} }
}

local craftMan = Action()

function craftMan.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local itemId = target:getId()
  
    if config[itemId] then
        local items = config[itemId].requiredItems
        local hasItems = true
        for i = 1, #items do
            if player:getItemCount(items[i][1]) < items[i][2] then
                hasItems = false
                break
            end
        end
  
        if hasItems then
            for i = 1, #items do
                player:removeItem(items[i][1], items[i][2])
            end
            target:remove(1)
            player:addItem(config[itemId].newItem, 1)
        end
    end
    return true
end

craftMan:id(11111) -- an item that can be used on another item
craftMan:register()
 
Solution
ohhh work perfect!! thanks <3
Post automatically merged:

btw i see you have upgrade system to add bonus on items.. i can pay if need to i just need your help to make it.. i tryed and failed :D

 
Last edited:
Back
Top