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

Set x amount of items to craft.

Lopaskurwa

Active Member
Joined
Oct 6, 2017
Messages
873
Solutions
2
Reaction score
49
Hi
how can i set x requirement amount to craft a item like x100 Addon doll because now you it doesnt have a function to set amount
TFS 1.2
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                          npcHandler:onThink()                        end

local config =
    {
        [1] =
            {
                name = 'Mage Helmet',
                itemsRequired = {'Addon doll', 'leaf', 'yalahari mask', 'Outfiter', 'RS Remover'}    -- qty is always 1. you can add here as many items as you want
            },
        [2] =
            {
                name = 'Knight Donate UH',
                itemsRequired = {'Addon doll', 'warlord sword', 'demon helmet', 'Outfiter', 'RS Remover'}
            },
        [3] =
            {
                name = 'Paladin Donate UH/MR',
                itemsRequired = {'Addon doll', 'arbalest', 'demon helmet', 'Outfiter', 'RS Remover'}
            }
    }

local Topic = {}

local function checkItems(cid, table)
    for _, item in ipairs(table) do
        if Player(cid):getItemCount(ItemType(item):getId()) == 0 then
            return false
        end
    end
    return true
end

local function removeItems(cid, table)
    for _, item in ipairs(table) do
        Player(cid):removeItem(ItemType(item):getId(), 1)
    end
end

function creatureSayCallback(cid, type, msg)
    msg = msg:lower()
    if not npcHandler:isFocused(cid) then
        return false
    elseif msgcontains(msg, 'runes') then
        local str = 'I can craft for you all these runes: '
        for _, item in ipairs(config) do
            if _ ~= #config - 1 then
                str = str .. '{' .. item.name:lower() .. '}, '
            else
                str = str .. '{' .. item.name:lower() .. '} and '
            end
        end
        str = str:sub(1, str:len() - 2)
        str = str .. '.'
        npcHandler:say(str, cid)
    elseif Topic[cid] ~= nil then
        if msgcontains(msg, 'yes') then
            if checkItems(cid, config[Topic[cid]].itemsRequired) then
                removeItems(cid, config[Topic[cid]].itemsRequired)
                Player(cid):addItem(ItemType(config[Topic[cid]].name):getId(), 1)
                npcHandler:say('Thank you very much! Come back anytime you want!!', cid)
                Topic[cid] = nil
            else
                npcHandler:say('Do not waste my time.', cid)
                Topic[cid] = nil
            end
        else
            npcHandler:say('Do not waste my time.', cid)
            Topic[cid] = nil
        end
    else
        for _, item in ipairs(config) do
            if msgcontains(msg, item.name) then
                Topic[cid] = _
                local str = 'To craft a ' .. item.name:lower() .. ' you will need: '
                for _, items in ipairs(item.itemsRequired) do
                    if _ ~= #item.itemsRequired - 1 then
                        str = str .. 'a {' .. items:lower() .. '}, '
                    else
                        str = str .. 'a {' .. items:lower() .. '} and '
                    end
                end
                str = str:sub(1, str:len() - 2)
                str = str .. '. Do you have them?'
                npcHandler:say(str, cid)
                break
            end
        end
    end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Solution
Hi
how can i set x requirement amount to craft a item like x100 Addon doll because now you it doesnt have a function to set amount
TFS 1.2
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                          npcHandler:onThink()                        end

local config =
    {
        [1] =
            {
                name = 'Mage Helmet'...
Hi
how can i set x requirement amount to craft a item like x100 Addon doll because now you it doesnt have a function to set amount
TFS 1.2
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                          npcHandler:onThink()                        end

local config =
    {
        [1] =
            {
                name = 'Mage Helmet',
                itemsRequired = {'Addon doll', 'leaf', 'yalahari mask', 'Outfiter', 'RS Remover'}    -- qty is always 1. you can add here as many items as you want
            },
        [2] =
            {
                name = 'Knight Donate UH',
                itemsRequired = {'Addon doll', 'warlord sword', 'demon helmet', 'Outfiter', 'RS Remover'}
            },
        [3] =
            {
                name = 'Paladin Donate UH/MR',
                itemsRequired = {'Addon doll', 'arbalest', 'demon helmet', 'Outfiter', 'RS Remover'}
            }
    }

local Topic = {}

local function checkItems(cid, table)
    for _, item in ipairs(table) do
        if Player(cid):getItemCount(ItemType(item):getId()) == 0 then
            return false
        end
    end
    return true
end

local function removeItems(cid, table)
    for _, item in ipairs(table) do
        Player(cid):removeItem(ItemType(item):getId(), 1)
    end
end

function creatureSayCallback(cid, type, msg)
    msg = msg:lower()
    if not npcHandler:isFocused(cid) then
        return false
    elseif msgcontains(msg, 'runes') then
        local str = 'I can craft for you all these runes: '
        for _, item in ipairs(config) do
            if _ ~= #config - 1 then
                str = str .. '{' .. item.name:lower() .. '}, '
            else
                str = str .. '{' .. item.name:lower() .. '} and '
            end
        end
        str = str:sub(1, str:len() - 2)
        str = str .. '.'
        npcHandler:say(str, cid)
    elseif Topic[cid] ~= nil then
        if msgcontains(msg, 'yes') then
            if checkItems(cid, config[Topic[cid]].itemsRequired) then
                removeItems(cid, config[Topic[cid]].itemsRequired)
                Player(cid):addItem(ItemType(config[Topic[cid]].name):getId(), 1)
                npcHandler:say('Thank you very much! Come back anytime you want!!', cid)
                Topic[cid] = nil
            else
                npcHandler:say('Do not waste my time.', cid)
                Topic[cid] = nil
            end
        else
            npcHandler:say('Do not waste my time.', cid)
            Topic[cid] = nil
        end
    else
        for _, item in ipairs(config) do
            if msgcontains(msg, item.name) then
                Topic[cid] = _
                local str = 'To craft a ' .. item.name:lower() .. ' you will need: '
                for _, items in ipairs(item.itemsRequired) do
                    if _ ~= #item.itemsRequired - 1 then
                        str = str .. 'a {' .. items:lower() .. '}, '
                    else
                        str = str .. 'a {' .. items:lower() .. '} and '
                    end
                end
                str = str:sub(1, str:len() - 2)
                str = str .. '. Do you have them?'
                npcHandler:say(str, cid)
                break
            end
        end
    end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                          npcHandler:onThink()                        end

local config = {
    [1] = {
        name = 'Mage Helmet',
        itemsRequired = {{'Addon doll', 1}, {'leaf', 1}, {'yalahari mask', 1}, {'Outfiter', 1}, {'RS Remover', 1}}
    },
    [2] = {
        name = 'Knight Donate UH',
        itemsRequired = {{'Addon doll', 1}, {'warlord sword', 1}, {'demon helmet', 1}, {'Outfiter', 1}, {'RS Remover', 1}}
    },
    [3] = {
        name = 'Paladin Donate UH/MR',
        itemsRequired = {{'Addon doll', 1}, {'arbalest', 1}, {'demon helmet', 1}, {'Outfiter', 1}, {'RS Remover', 1}}
    }
}

local function checkItems(cid, table)
    for _, item in ipairs(table) do
        if Player(cid):getItemCount(ItemType(item[1]):getId()) < item[2] then
            return false
        end
    end
    return true
end

local function removeItems(cid, table)
    for _, item in ipairs(table) do
        Player(cid):removeItem(ItemType(item[1]):getId(), item[2])
    end
end

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    if npcHandler.topic[cid] < 1 then
        if msgcontains(msg, 'rune') then
            local string = 'I can craft for you all these runes:'
            for key, item in pairs(config) do
                if not next(config, key) then
                    string = string .. " and " .. item.name .. "."
                else
                    string = string .. " " .. item.name .. ","
                end
            end
            npcHandler:say(string, cid)
            npcHandler.topic[cid] = 1
        end
    elseif npcHandler.topic[cid] == 1 then
        for key, item in pairs(config) do
            if msg:lower() == item.name:lower() then
                local string = "To craft a " .. item.name:lower() .. " you will need:"
                for req_key, req_item in pairs(item.itemsRequired) do
                    local type = ItemType(req_item[1])
                    if not type or type:getId() < 1 then print("Type does not exist with name " .. req_item[1]) return true end

                    local article = req_item[2] == 1 and type:getArticle() or req_item[2]
                    local name = req_item[2] == 1 and req_item[1] or type:getPluralName()
                    if not next(item.itemsRequired, req_key) then
                        string = string .. " and " .. article .. " " .. name .. "."
                    else
                        string = string .. " " .. article .. " " .. name .. ","
                    end
                end
                npcHandler:say(string .. " Do you have them?", cid)
                npcHandler.topic[cid] = key + 1
                return true
            end
        end
        npcHandler.topic[cid] = 0
    elseif npcHandler.topic[cid] > 1 then
        if msgcontains(msg, "yes") then
            local item = config[npcHandler.topic[cid] - 1]
            if ItemType(item.name):getId() < 1 then print("Type does not exist with name " .. item.name) return true end
            if checkItems(cid, item.itemsRequired) then
                removeItems(cid, item.itemsRequired)
                Player(cid):addItem(ItemType(item.name):getId(), 1)
                npcHandler:say('Thank you very much! Come back anytime you want!!', cid)
            else
                npcHandler:say('You do not have the required items.', cid)
            end
        else
            npcHandler:say('Do not waste my time.', cid)
        end
        npcHandler.topic[cid] = 0
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Solution
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                          npcHandler:onThink()                        end

local config = {
    [1] = {
        name = 'Mage Helmet',
        itemsRequired = {{'Addon doll', 1}, {'leaf', 1}, {'yalahari mask', 1}, {'Outfiter', 1}, {'RS Remover', 1}}
    },
    [2] = {
        name = 'Knight Donate UH',
        itemsRequired = {{'Addon doll', 1}, {'warlord sword', 1}, {'demon helmet', 1}, {'Outfiter', 1}, {'RS Remover', 1}}
    },
    [3] = {
        name = 'Paladin Donate UH/MR',
        itemsRequired = {{'Addon doll', 1}, {'arbalest', 1}, {'demon helmet', 1}, {'Outfiter', 1}, {'RS Remover', 1}}
    }
}

local function checkItems(cid, table)
    for _, item in ipairs(table) do
        if Player(cid):getItemCount(ItemType(item[1]):getId()) < item[2] then
            return false
        end
    end
    return true
end

local function removeItems(cid, table)
    for _, item in ipairs(table) do
        Player(cid):removeItem(ItemType(item[1]):getId(), item[2])
    end
end

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    if npcHandler.topic[cid] < 1 then
        if msgcontains(msg, 'rune') then
            local string = 'I can craft for you all these runes:'
            for key, item in pairs(config) do
                if not next(config, key) then
                    string = string .. " and " .. item.name .. "."
                else
                    string = string .. " " .. item.name .. ","
                end
            end
            npcHandler:say(string, cid)
            npcHandler.topic[cid] = 1
        end
    elseif npcHandler.topic[cid] == 1 then
        for key, item in pairs(config) do
            if msg:lower() == item.name:lower() then
                local string = "To craft a " .. item.name:lower() .. " you will need:"
                for req_key, req_item in pairs(item.itemsRequired) do
                    local type = ItemType(req_item[1])
                    if not type or type:getId() < 1 then print("Type does not exist with name " .. req_item[1]) return true end

                    local article = req_item[2] == 1 and type:getArticle() or req_item[2]
                    local name = req_item[2] == 1 and req_item[1] or type:getPluralName()
                    if not next(item.itemsRequired, req_key) then
                        string = string .. " and " .. article .. " " .. name .. "."
                    else
                        string = string .. " " .. article .. " " .. name .. ","
                    end
                end
                npcHandler:say(string .. " Do you have them?", cid)
                npcHandler.topic[cid] = key + 1
                return true
            end
        end
        npcHandler.topic[cid] = 0
    elseif npcHandler.topic[cid] > 1 then
        if msgcontains(msg, "yes") then
            local item = config[npcHandler.topic[cid] - 1]
            if ItemType(item.name):getId() < 1 then print("Type does not exist with name " .. item.name) return true end
            if checkItems(cid, item.itemsRequired) then
                removeItems(cid, item.itemsRequired)
                Player(cid):addItem(ItemType(item.name):getId(), 1)
                npcHandler:say('Thank you very much! Come back anytime you want!!', cid)
            else
                npcHandler:say('You do not have the required items.', cid)
            end
        else
            npcHandler:say('Do not waste my time.', cid)
        end
        npcHandler.topic[cid] = 0
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
I have one edit to ask, since i have over 50items that i can craft they doesnt fit in NPCs channel so as far as i understand i have to edit this line
Lua:
    if npcHandler.topic[cid] < 1 then
        if msgcontains(msg, 'items') then
            local string = 'I can craft for you all these items:'
            for key, item in pairs(config) do
                if not next(config, key) then
                    string = string .. " and " .. item.name .. "."
                else
                    string = string .. " " .. item.name .. ","
                end
            end
            npcHandler:say(string, cid)
            npcHandler.topic[cid] = 1
        end

so it would be like this
P:hi
Npc: W/e
P: items
Npc: Say the item name you want to craft.
(Do not show items what you can craft since they do not fit)
 
I have one edit to ask, since i have over 50items that i can craft they doesnt fit in NPCs channel so as far as i understand i have to edit this line
Lua:
    if npcHandler.topic[cid] < 1 then
        if msgcontains(msg, 'items') then
            local string = 'I can craft for you all these items:'
            for key, item in pairs(config) do
                if not next(config, key) then
                    string = string .. " and " .. item.name .. "."
                else
                    string = string .. " " .. item.name .. ","
                end
            end
            npcHandler:say(string, cid)
            npcHandler.topic[cid] = 1
        end

so it would be like this
P:hi
Npc: W/e
P: items
Npc: Say the item name you want to craft.
(Do not show items what you can craft since they do not fit)
Try this one out, hope it works well:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                          npcHandler:onThink()                        end

local config = { -- KEEP ALL LOWER CASE
    ['mage helmet'] = {{'addon doll', 1}, {'leaf', 1}, {'yalahari mask', 1}, {'outfiter', 1}, {'rs remover', 1}},
    ['knight donate uh'] = {{'addon doll', 1}, {'warlord sword', 1}, {'demon helmet', 1}, {'outfiter', 1}, {'rs remover', 1}},
    ['paladin donate uh/mr'] = {{{'addon doll', 1}, {'arbalest', 1}, {'demon helmet', 1}, {'outfiter', 1}, {'rs remover', 1}}},
}

craft_storage = craft_storage or {}

function Player:checkCraftItems(table)
    for _, item in ipairs(table) do
        if self:getItemCount(ItemType(item[1]):getId()) < item[2] then
            return false
        end
    end
    return true
end

function Player:removeCraftItems(table)
    for _, item in ipairs(table) do
        self:removeItem(ItemType(item[1]):getId(), item[2])
    end
end

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    local msg = msg:lower()
    if npcHandler.topic[cid] < 1 then
        local craft_items = config[msg]
        if craft_items then
            local string = "To craft a " .. msg .. " you will need:"
            for key, item in pairs(craft_items) do
                local type = ItemType(item[1])
                if not type or type:getId() < 1 then print("Type does not exist with name " .. item[1]) return true end

                local article = item[2] == 1 and type:getArticle() or item[2]
                local name = item[2] == 1 and item[1] or type:getPluralName()
                if not next(craft_items, key) then
                    string = string .. " and " .. article .. " " .. name .. "."
                else
                    string = string .. " " .. article .. " " .. name .. ","
                end
            end
            npcHandler:say(string .. " Do you have them?", cid)
            npcHandler.topic[cid] = 1
            craft_storage[cid] = msg
        else
            npcHandler:say("Please tell me an item you would like to craft.", cid)
        end
    elseif npcHandler.topic[cid] == 1 then
        local craft_items = config[craft_storage[cid]]
        if craft_items and msgcontains(msg, "yes") then
            local type = ItemType(storage[cid])
            if not type or type:getId() < 1 then print("Type does not exist with name " .. storage[cid]) return true end
            if player:checkCraftItems(craft_items) then
                player:removeCraftItems(craft_items)
                player:addItem(type:getId(), 1)
                npcHandler:say('Thank you very much! Come back anytime you want!!', cid)
            else
                npcHandler:say('You do not have the required items.', cid)
            end
        else
            npcHandler:say('Do not waste my time.', cid)
        end
        npcHandler.topic[cid] = 0
        craft_storage[cid] = nil
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Try this one out, hope it works well:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                          npcHandler:onThink()                        end

local config = { -- KEEP ALL LOWER CASE
    ['mage helmet'] = {{'addon doll', 1}, {'leaf', 1}, {'yalahari mask', 1}, {'outfiter', 1}, {'rs remover', 1}},
    ['knight donate uh'] = {{'addon doll', 1}, {'warlord sword', 1}, {'demon helmet', 1}, {'outfiter', 1}, {'rs remover', 1}},
    ['paladin donate uh/mr'] = {{{'addon doll', 1}, {'arbalest', 1}, {'demon helmet', 1}, {'outfiter', 1}, {'rs remover', 1}}},
}

craft_storage = craft_storage or {}

function Player:checkCraftItems(table)
    for _, item in ipairs(table) do
        if self:getItemCount(ItemType(item[1]):getId()) < item[2] then
            return false
        end
    end
    return true
end

function Player:removeCraftItems(table)
    for _, item in ipairs(table) do
        self:removeItem(ItemType(item[1]):getId(), item[2])
    end
end

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    local msg = msg:lower()
    if npcHandler.topic[cid] < 1 then
        local craft_items = config[msg]
        if craft_items then
            local string = "To craft a " .. msg .. " you will need:"
            for key, item in pairs(craft_items) do
                local type = ItemType(item[1])
                if not type or type:getId() < 1 then print("Type does not exist with name " .. item[1]) return true end

                local article = item[2] == 1 and type:getArticle() or item[2]
                local name = item[2] == 1 and item[1] or type:getPluralName()
                if not next(craft_items, key) then
                    string = string .. " and " .. article .. " " .. name .. "."
                else
                    string = string .. " " .. article .. " " .. name .. ","
                end
            end
            npcHandler:say(string .. " Do you have them?", cid)
            npcHandler.topic[cid] = 1
            craft_storage[cid] = msg
        else
            npcHandler:say("Please tell me an item you would like to craft.", cid)
        end
    elseif npcHandler.topic[cid] == 1 then
        local craft_items = config[craft_storage[cid]]
        if craft_items and msgcontains(msg, "yes") then
            local type = ItemType(storage[cid])
            if not type or type:getId() < 1 then print("Type does not exist with name " .. storage[cid]) return true end
            if player:checkCraftItems(craft_items) then
                player:removeCraftItems(craft_items)
                player:addItem(type:getId(), 1)
                npcHandler:say('Thank you very much! Come back anytime you want!!', cid)
            else
                npcHandler:say('You do not have the required items.', cid)
            end
        else
            npcHandler:say('Do not waste my time.', cid)
        end
        npcHandler.topic[cid] = 0
        craft_storage[cid] = nil
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
It works but is it possible to keep same local config structure? And btw i can flood "items" keyword so if i say "hi "items" npc will say "Please tell me an item you would like to craft" so i can spwan "items" as much as i want and make that npc call this text everytime so i dont think its a good think since some people could abuse it and it could lead to a crash maybe.
 
It works but is it possible to keep same local config structure? And btw i can flood "items" keyword so if i say "hi "items" npc will say "Please tell me an item you would like to craft" so i can spwan "items" as much as i want and make that npc call this text everytime so i dont think its a good think since some people could abuse it and it could lead to a crash maybe.
What is your need for the original config structure, this method is faster to use since you don't have to loop through the config every time, instead you just call it from the index.

For the abuse question, the same can be said about any npc. If you spam job, hi then bye, or whatever it's still the same issue. If you want to fix this script you can remove the:
Lua:
        else
            npcHandler:say("Please tell me an item you would like to craft.", cid)

Then just add the "tell me an item you would like to craft" to the npc's greeting.
 
What is your need for the original config structure, this method is faster to use since you don't have to loop through the config every time, instead you just call it from the index.

For the abuse question, the same can be said about any npc. If you spam job, hi then bye, or whatever it's still the same issue. If you want to fix this script you can remove the:
Lua:
        else
            npcHandler:say("Please tell me an item you would like to craft.", cid)

Then just add the "tell me an item you would like to craft" to the npc's greeting.
Okay
 
What is your need for the original config structure, this method is faster to use since you don't have to loop through the config every time, instead you just call it from the index.

For the abuse question, the same can be said about any npc. If you spam job, hi then bye, or whatever it's still the same issue. If you want to fix this script you can remove the:
Lua:
        else
            npcHandler:say("Please tell me an item you would like to craft.", cid)

Then just add the "tell me an item you would like to craft" to the npc's greeting.
Well tested if i delete
else
npcHandler:say("Please tell me an item you would like to craft.", cid)
This whole stuff doesnt even work after that.
 
Well tested if i delete
else
npcHandler:say("Please tell me an item you would like to craft.", cid)
This whole stuff doesnt even work after that.
The if statement is based off:
Lua:
local craft_items = config[msg]
if craft_items then

So if it's not doing anything then you are not writing an item name that's included in the config, or you deleted something you shouldn't have.
 
The if statement is based off:
Lua:
local craft_items = config[msg]
if craft_items then

So if it's not doing anything then you are not writing an item name that's included in the config, or you deleted something you shouldn't have.
Fuck forgot it has to be not caps. Have last question related with this system what if i want to add ability to craft same item but with different item requirement.
Lua:
    ['demon sword'] = {{'big sword', 1}, {'sword card', 2}, {'demon card', 8}},
    ['demon sword'] = {{'small sword', 1}, {'sword card', 2}, {'demon card', 10}},
As you can see it has same item name so what will happen? How to make it work properly ?
Tested more it gives
35970
 
Last edited:
Back
Top