Piotrek1447
Member
Here is piece of shit what i latest do for my friend - he don't need it now so i release this.
How it work? You must have a container in arrow slot and put items in it required to craft other things, in this example is spear and wood.
After this, type !craft spear and thats all.
Remember, if put nonStackable item count must be 0!
How it work? You must have a container in arrow slot and put items in it required to craft other things, in this example is spear and wood.
After this, type !craft spear and thats all.
Remember, if put nonStackable item count must be 0!
XML:
<talkaction words="!craft;/craft" event="script" value="craft.lua"/>
Lua:
local crafting =
{
["spear"] = {requiredItems = {{5880, 1}, {5901, 1}}, createItem = 2389, count = 2},
["wood"] = {requiredItems = {{8582, 0}, {8582, 0}, {8582, 0}, {8582, 0}}, createItem = 5901, count = 1},
}
function onSay(cid, words, param)
local craft = crafting[param:lower()]
if(not craft) then
return true
end
local slot = getPlayerSlotItem(cid, CONST_SLOT_AMMO).uid
if(not isContainer(slot)) then
doPlayerSendCancel(cid, "Put container with items in ammo slot.")
return true
end
local check = false
for c = 1, getContainerSize(slot) do
local item = getContainerItem(slot, c - 1)
for i, req in ipairs(craft.requiredItems) do
if(item.itemid == req[1] and item.type >= req[2]) then
if(table.maxn(craft.requiredItems) == getContainerSize(slot)) then
check = true
end
end
end
end
if(check) then
for i, req in ipairs(craft.requiredItems) do
doPlayerRemoveItem(cid, req[1], req[2] == 0 and 1 or req[2])
end
doPlayerAddItem(cid, craft.createItem, craft.count)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You succesfully craft " .. getItemInfo(craft.createItem).article .. " " .. craft.count .. " " .. getItemNameById(craft.createItem) .. (craft.count > 1 and "s" or "") .. "!")
else
doPlayerSendCancel(cid, "You don't have enough items.")
return true
end
return true
end