• 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 Request for Varkhal Addon NPC TFS 1.2

Solution
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
local talkState = {}
local rtnt = {}
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

npcHandler:setMessage(MESSAGE_GREET, "Greetings |PLAYERNAME|. I need your help and I'll reward you with nice addons if you help me! Just say {addons} or {help} if you don't know what to do.")

addoninfo = {
['first citizen addon']...
Lua:
local text = '--Addon List--\n!addon citizen\n!addon hunter\n!addon mage\n!addon knight\n!addon summoner\n!addon warrior\n!addon barbarian\n!addon druid\n!addon wizard\n!addon oriental\n!addon pirate\n!addon assassin\n!addon beggar\n!addon demonhunter\n!addon shaman\n!addon norseman\n!addon nightmare\n!addon jester\n!addon brotherhood\n!addon warmaster\n!addon wayfarer\n!addon afflicted\n!addon yalaharian\n--Addon List End--'
 
function onSay(cid, words, param)
local player = Player(cid)
    local cfg = {
        ["citizen"] = {
            outfit = {
                male = 128,
                female = 136,
                addon = 3,
                storage = 10031
            },
            items = {
                {2160, 1}
            }
        },
        ["hunter"] = {
            outfit = {
                male = 129,
                female = 137,
                addon = 3,
                storage = 10032
            },
            items = {
                {2160, 1}
            }
        },
        ["mage"] = {
            outfit = {
                male = 130,
                female = 138,
                addon = 3,
                storage = 10033
            },
            items = {
                {2160, 1}
            }
        },
        ["knight"] = {
            outfit = {
                male = 131,
                female = 139,
                addon = 3,
                storage = 10034
            },
            items = {
                {2160, 1}
            }
        },
        ["summoner"] = {
            outfit = {
                male = 133,
                female = 141,
                addon = 3,
                storage = 10035
            },
            items = {
                {2160, 1}
            }
        },
        ["warrior"] = {
            outfit = {
                male = 134,
                female = 142,
                addon = 3,
                storage = 10029
            },
            items = {
                {2160, 1}
            }
        },
        ["barbarian"] = {
            outfit = {
                male = 143,
                female = 147,
                addon = 3,
                storage = 10037
            },
            items = {
                {2160, 1}
            }
        },
        ["wizard"] = {
            outfit = {
                male = 145,
                female = 149,
                addon = 3,
                storage = 10049
            },
            items = {
                {2160, 1}
            }
        },
        ["pirate"] = {
            outfit = {
                male = 151,
                female = 155,
                addon = 3,
                storage = 10041
            },
            items = {
                {2160, 1}
            }
        },
        ["assassin"] = {
            outfit = {
                male = 152,
                female = 156,
                addon = 3,
                storage = 10042
            },
            items = {
                {2160, 1}
            }
        },
        ["beggar"] = {
            outfit = {
                male = 153,
                female = 157,
                addon = 3,
                storage = 10043
            },
            items = {
                {2160, 1}
            }
        },
        ["shaman"] = {
            outfit = {
                male = 154,
                female = 158,
                addon = 3,
                storage = 10044
            },
            items = {
                {2160, 1}
            }
        },
        ["norseman"] = {
            outfit = {
                male = 251,
                female = 252,
                addon = 3,
                storage = 10045
            },
            items = {
                {2160, 1}
            }
        },
        ["nightmare"] = {
            outfit = {
                male = 268,
                female = 269,
                addon = 3,
                storage = 10046
            },
            items = {
                {2160, 1}
            }
        },
        ["jester"] = {
            outfit = {
                male = 273,
                female = 270,
                addon = 3,
                storage = 10047
            },
            items = {
                {2160, 1}
            }
        },
        ["brotherhood"] = {
            outfit = {
                male = 278,
                female = 279,
                addon = 3,
                storage = 10048
            },
            items = {
                {2160, 1}
            }
        },
        ["demonhunter"] = {
            outfit = {
                male = 289,
                female = 288,
                addon = 3,
                storage = 10051
            },
            items = {
                {2160, 1}
            }
        },
        ["yalaharian"] = {
            outfit = {
                male = 325,
                female = 324,
                addon = 3,
                storage = 10052
            },
            items = {
                {2160, 1}
            }
        },
        ["warmaster"] = {
            outfit = {
                male = 335,
                female = 336,
                addon = 3,
                storage = 10053
            },
            items = {
                {2160, 1}
            }
        },
        ["wayfarer"] = {
            outfit = {
                male = 367,
                female = 366,
                addon = 3,
                storage = 10054
            },
            items = {
                {2160, 1}
            }
        },
        ["afflicted"] = {
            outfit = {
                male = 430,
                female = 431,
                addon = 3,
                storage = 10055
            },
            items = {
                {2160, 1}
            }
        },
        ["nobleman"] = {
            outfit = {
                male = 132,
                female = 140,
                addon = 3,
                storage = 10056
            },
            items = {
                {2160, 1}
            }
        },
        ["druid"] = {
            outfit = {
                male = 144,
                female = 148,
                addon = 3,
                storage = 10057
            },
            items = {
                {2160, 1}
            }
        },
        ["oriental"] = {
            outfit = {
                male = 146,
                female = 150,
                addon = 3,
                storage = 10058
            },
            items = {
                {2160, 1}
            }
        },
    }
    local v, removeItems = cfg[param], 0, 0
          if(param == "") then
              player:sendTextMessage(MESSAGE_INFO_DESCR, 'Please type !addon outfit')
        player:showTextDialog( 5914, text)
    return false
    end
    if (v == nil) then
          player:sendTextMessage(MESSAGE_INFO_DESCR, "There is no such as outfit named "..param..", here is the list of available outfit.")
        player:showTextDialog(5914, text)
    return false
    end
    if(player:getStorageValue(v.outfit.storage) < 1) then
        for i = 1, #v.items do
            if(player:getItemCount(v.items[i][1]) >= v.items[i][2]) then
                removeItems = removeItems+1
            end
        end
        if(removeItems == #v.items) then
            if(player:getSex(cid) == 1) then
                player:addOutfitAddon(v.outfit.male, v.outfit.addon)
            elseif(player:getSex(cid) == 0) then
                player:addOutfitAddon( v.outfit.female, v.outfit.addon)
            end
            for i = 1, #v.items do
                player:removeItem( v.items[i][1], v.items[i][2])
            end
              player:sendTextMessage(MESSAGE_INFO_DESCR, "Enjoy your new addons to your "..param.." outfit!")
                    player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
            player:setStorageValue( v.outfit.storage, 1)
        else
            for i = 1, #v.items do
                  player:sendTextMessage(MESSAGE_INFO_DESCR, "you need " .. v.items[i][2] .. "x " .. ItemType(v.items[i][1]):getName() .. " to get the "..param.." addon.")
            end
        end
    else
          player:sendTextMessage(MESSAGE_INFO_DESCR, "you already got the "..param.." addon.")
    end
    return false
end

iam using this command for addons if your don't care npc or command both gives addons with the price you decide
 
Lua:
local text = '--Addon List--\n!addon citizen\n!addon hunter\n!addon mage\n!addon knight\n!addon summoner\n!addon warrior\n!addon barbarian\n!addon druid\n!addon wizard\n!addon oriental\n!addon pirate\n!addon assassin\n!addon beggar\n!addon demonhunter\n!addon shaman\n!addon norseman\n!addon nightmare\n!addon jester\n!addon brotherhood\n!addon warmaster\n!addon wayfarer\n!addon afflicted\n!addon yalaharian\n--Addon List End--'

function onSay(cid, words, param)
local player = Player(cid)
    local cfg = {
        ["citizen"] = {
            outfit = {
                male = 128,
                female = 136,
                addon = 3,
                storage = 10031
            },
            items = {
                {2160, 1}
            }
        },
        ["hunter"] = {
            outfit = {
                male = 129,
                female = 137,
                addon = 3,
                storage = 10032
            },
            items = {
                {2160, 1}
            }
        },
        ["mage"] = {
            outfit = {
                male = 130,
                female = 138,
                addon = 3,
                storage = 10033
            },
            items = {
                {2160, 1}
            }
        },
        ["knight"] = {
            outfit = {
                male = 131,
                female = 139,
                addon = 3,
                storage = 10034
            },
            items = {
                {2160, 1}
            }
        },
        ["summoner"] = {
            outfit = {
                male = 133,
                female = 141,
                addon = 3,
                storage = 10035
            },
            items = {
                {2160, 1}
            }
        },
        ["warrior"] = {
            outfit = {
                male = 134,
                female = 142,
                addon = 3,
                storage = 10029
            },
            items = {
                {2160, 1}
            }
        },
        ["barbarian"] = {
            outfit = {
                male = 143,
                female = 147,
                addon = 3,
                storage = 10037
            },
            items = {
                {2160, 1}
            }
        },
        ["wizard"] = {
            outfit = {
                male = 145,
                female = 149,
                addon = 3,
                storage = 10049
            },
            items = {
                {2160, 1}
            }
        },
        ["pirate"] = {
            outfit = {
                male = 151,
                female = 155,
                addon = 3,
                storage = 10041
            },
            items = {
                {2160, 1}
            }
        },
        ["assassin"] = {
            outfit = {
                male = 152,
                female = 156,
                addon = 3,
                storage = 10042
            },
            items = {
                {2160, 1}
            }
        },
        ["beggar"] = {
            outfit = {
                male = 153,
                female = 157,
                addon = 3,
                storage = 10043
            },
            items = {
                {2160, 1}
            }
        },
        ["shaman"] = {
            outfit = {
                male = 154,
                female = 158,
                addon = 3,
                storage = 10044
            },
            items = {
                {2160, 1}
            }
        },
        ["norseman"] = {
            outfit = {
                male = 251,
                female = 252,
                addon = 3,
                storage = 10045
            },
            items = {
                {2160, 1}
            }
        },
        ["nightmare"] = {
            outfit = {
                male = 268,
                female = 269,
                addon = 3,
                storage = 10046
            },
            items = {
                {2160, 1}
            }
        },
        ["jester"] = {
            outfit = {
                male = 273,
                female = 270,
                addon = 3,
                storage = 10047
            },
            items = {
                {2160, 1}
            }
        },
        ["brotherhood"] = {
            outfit = {
                male = 278,
                female = 279,
                addon = 3,
                storage = 10048
            },
            items = {
                {2160, 1}
            }
        },
        ["demonhunter"] = {
            outfit = {
                male = 289,
                female = 288,
                addon = 3,
                storage = 10051
            },
            items = {
                {2160, 1}
            }
        },
        ["yalaharian"] = {
            outfit = {
                male = 325,
                female = 324,
                addon = 3,
                storage = 10052
            },
            items = {
                {2160, 1}
            }
        },
        ["warmaster"] = {
            outfit = {
                male = 335,
                female = 336,
                addon = 3,
                storage = 10053
            },
            items = {
                {2160, 1}
            }
        },
        ["wayfarer"] = {
            outfit = {
                male = 367,
                female = 366,
                addon = 3,
                storage = 10054
            },
            items = {
                {2160, 1}
            }
        },
        ["afflicted"] = {
            outfit = {
                male = 430,
                female = 431,
                addon = 3,
                storage = 10055
            },
            items = {
                {2160, 1}
            }
        },
        ["nobleman"] = {
            outfit = {
                male = 132,
                female = 140,
                addon = 3,
                storage = 10056
            },
            items = {
                {2160, 1}
            }
        },
        ["druid"] = {
            outfit = {
                male = 144,
                female = 148,
                addon = 3,
                storage = 10057
            },
            items = {
                {2160, 1}
            }
        },
        ["oriental"] = {
            outfit = {
                male = 146,
                female = 150,
                addon = 3,
                storage = 10058
            },
            items = {
                {2160, 1}
            }
        },
    }
    local v, removeItems = cfg[param], 0, 0
          if(param == "") then
              player:sendTextMessage(MESSAGE_INFO_DESCR, 'Please type !addon outfit')
        player:showTextDialog( 5914, text)
    return false
    end
    if (v == nil) then
          player:sendTextMessage(MESSAGE_INFO_DESCR, "There is no such as outfit named "..param..", here is the list of available outfit.")
        player:showTextDialog(5914, text)
    return false
    end
    if(player:getStorageValue(v.outfit.storage) < 1) then
        for i = 1, #v.items do
            if(player:getItemCount(v.items[i][1]) >= v.items[i][2]) then
                removeItems = removeItems+1
            end
        end
        if(removeItems == #v.items) then
            if(player:getSex(cid) == 1) then
                player:addOutfitAddon(v.outfit.male, v.outfit.addon)
            elseif(player:getSex(cid) == 0) then
                player:addOutfitAddon( v.outfit.female, v.outfit.addon)
            end
            for i = 1, #v.items do
                player:removeItem( v.items[i][1], v.items[i][2])
            end
              player:sendTextMessage(MESSAGE_INFO_DESCR, "Enjoy your new addons to your "..param.." outfit!")
                    player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
            player:setStorageValue( v.outfit.storage, 1)
        else
            for i = 1, #v.items do
                  player:sendTextMessage(MESSAGE_INFO_DESCR, "you need " .. v.items[i][2] .. "x " .. ItemType(v.items[i][1]):getName() .. " to get the "..param.." addon.")
            end
        end
    else
          player:sendTextMessage(MESSAGE_INFO_DESCR, "you already got the "..param.." addon.")
    end
    return false
end

iam using this command for addons if your don't care npc or command both gives addons with the price you decide
thanks but i prefer npc
 
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
local talkState = {}
local rtnt = {}
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

npcHandler:setMessage(MESSAGE_GREET, "Greetings |PLAYERNAME|. I need your help and I'll reward you with nice addons if you help me! Just say {addons} or {help} if you don't know what to do.")

addoninfo = {
['first citizen addon'] = {cost = 0, items = {{5878,20}}, outfit_female = 136, outfit_male = 128, addon = 1, storageID = 10042},
['second citizen addon'] = {cost = 0, items = {{5890,50}, {5902,25}, {2480,1}}, outfit_female = 136, outfit_male = 128, addon = 2, storageID = 10043},
['first hunter addon'] = {cost = 0, items = {{5876,50}, {5948,50}, {5891,5}, {5887,1}, {5889,1}, {5888,1}}, outfit_female = 137, outfit_male = 129, addon = 1, storageID = 10044},
['second hunter addon'] = {cost = 0, items = {{5875,1}}, outfit_female = 137, outfit_male = 129, addon = 2, storageID = 10045},
['first knight addon'] = {cost = 0, items = {{5880,50}, {5892,1}}, outfit_female = 139, outfit_male = 131, addon = 1, storageID = 10046},
['second knight addon'] = {cost = 0, items = {{5893,50}, {11422,1}, {5885,1}, {5887,1}}, outfit_female = 139, outfit_male = 131, addon = 2, storageID = 10047},
['first mage addon'] = {cost = 0, items = {{2182,1}, {2186,1}, {2185,1}, {8911,1}, {2181,1}, {2183,1}, {2190,1}, {2191,1}, {2188,1}, {8921,1}, {2189,1}, {2187,1}, {2392,30}, {5809,1}, {2193,20}}, outfit_female = 138, outfit_male = 130, addon = 1, storageID = 10048},
['second mage addon'] = {cost = 0, items = {{5903,1}}, outfit_female = 138, outfit_male = 130, addon = 2, storageID = 10049},
['first summoner addon'] = {cost = 0, items = {{5878,20}}, outfit_female = 141, outfit_male = 133, addon = 1, storageID = 10050},
['second summoner addon'] = {cost = 0, items = {{5894,35}, {5911,20}, {5883,40}, {5922,35}, {5879,10}, {5881,30}, {5882,40}, {2392,3}, {5905,30}}, outfit_female = 141, outfit_male = 133, addon = 2, storageID = 10051},
['first barbarian addon'] = {cost = 0, items = {{5884,1}, {5885,1}, {5910,25}, {5911,25}, {5886,10}}, outfit_female = 147, outfit_male = 143, addon = 1, storageID = 10011},
['second barbarian addon'] = {cost = 0, items = {{5880,25}, {5892,1}, {5893,25}, {5876,25}}, outfit_female = 147, outfit_male = 143, addon = 2, storageID = 10012},
['first druid addon'] = {cost = 0, items = {{5896,20}, {5897,20}}, outfit_female = 148, outfit_male = 144, addon = 1, storageID = 10013},
['second druid addon'] = {cost = 0, items = {{5906,100}}, outfit_female = 148, outfit_male = 144, addon = 2, storageID = 10014},
['first nobleman addon'] = {cost = 300000, items = {}, outfit_female = 140, outfit_male = 132, addon = 1, storageID = 10015},
['second nobleman addon'] = {cost = 300000, items = {}, outfit_female = 140, outfit_male = 132, addon = 2, storageID = 10016},
['first oriental addon'] = {cost = 0, items = {{5945,1}}, outfit_female = 150, outfit_male = 146, addon = 1, storageID = 10017},
['second oriental addon'] = {cost = 0, items = {{5883,30}, {5895,30}, {5891,2}, {5912,30}}, outfit_female = 150, outfit_male = 146, addon = 2, storageID = 10018},
['first warrior addon'] = {cost = 0, items = {{5925,40}, {5899,40}, {5884,1}, {5919,1}}, outfit_female = 142, outfit_male = 134, addon = 1, storageID = 10019},
['second warrior addon'] = {cost = 0, items = {{5880,40}, {5887,1}}, outfit_female = 142, outfit_male = 134, addon = 2, storageID = 10020},
['first wizard addon'] = {cost = 0, items = {{2536,1}, {2492,1}, {2488,1}, {2123,1}}, outfit_female = 149, outfit_male = 145, addon = 1, storageID = 10021},
['second wizard addon'] = {cost = 0, items = {{5922,40}, {2472,10}}, outfit_female = 149, outfit_male = 145, addon = 2, storageID = 10022},
['first assassin addon'] = {cost = 0, items = {{5912,20}, {5910,20}, {5911,20}, {5913,20}, {5914,20}, {5909,20}, {5886,10}}, outfit_female = 156, outfit_male = 152, addon = 1, storageID = 10023},
['second assassin addon'] = {cost = 0, items = {{5804,1}, {5930,10}}, outfit_female = 156, outfit_male = 152, addon = 2, storageID = 10024},
['first beggar addon'] = {cost = 0, items = {{5878,30}, {5921,20}, {5913,10}, {5894,10}}, outfit_female = 157, outfit_male = 153, addon = 1, storageID = 10025},
['second beggar addon'] = {cost = 0, items = {{5883,30}, {2160,2}}, outfit_female = 157, outfit_male = 153, addon = 2, storageID = 10026},
['first pirate addon'] = {cost = 0, items = {{6098,30}, {6126,30}, {6097,30}}, outfit_female = 155, outfit_male = 151, addon = 1, storageID = 10027},
['second pirate addon'] = {cost = 0, items = {{6101,1}, {6102,1}, {6100,1}, {6099,1}}, outfit_female = 155, outfit_male = 151, addon = 2, storageID = 10028},
['first shaman addon'] = {cost = 0, items = {{5810,5}, {3955,5}, {5015,1}}, outfit_female = 158, outfit_male = 154, addon = 1, storageID = 10029},
['second shaman addon'] = {cost = 0, items = {{3966,5}, {3967,5}}, outfit_female = 158, outfit_male = 154, addon = 2, storageID = 10030},
['first norseman addon'] = {cost = 0, items = {{7290,5}}, outfit_female = 252, outfit_male = 251, addon = 1, storageID = 10031},
['second norseman addon'] = {cost = 0, items = {{7290,10}}, outfit_female = 252, outfit_male = 251, addon = 2, storageID = 10032}
-- next storage 10052    -- next storage 10052    -- next storage 10052    -- next storage 10052    -- next storage 10052    -- next storage 10052    -- next storage 10052 --
}
local o = {'citizen', 'hunter', 'knight', 'mage', 'nobleman', 'summoner', 'warrior', 'barbarian', 'druid', 'wizard', 'oriental', 'pirate', 'assassin', 'beggar', 'shaman', 'norseman'}
function creatureSayCallback(cid, type, msg)
local talkUser = cid

    if(not npcHandler:isFocused(cid)) then
        return false
    end

    if addoninfo[msg] ~= nil then
        if (getPlayerStorageValue(cid, addoninfo[msg].storageID) ~= -1) then
                npcHandler:say('You already have this addon!', cid)
                npcHandler:resetNpc()
        else
        local itemsTable = addoninfo[msg].items
        local items_list = ''
            if table.maxn(itemsTable) > 0 then
                for i = 1, table.maxn(itemsTable) do
                    local item = itemsTable[i]
                    items_list = items_list .. item[2] .. ' ' .. ItemType(item[1]):getName()
                    if i ~= table.maxn(itemsTable) then
                        items_list = items_list .. ', '
                    end
                end
            end
        local text = ''
            if (addoninfo[msg].cost > 0) then
                text = addoninfo[msg].cost .. ' gp'
            elseif table.maxn(addoninfo[msg].items) then
                text = items_list
            elseif (addoninfo[msg].cost > 0) and table.maxn(addoninfo[msg].items) then
                text = items_list .. ' and ' .. addoninfo[msg].cost .. ' gp'
            end
            npcHandler:say('For ' .. msg .. ' you will need ' .. text .. '. Do you have it all with you?', cid)
            rtnt[talkUser] = msg
            talkState[talkUser] = addoninfo[msg].storageID
            return true
        end
    elseif msgcontains(msg, "yes") then
        if (talkState[talkUser] > 10010 and talkState[talkUser] < 10100) then
            local items_number = 0
            if table.maxn(addoninfo[rtnt[talkUser]].items) > 0 then
                for i = 1, table.maxn(addoninfo[rtnt[talkUser]].items) do
                    local item = addoninfo[rtnt[talkUser]].items[i]
                    if (getPlayerItemCount(cid,item[1]) >= item[2]) then
                        items_number = items_number + 1
                    end
                end
            end
            if(getPlayerMoney(cid) >= addoninfo[rtnt[talkUser]].cost) and (items_number == table.maxn(addoninfo[rtnt[talkUser]].items)) then
                doPlayerRemoveMoney(cid, addoninfo[rtnt[talkUser]].cost)
                if table.maxn(addoninfo[rtnt[talkUser]].items) > 0 then
                    for i = 1, table.maxn(addoninfo[rtnt[talkUser]].items) do
                        local item = addoninfo[rtnt[talkUser]].items[i]
                        doPlayerRemoveItem(cid,item[1],item[2])
                    end
                end
                doPlayerAddOutfit(cid, addoninfo[rtnt[talkUser]].outfit_male, addoninfo[rtnt[talkUser]].addon)
                doPlayerAddOutfit(cid, addoninfo[rtnt[talkUser]].outfit_female, addoninfo[rtnt[talkUser]].addon)
                setPlayerStorageValue(cid,addoninfo[rtnt[talkUser]].storageID,1)
                npcHandler:say('Here you are.', cid)
            else
                npcHandler:say('You do not have needed items!', cid)
            end
            rtnt[talkUser] = nil
            talkState[talkUser] = 0
            npcHandler:resetNpc()
            return true
        end
    elseif msgcontains(msg, "addon") then
        npcHandler:say('I can give you addons for {' .. table.concat(o, "}, {") .. '} outfits.', cid)
        rtnt[talkUser] = nil
        talkState[talkUser] = 0
        npcHandler:resetNpc()
        return true
    elseif msgcontains(msg, "help") then
        npcHandler:say('To buy the first addon say \'first NAME addon\', for the second addon say \'second NAME addon\'.', cid)
        rtnt[talkUser] = nil
        talkState[talkUser] = 0
        npcHandler:resetNpc()
        return true
    else
        if talkState[talkUser] ~= nil then
            if talkState[talkUser] > 0 then
            npcHandler:say('Come back when you get these items.', cid)
            rtnt[talkUser] = nil
            talkState[talkUser] = 0
            npcHandler:resetNpc()
            return true
            end
        end
    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)
local talkState = {}
local rtnt = {}
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

npcHandler:setMessage(MESSAGE_GREET, "Greetings |PLAYERNAME|. I need your help and I'll reward you with nice addons if you help me! Just say {addons} or {help} if you don't know what to do.")

addoninfo = {
['first citizen addon'] = {cost = 0, items = {{5878,20}}, outfit_female = 136, outfit_male = 128, addon = 1, storageID = 10042},
['second citizen addon'] = {cost = 0, items = {{5890,50}, {5902,25}, {2480,1}}, outfit_female = 136, outfit_male = 128, addon = 2, storageID = 10043},
['first hunter addon'] = {cost = 0, items = {{5876,50}, {5948,50}, {5891,5}, {5887,1}, {5889,1}, {5888,1}}, outfit_female = 137, outfit_male = 129, addon = 1, storageID = 10044},
['second hunter addon'] = {cost = 0, items = {{5875,1}}, outfit_female = 137, outfit_male = 129, addon = 2, storageID = 10045},
['first knight addon'] = {cost = 0, items = {{5880,50}, {5892,1}}, outfit_female = 139, outfit_male = 131, addon = 1, storageID = 10046},
['second knight addon'] = {cost = 0, items = {{5893,50}, {11422,1}, {5885,1}, {5887,1}}, outfit_female = 139, outfit_male = 131, addon = 2, storageID = 10047},
['first mage addon'] = {cost = 0, items = {{2182,1}, {2186,1}, {2185,1}, {8911,1}, {2181,1}, {2183,1}, {2190,1}, {2191,1}, {2188,1}, {8921,1}, {2189,1}, {2187,1}, {2392,30}, {5809,1}, {2193,20}}, outfit_female = 138, outfit_male = 130, addon = 1, storageID = 10048},
['second mage addon'] = {cost = 0, items = {{5903,1}}, outfit_female = 138, outfit_male = 130, addon = 2, storageID = 10049},
['first summoner addon'] = {cost = 0, items = {{5878,20}}, outfit_female = 141, outfit_male = 133, addon = 1, storageID = 10050},
['second summoner addon'] = {cost = 0, items = {{5894,35}, {5911,20}, {5883,40}, {5922,35}, {5879,10}, {5881,30}, {5882,40}, {2392,3}, {5905,30}}, outfit_female = 141, outfit_male = 133, addon = 2, storageID = 10051},
['first barbarian addon'] = {cost = 0, items = {{5884,1}, {5885,1}, {5910,25}, {5911,25}, {5886,10}}, outfit_female = 147, outfit_male = 143, addon = 1, storageID = 10011},
['second barbarian addon'] = {cost = 0, items = {{5880,25}, {5892,1}, {5893,25}, {5876,25}}, outfit_female = 147, outfit_male = 143, addon = 2, storageID = 10012},
['first druid addon'] = {cost = 0, items = {{5896,20}, {5897,20}}, outfit_female = 148, outfit_male = 144, addon = 1, storageID = 10013},
['second druid addon'] = {cost = 0, items = {{5906,100}}, outfit_female = 148, outfit_male = 144, addon = 2, storageID = 10014},
['first nobleman addon'] = {cost = 300000, items = {}, outfit_female = 140, outfit_male = 132, addon = 1, storageID = 10015},
['second nobleman addon'] = {cost = 300000, items = {}, outfit_female = 140, outfit_male = 132, addon = 2, storageID = 10016},
['first oriental addon'] = {cost = 0, items = {{5945,1}}, outfit_female = 150, outfit_male = 146, addon = 1, storageID = 10017},
['second oriental addon'] = {cost = 0, items = {{5883,30}, {5895,30}, {5891,2}, {5912,30}}, outfit_female = 150, outfit_male = 146, addon = 2, storageID = 10018},
['first warrior addon'] = {cost = 0, items = {{5925,40}, {5899,40}, {5884,1}, {5919,1}}, outfit_female = 142, outfit_male = 134, addon = 1, storageID = 10019},
['second warrior addon'] = {cost = 0, items = {{5880,40}, {5887,1}}, outfit_female = 142, outfit_male = 134, addon = 2, storageID = 10020},
['first wizard addon'] = {cost = 0, items = {{2536,1}, {2492,1}, {2488,1}, {2123,1}}, outfit_female = 149, outfit_male = 145, addon = 1, storageID = 10021},
['second wizard addon'] = {cost = 0, items = {{5922,40}, {2472,10}}, outfit_female = 149, outfit_male = 145, addon = 2, storageID = 10022},
['first assassin addon'] = {cost = 0, items = {{5912,20}, {5910,20}, {5911,20}, {5913,20}, {5914,20}, {5909,20}, {5886,10}}, outfit_female = 156, outfit_male = 152, addon = 1, storageID = 10023},
['second assassin addon'] = {cost = 0, items = {{5804,1}, {5930,10}}, outfit_female = 156, outfit_male = 152, addon = 2, storageID = 10024},
['first beggar addon'] = {cost = 0, items = {{5878,30}, {5921,20}, {5913,10}, {5894,10}}, outfit_female = 157, outfit_male = 153, addon = 1, storageID = 10025},
['second beggar addon'] = {cost = 0, items = {{5883,30}, {2160,2}}, outfit_female = 157, outfit_male = 153, addon = 2, storageID = 10026},
['first pirate addon'] = {cost = 0, items = {{6098,30}, {6126,30}, {6097,30}}, outfit_female = 155, outfit_male = 151, addon = 1, storageID = 10027},
['second pirate addon'] = {cost = 0, items = {{6101,1}, {6102,1}, {6100,1}, {6099,1}}, outfit_female = 155, outfit_male = 151, addon = 2, storageID = 10028},
['first shaman addon'] = {cost = 0, items = {{5810,5}, {3955,5}, {5015,1}}, outfit_female = 158, outfit_male = 154, addon = 1, storageID = 10029},
['second shaman addon'] = {cost = 0, items = {{3966,5}, {3967,5}}, outfit_female = 158, outfit_male = 154, addon = 2, storageID = 10030},
['first norseman addon'] = {cost = 0, items = {{7290,5}}, outfit_female = 252, outfit_male = 251, addon = 1, storageID = 10031},
['second norseman addon'] = {cost = 0, items = {{7290,10}}, outfit_female = 252, outfit_male = 251, addon = 2, storageID = 10032}
-- next storage 10052    -- next storage 10052    -- next storage 10052    -- next storage 10052    -- next storage 10052    -- next storage 10052    -- next storage 10052 --
}
local o = {'citizen', 'hunter', 'knight', 'mage', 'nobleman', 'summoner', 'warrior', 'barbarian', 'druid', 'wizard', 'oriental', 'pirate', 'assassin', 'beggar', 'shaman', 'norseman'}
function creatureSayCallback(cid, type, msg)
local talkUser = cid

    if(not npcHandler:isFocused(cid)) then
        return false
    end

    if addoninfo[msg] ~= nil then
        if (getPlayerStorageValue(cid, addoninfo[msg].storageID) ~= -1) then
                npcHandler:say('You already have this addon!', cid)
                npcHandler:resetNpc()
        else
        local itemsTable = addoninfo[msg].items
        local items_list = ''
            if table.maxn(itemsTable) > 0 then
                for i = 1, table.maxn(itemsTable) do
                    local item = itemsTable[i]
                    items_list = items_list .. item[2] .. ' ' .. ItemType(item[1]):getName()
                    if i ~= table.maxn(itemsTable) then
                        items_list = items_list .. ', '
                    end
                end
            end
        local text = ''
            if (addoninfo[msg].cost > 0) then
                text = addoninfo[msg].cost .. ' gp'
            elseif table.maxn(addoninfo[msg].items) then
                text = items_list
            elseif (addoninfo[msg].cost > 0) and table.maxn(addoninfo[msg].items) then
                text = items_list .. ' and ' .. addoninfo[msg].cost .. ' gp'
            end
            npcHandler:say('For ' .. msg .. ' you will need ' .. text .. '. Do you have it all with you?', cid)
            rtnt[talkUser] = msg
            talkState[talkUser] = addoninfo[msg].storageID
            return true
        end
    elseif msgcontains(msg, "yes") then
        if (talkState[talkUser] > 10010 and talkState[talkUser] < 10100) then
            local items_number = 0
            if table.maxn(addoninfo[rtnt[talkUser]].items) > 0 then
                for i = 1, table.maxn(addoninfo[rtnt[talkUser]].items) do
                    local item = addoninfo[rtnt[talkUser]].items[i]
                    if (getPlayerItemCount(cid,item[1]) >= item[2]) then
                        items_number = items_number + 1
                    end
                end
            end
            if(getPlayerMoney(cid) >= addoninfo[rtnt[talkUser]].cost) and (items_number == table.maxn(addoninfo[rtnt[talkUser]].items)) then
                doPlayerRemoveMoney(cid, addoninfo[rtnt[talkUser]].cost)
                if table.maxn(addoninfo[rtnt[talkUser]].items) > 0 then
                    for i = 1, table.maxn(addoninfo[rtnt[talkUser]].items) do
                        local item = addoninfo[rtnt[talkUser]].items[i]
                        doPlayerRemoveItem(cid,item[1],item[2])
                    end
                end
                doPlayerAddOutfit(cid, addoninfo[rtnt[talkUser]].outfit_male, addoninfo[rtnt[talkUser]].addon)
                doPlayerAddOutfit(cid, addoninfo[rtnt[talkUser]].outfit_female, addoninfo[rtnt[talkUser]].addon)
                setPlayerStorageValue(cid,addoninfo[rtnt[talkUser]].storageID,1)
                npcHandler:say('Here you are.', cid)
            else
                npcHandler:say('You do not have needed items!', cid)
            end
            rtnt[talkUser] = nil
            talkState[talkUser] = 0
            npcHandler:resetNpc()
            return true
        end
    elseif msgcontains(msg, "addon") then
        npcHandler:say('I can give you addons for {' .. table.concat(o, "}, {") .. '} outfits.', cid)
        rtnt[talkUser] = nil
        talkState[talkUser] = 0
        npcHandler:resetNpc()
        return true
    elseif msgcontains(msg, "help") then
        npcHandler:say('To buy the first addon say \'first NAME addon\', for the second addon say \'second NAME addon\'.', cid)
        rtnt[talkUser] = nil
        talkState[talkUser] = 0
        npcHandler:resetNpc()
        return true
    else
        if talkState[talkUser] ~= nil then
            if talkState[talkUser] > 0 then
            npcHandler:say('Come back when you get these items.', cid)
            rtnt[talkUser] = nil
            talkState[talkUser] = 0
            npcHandler:resetNpc()
            return true
            end
        end
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
WOW! work!!! :D only i must change the items for addons,
 
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
local talkState = {}
local rtnt = {}
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

npcHandler:setMessage(MESSAGE_GREET, "Greetings |PLAYERNAME|. I need your help and I'll reward you with nice addons if you help me! Just say {addons} or {help} if you don't know what to do.")

addoninfo = {
['first citizen addon'] = {cost = 0, items = {{5878,20}}, outfit_female = 136, outfit_male = 128, addon = 1, storageID = 10042},
['second citizen addon'] = {cost = 0, items = {{5890,50}, {5902,25}, {2480,1}}, outfit_female = 136, outfit_male = 128, addon = 2, storageID = 10043},
['first hunter addon'] = {cost = 0, items = {{5876,50}, {5948,50}, {5891,5}, {5887,1}, {5889,1}, {5888,1}}, outfit_female = 137, outfit_male = 129, addon = 1, storageID = 10044},
['second hunter addon'] = {cost = 0, items = {{5875,1}}, outfit_female = 137, outfit_male = 129, addon = 2, storageID = 10045},
['first knight addon'] = {cost = 0, items = {{5880,50}, {5892,1}}, outfit_female = 139, outfit_male = 131, addon = 1, storageID = 10046},
['second knight addon'] = {cost = 0, items = {{5893,50}, {11422,1}, {5885,1}, {5887,1}}, outfit_female = 139, outfit_male = 131, addon = 2, storageID = 10047},
['first mage addon'] = {cost = 0, items = {{2182,1}, {2186,1}, {2185,1}, {8911,1}, {2181,1}, {2183,1}, {2190,1}, {2191,1}, {2188,1}, {8921,1}, {2189,1}, {2187,1}, {2392,30}, {5809,1}, {2193,20}}, outfit_female = 138, outfit_male = 130, addon = 1, storageID = 10048},
['second mage addon'] = {cost = 0, items = {{5903,1}}, outfit_female = 138, outfit_male = 130, addon = 2, storageID = 10049},
['first summoner addon'] = {cost = 0, items = {{5878,20}}, outfit_female = 141, outfit_male = 133, addon = 1, storageID = 10050},
['second summoner addon'] = {cost = 0, items = {{5894,35}, {5911,20}, {5883,40}, {5922,35}, {5879,10}, {5881,30}, {5882,40}, {2392,3}, {5905,30}}, outfit_female = 141, outfit_male = 133, addon = 2, storageID = 10051},
['first barbarian addon'] = {cost = 0, items = {{5884,1}, {5885,1}, {5910,25}, {5911,25}, {5886,10}}, outfit_female = 147, outfit_male = 143, addon = 1, storageID = 10011},
['second barbarian addon'] = {cost = 0, items = {{5880,25}, {5892,1}, {5893,25}, {5876,25}}, outfit_female = 147, outfit_male = 143, addon = 2, storageID = 10012},
['first druid addon'] = {cost = 0, items = {{5896,20}, {5897,20}}, outfit_female = 148, outfit_male = 144, addon = 1, storageID = 10013},
['second druid addon'] = {cost = 0, items = {{5906,100}}, outfit_female = 148, outfit_male = 144, addon = 2, storageID = 10014},
['first nobleman addon'] = {cost = 300000, items = {}, outfit_female = 140, outfit_male = 132, addon = 1, storageID = 10015},
['second nobleman addon'] = {cost = 300000, items = {}, outfit_female = 140, outfit_male = 132, addon = 2, storageID = 10016},
['first oriental addon'] = {cost = 0, items = {{5945,1}}, outfit_female = 150, outfit_male = 146, addon = 1, storageID = 10017},
['second oriental addon'] = {cost = 0, items = {{5883,30}, {5895,30}, {5891,2}, {5912,30}}, outfit_female = 150, outfit_male = 146, addon = 2, storageID = 10018},
['first warrior addon'] = {cost = 0, items = {{5925,40}, {5899,40}, {5884,1}, {5919,1}}, outfit_female = 142, outfit_male = 134, addon = 1, storageID = 10019},
['second warrior addon'] = {cost = 0, items = {{5880,40}, {5887,1}}, outfit_female = 142, outfit_male = 134, addon = 2, storageID = 10020},
['first wizard addon'] = {cost = 0, items = {{2536,1}, {2492,1}, {2488,1}, {2123,1}}, outfit_female = 149, outfit_male = 145, addon = 1, storageID = 10021},
['second wizard addon'] = {cost = 0, items = {{5922,40}, {2472,10}}, outfit_female = 149, outfit_male = 145, addon = 2, storageID = 10022},
['first assassin addon'] = {cost = 0, items = {{5912,20}, {5910,20}, {5911,20}, {5913,20}, {5914,20}, {5909,20}, {5886,10}}, outfit_female = 156, outfit_male = 152, addon = 1, storageID = 10023},
['second assassin addon'] = {cost = 0, items = {{5804,1}, {5930,10}}, outfit_female = 156, outfit_male = 152, addon = 2, storageID = 10024},
['first beggar addon'] = {cost = 0, items = {{5878,30}, {5921,20}, {5913,10}, {5894,10}}, outfit_female = 157, outfit_male = 153, addon = 1, storageID = 10025},
['second beggar addon'] = {cost = 0, items = {{5883,30}, {2160,2}}, outfit_female = 157, outfit_male = 153, addon = 2, storageID = 10026},
['first pirate addon'] = {cost = 0, items = {{6098,30}, {6126,30}, {6097,30}}, outfit_female = 155, outfit_male = 151, addon = 1, storageID = 10027},
['second pirate addon'] = {cost = 0, items = {{6101,1}, {6102,1}, {6100,1}, {6099,1}}, outfit_female = 155, outfit_male = 151, addon = 2, storageID = 10028},
['first shaman addon'] = {cost = 0, items = {{5810,5}, {3955,5}, {5015,1}}, outfit_female = 158, outfit_male = 154, addon = 1, storageID = 10029},
['second shaman addon'] = {cost = 0, items = {{3966,5}, {3967,5}}, outfit_female = 158, outfit_male = 154, addon = 2, storageID = 10030},
['first norseman addon'] = {cost = 0, items = {{7290,5}}, outfit_female = 252, outfit_male = 251, addon = 1, storageID = 10031},
['second norseman addon'] = {cost = 0, items = {{7290,10}}, outfit_female = 252, outfit_male = 251, addon = 2, storageID = 10032}
-- next storage 10052    -- next storage 10052    -- next storage 10052    -- next storage 10052    -- next storage 10052    -- next storage 10052    -- next storage 10052 --
}
local o = {'citizen', 'hunter', 'knight', 'mage', 'nobleman', 'summoner', 'warrior', 'barbarian', 'druid', 'wizard', 'oriental', 'pirate', 'assassin', 'beggar', 'shaman', 'norseman'}
function creatureSayCallback(cid, type, msg)
local talkUser = cid

    if(not npcHandler:isFocused(cid)) then
        return false
    end

    if addoninfo[msg] ~= nil then
        if (getPlayerStorageValue(cid, addoninfo[msg].storageID) ~= -1) then
                npcHandler:say('You already have this addon!', cid)
                npcHandler:resetNpc()
        else
        local itemsTable = addoninfo[msg].items
        local items_list = ''
            if table.maxn(itemsTable) > 0 then
                for i = 1, table.maxn(itemsTable) do
                    local item = itemsTable[i]
                    items_list = items_list .. item[2] .. ' ' .. ItemType(item[1]):getName()
                    if i ~= table.maxn(itemsTable) then
                        items_list = items_list .. ', '
                    end
                end
            end
        local text = ''
            if (addoninfo[msg].cost > 0) then
                text = addoninfo[msg].cost .. ' gp'
            elseif table.maxn(addoninfo[msg].items) then
                text = items_list
            elseif (addoninfo[msg].cost > 0) and table.maxn(addoninfo[msg].items) then
                text = items_list .. ' and ' .. addoninfo[msg].cost .. ' gp'
            end
            npcHandler:say('For ' .. msg .. ' you will need ' .. text .. '. Do you have it all with you?', cid)
            rtnt[talkUser] = msg
            talkState[talkUser] = addoninfo[msg].storageID
            return true
        end
    elseif msgcontains(msg, "yes") then
        if (talkState[talkUser] > 10010 and talkState[talkUser] < 10100) then
            local items_number = 0
            if table.maxn(addoninfo[rtnt[talkUser]].items) > 0 then
                for i = 1, table.maxn(addoninfo[rtnt[talkUser]].items) do
                    local item = addoninfo[rtnt[talkUser]].items[i]
                    if (getPlayerItemCount(cid,item[1]) >= item[2]) then
                        items_number = items_number + 1
                    end
                end
            end
            if(getPlayerMoney(cid) >= addoninfo[rtnt[talkUser]].cost) and (items_number == table.maxn(addoninfo[rtnt[talkUser]].items)) then
                doPlayerRemoveMoney(cid, addoninfo[rtnt[talkUser]].cost)
                if table.maxn(addoninfo[rtnt[talkUser]].items) > 0 then
                    for i = 1, table.maxn(addoninfo[rtnt[talkUser]].items) do
                        local item = addoninfo[rtnt[talkUser]].items[i]
                        doPlayerRemoveItem(cid,item[1],item[2])
                    end
                end
                doPlayerAddOutfit(cid, addoninfo[rtnt[talkUser]].outfit_male, addoninfo[rtnt[talkUser]].addon)
                doPlayerAddOutfit(cid, addoninfo[rtnt[talkUser]].outfit_female, addoninfo[rtnt[talkUser]].addon)
                setPlayerStorageValue(cid,addoninfo[rtnt[talkUser]].storageID,1)
                npcHandler:say('Here you are.', cid)
            else
                npcHandler:say('You do not have needed items!', cid)
            end
            rtnt[talkUser] = nil
            talkState[talkUser] = 0
            npcHandler:resetNpc()
            return true
        end
    elseif msgcontains(msg, "addon") then
        npcHandler:say('I can give you addons for {' .. table.concat(o, "}, {") .. '} outfits.', cid)
        rtnt[talkUser] = nil
        talkState[talkUser] = 0
        npcHandler:resetNpc()
        return true
    elseif msgcontains(msg, "help") then
        npcHandler:say('To buy the first addon say \'first NAME addon\', for the second addon say \'second NAME addon\'.', cid)
        rtnt[talkUser] = nil
        talkState[talkUser] = 0
        npcHandler:resetNpc()
        return true
    else
        if talkState[talkUser] ~= nil then
            if talkState[talkUser] > 0 then
            npcHandler:say('Come back when you get these items.', cid)
            rtnt[talkUser] = nil
            talkState[talkUser] = 0
            npcHandler:resetNpc()
            return true
            end
        end
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Thanks
 
Bump
There is some npc to sell all addons? here is only max to norseman, i need create a npc who sell all addons for money, i can edit it but i dont know more addons itd etc..
 
Bump
There is some npc to sell all addons? here is only max to norseman, i need create a npc who sell all addons for money, i can edit it but i dont know more addons itd etc..
Data/xml/outfits you will find all outfits ID on this file , add a new line and add female outfit Id and male outfit Id.
You can also add to this npc the same but for mounts.
 
Back
Top