Hello, im going to bring a new npc that i've been working with on Canary servers, it worked for me and. NPC sell real items for addons, you can edit the prices. I edited the npc with the most communs items for addons. Hope you like it 

local internalNpcName = "Addons Items Seller"
local npcType = Game.createNpcType(internalNpcName)
local npcConfig = {}
npcConfig.name = internalNpcName
npcConfig.description = internalNpcName
npcConfig.health = 100
npcConfig.maxHealth = npcConfig.health
npcConfig.walkInterval = 2000
npcConfig.walkRadius = 3
npcConfig.outfit = {
lookType = 130,
lookHead = 116,
lookBody = 124,
lookLegs = 95,
lookFeet = 0,
lookAddons = 3
}
npcConfig.flags = {
floorchange = false
}
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
npcType.onThink = function(npc, interval)
npcHandlernThink(npc, interval)
end
npcType.onAppear = function(npc, creature)
npcHandlernAppear(npc, creature)
end
npcType.onDisappear = function(npc, creature)
npcHandlernDisappear(npc, creature)
end
npcType.onMove = function(npc, creature, fromPosition, toPosition)
npcHandlernMove(npc, creature, fromPosition, toPosition)
end
npcType.onSay = function(npc, creature, type, message)
npcHandlernSay(npc, creature, type, message)
end
npcType.onCloseChannel = function(npc, creature)
npcHandlernCloseChannel(npc, creature)
end
local function creatureSayCallback(npc, creature, type, message)
local player = Player(creature)
local playerId = player:getId()
if not npcHandler:checkInteraction(npc, creature) then
return false
end
return true
end
keywordHandler:addKeyword({ "job" }, StdModule.say, { npcHandler = npcHandler, text = "I am a travelling trader. I don't buy everything, though. And not from everyone, for that matter." })
keywordHandler:addKeyword({ "name" }, StdModule.say, { npcHandler = npcHandler, text = "I am Rashid, son of the desert." })
keywordHandler:addKeyword({ "offers" }, StdModule.say, { npcHandler = npcHandler, text = "Of course, old friend. You can also browse only armor, legs, shields, helmets, boots, weapons, enchanted weapons, jewelry or miscellaneous stuff." })
keywordHandler:addKeyword({ "ab'dendriel" }, StdModule.say, { npcHandler = npcHandler, text = "Elves... I don't really trust them. All this talk about nature and flowers and treehugging... I'm sure there's some wicked scheme behind all this." })
keywordHandler:addKeyword({ "desert" }, StdModule.say, { npcHandler = npcHandler, text = "My beloved hometown! Ah, the sweet scent of the desert sands, the perfect shape of the pyramids... stunningly beautiful." })
keywordHandler:addKeyword({ "carlin" }, StdModule.say, { npcHandler = npcHandler, text = "I have to go to Carlin once in a while, since the queen wishes to see my exclusive wares in regular intervals." })
keywordHandler:addKeyword({ "cormaya" }, StdModule.say, { npcHandler = npcHandler, text = "Cormaya? Not a good place to make business, it's way too far and small." })
keywordHandler:addKeyword({ "darashia" }, StdModule.say, { npcHandler = npcHandler, text = "It's not the real thing, but almost as good. The merchants there claim ridiculous prices, which is fine for my own business." })
keywordHandler:addKeyword({ "edron" }, StdModule.say, { npcHandler = npcHandler, text = "Ah yes, Edron! Such a lovely and quiet island! I usually make some nice business there." })
keywordHandler:addKeyword({ "fibula" }, StdModule.say, { npcHandler = npcHandler, text = "Too few customers there, it's not worth the trip." })
keywordHandler:addKeyword({ "greenshore" }, StdModule.say, { npcHandler = npcHandler, text = "Um... I don't think so." })
keywordHandler:addKeyword({ "kazordoon" }, StdModule.say, { npcHandler = npcHandler, text = "I don't like being underground much. I also tend to get lost in these labyrinthine dwarven tunnels, so I rather avoid them." })
keywordHandler:addKeyword({ "liberty bay" }, StdModule.say, { npcHandler = npcHandler, text = "When you avoid the slums, it's a really pretty city. Almost as pretty as the governor's daughter." })
keywordHandler:addKeyword({ "northport" }, StdModule.say, { npcHandler = npcHandler, text = "Um... I don't think so." })
keywordHandler:addKeyword({ "port hope" }, StdModule.say, { npcHandler = npcHandler, text = "I like the settlement itself, but I don't set my foot into the jungle. Have you seen the size of these centipedes??" })
keywordHandler:addKeyword({ "senja" }, StdModule.say, { npcHandler = npcHandler, text = "Um... I don't think so." })
keywordHandler:addKeyword({ "svargrond" }, StdModule.say, { npcHandler = npcHandler, text = "I wish it was a little bit warmer there, but with a good mug of barbarian mead in your tummy everything gets a lot cosier." })
keywordHandler:addKeyword({ "thais" }, StdModule.say, { npcHandler = npcHandler, text = "I feel uncomfortable and rather unsafe in Thais, so I don't really travel there." })
keywordHandler:addKeyword({ "vega" }, StdModule.say, { npcHandler = npcHandler, text = "Um... I don't think so." })
keywordHandler:addKeyword({ "venore" }, StdModule.say, { npcHandler = npcHandler, text = "Although it's the flourishing trade centre of Tibia, I don't like going there. Too much competition for my taste." })
keywordHandler:addKeyword({ "time" }, StdModule.say, { npcHandler = npcHandler, text = "It's almost time to journey on." })
keywordHandler:addKeyword({ "king" }, StdModule.say, { npcHandler = npcHandler, text = "Kings, queens, emperors and kaliphs... everyone claims to be different and unique, but actually it's the same thing everywhere." })
npcHandler:setMessage(MESSAGE_GREET, "Ah, a customer! Be greeted, |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Farewell, |PLAYERNAME|, may the winds guide your way.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Come back soon!")
npcHandler:setMessage(MESSAGE_SENDTRADE, "Take all the time you need to decide what you want!")
local function onTradeRequest(npc, creature)
if Player(creature):getStorageValue(Storage.TravellingTrader.Mission07) ~= 1 then
npcHandler:say('Sorry, but you do not belong to my exclusive customers. I have to make sure that I can trust in the quality of your wares.', npc, creature)
return false
end
return true
end
npcHandler:setCallback(CALLBACK_ON_TRADE_REQUEST, onTradeRequest)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true)
npcConfig.shop = {
{ itemName = "ankh", clientId = 3077, buy = 1000 },
{ itemName = "ape fur", clientId = 5883, buy = 2000 },
{ itemName = "bat wing", clientId = 5894, buy = 1000 },
{ itemName = "bear paw", clientId = 5896, buy = 3000 },
{ itemName = "behemoth claw", clientId = 5930, buy = 5000 },
{ itemName = "blue piece of cloth", clientId = 5912, buy = 3000 },
{ itemName = "bonelord eye", clientId = 5898, buy = 1000 },
{ itemName = "brown piece of cloth", clientId = 5913, buy = 2000 },
{ itemName = "chicken feather", clientId = 5890, buy = 500 },
{ itemName = "demon dust", clientId = 5906, buy = 9000 },
{ itemName = "dragon claw", clientId = 5919, buy = 2000000 },
{ itemName = "enchanted chicken wing", clientId = 5891, buy = 100000 },
{ itemName = "eye patch", clientId = 6098, buy = 2000 },
{ itemName = "fish fin", clientId = 5895, buy = 5000 },
{ itemName = "green piece of cloth", clientId = 5910, buy = 2000 },
{ itemName = "hardened bone", clientId = 5925, buy = 1000 },
{ itemName = "heaven blossom", clientId = 5921, buy = 2000 },
{ itemName = "holy orchid", clientId = 5922, buy = 5000 },
{ itemName = "honeycomb", clientId = 5902, buy = 4000 },
{ itemName = "hook", clientId = 6097, buy = 2000 },
{ itemName = "huge chunk of crude iron", clientId = 5892, buy = 10000 },
{ itemName = "iron ore", clientId = 5880, buy = 2000 },
{ itemName = "lizard leather", clientId = 5876, buy = 1000 },
{ itemName = "lizard scale", clientId = 5881, buy = 2000 },
{ itemName = "magic sulphur", clientId = 5904, buy = 10000 },
{ itemName = "mandrake", clientId = 5014, buy = 3000000 },
{ itemName = "minotaur leather", clientId = 5878, buy = 1000 },
{ itemName = "nose ring", clientId = 5804, buy = 300000 },
{ itemName = "peg leg", clientId = 6126, buy = 1000 },
{ itemName = "perfect behemoth fang", clientId = 5893, buy = 5000 },
{ itemName = "piece of royal steel", clientId = 5887, buy = 100000 },
{ itemName = "red dragon leather", clientId = 5948, buy = 2000 },
{ itemName = "red dragon scale", clientId = 5882, buy = 3000 },
{ itemName = "red piece of cloth", clientId = 5911, buy = 5000 },
{ itemName = "sniper gloves", clientId = 5875, buy = 50000 },
{ itemName = "spider silk", clientId = 5879, buy = 10000 },
{ itemName = "spirit container", clientId = 5884, buy = 200000 },
{ itemName = "spool of yarn", clientId = 5886, buy = 100000 },
{ itemName = "turtle shell", clientId = 5899, buy = 2000 },
{ itemName = "vampire dust", clientId = 5905, buy = 8000 },
{ itemName = "white piece of cloth", clientId = 5909, buy = 2000 },
{ itemName = "wolf paw", clientId = 5897, buy = 1000 },
{ itemName = "yellow piece of cloth", clientId = 5914, buy = 2000 },
}
-- On buy npc shop message
npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost)
npc:sellItem(player, itemId, amount, subType, 0, ignore, inBackpacks)
end
-- On sell npc shop message
npcType.onSellItem = function(npc, player, itemId, subtype, amount, ignore, name, totalCost)
player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("Sold %ix %s for %i gold.", amount, name, totalCost))
end
-- On check npc shop message (look item)
npcType.onCheckItem = function(npc, player, clientId, subType)
end
npcType:register(npcConfig)
Attachments
-
addons_items_seller.lua9.5 KB · Views: 5 · VirusTotal