NPC addons real items

eduardoaam

Member
Exodus Github
Messages
24
Points
78
Hola estoy tratando de agregar este nuevo NPC para canary, consiste en vender los items para los addons. Cuando abro el ot, me da error en la consola con (a nil value) y cuando trato de hablar con el npc y no dice nada.
Pasare el LUA. Agradeceria ayuda!!

local internalNpcName = "Addon Item 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 = 2

npcConfig.outfit = {
lookType = 128,
lookHead = 25,
lookBody = 95,
lookLegs = 50,
lookFeet = 99,
lookAddons = 3,
}

npcConfig.flags = {
floorchange = false,
}

npcConfig.shop = { -- Sellable items
{ itemName = "mermaid comb", clientId = 5945, buy = 300000 },
{ itemName = "fighting spirit", clientId = 5884, buy = 150000 },
{ itemName = "banana staff", clientId = 3348, buy = 1500 },
{ itemName = "tribal mask", clientId = 3403, buy = 1500 },
{ itemName = "simon the beggar's favorite staff", clientId = 6107, buy = 1500 },
{ itemName = "damaged steel helmet", clientId = 5924, buy = 50000 },
{ itemName = "piece of royal steel", clientId = 5887, buy = 50000 },
{ itemName = "piece of hell steel", clientId = 5888, buy = 50000 },
{ itemName = "enchanted chicken wing", clientId = 5891, buy = 5000 },
{ itemName = "piece of draconian steel", clientId = 5889, buy = 10000 },
{ itemName = "botanist container", clientId = 5937, buy = 150000 },
{ itemName = "magic sulphur", clientId = 5904, buy = 100000 },
{ itemName = "waterhose", clientId = 5938, buy = 100000 },
{ itemName = "chunk of crude iron", clientId = 5892, buy = 100000 },
{ itemName = "iron ore", clientId = 5880, buy = 1000 },
{ itemName = "ankh", clientId = 2193, buy = 1000 },
{ itemName = "red poc", clientId = 5911, buy = 2000 },
{ itemName = "yellow poc", clientId = 5914, buy = 2000 },
{ itemName = "green poc", clientId = 5910, buy = 2000 },
{ itemName = "demon dust", clientId = 5906, buy = 5000 },
{ itemName = "blue poc", clientId = 5912, buy = 2000 },
{ itemName = "white poc", clientId = 5909, buy = 2000 },
{ itemName = "warriors sweat", clientId = 5885, buy = 100000 },
{ itemName = "beholder eye", clientId = 5898, buy = 1000 },
{ itemName = "demonic essence", clientId = 6500, buy = 1000 },
{ itemName = "minotaur leather", clientId = 5878, buy = 1000 },
{ itemName = "lizard scale", clientId = 5881, buy = 1000 },
{ itemName = "behemoth claw", clientId = 5930, buy = 1000 },
{ itemName = "vampire dusts", clientId = 5905, buy = 1000 },
{ itemName = "turtle shells", clientId = 5899, buy = 1000 },
{ itemName = "spider silk", clientId = 5879, buy = 1000 },
{ itemName = "shard", clientId = 7290, buy = 15000 },
{ itemName = "honeycomb", clientId = 5902, buy = 2000 },
{ itemName = "hardened bone", clientId = 5925, buy = 1000 },
{ itemName = "fish fin", clientId = 5895, buy = 1000 },
{ itemName = "demon horn", clientId = 5954, buy = 4000 },
{ itemName = "bear paw", clientId = 5896, buy = 1000 },
{ itemName = "bat wing", clientId = 5894, buy = 1000 },
{ itemName = "green dragon scale", clientId = 5920, buy = 1000 },
{ itemName = "red dragon scale", clientId = 5882, buy = 1000 },
{ itemName = "green lizard leather", clientId = 5876, buy = 1000 },
{ itemName = "green dragon leather", clientId = 5877, buy = 1000 },
{ itemName = "lottery ticket", clientId = 5957, buy = 100000 },
}

-- 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_TRADE, 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

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)

npcType.onThink = function(npc, interval)
npcHandler:eek:nThink(npc, interval)
end

npcType.onAppear = function(npc, creature)
npcHandler:eek:nAppear(npc, creature)
end

npcType.onDisappear = function(npc, creature)
npcHandler:eek:nDisappear(npc, creature)
end

npcType.onMove = function(npc, creature, fromPosition, toPosition)
npcHandler:eek:nMove(npc, creature, fromPosition, toPosition)
end

npcType.onSay = function(npc, creature, type, message)
npcHandler:eek:nSay(npc, creature, type, message)
end

npcType.onCloseChannel = function(npc, creature)
npcHandler:eek:nCloseChannel(npc, creature)
end

npcHandler:setMessage(MESSAGE_GREET, "Hello "..player:getName()..". I can sell addon items to you. Just {trade} with me.")

npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true)

-- npcType registering the npcConfig table
npcType:register(npcConfig)

npcType.onSay = function(npc, creature, type, message)
npcHandler:eek:nSay(npc, creature, type, message)
end

npcType.onCloseChannel = function(npc, creature)
npcHandler:eek:nCloseChannel(npc, creature)
end
 
Solution
Queria aportarles el nuevo archivo lua para el npc, lo he probado y me ha funcionado bien. El precio de los items se lo pueden editar ustedes a su gustos, puse los items mas comunes. Les comparto

ACLARO este archivo LUA lo trabajo en Canary server x13+

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...
Queria aportarles el nuevo archivo lua para el npc, lo he probado y me ha funcionado bien. El precio de los items se lo pueden editar ustedes a su gustos, puse los items mas comunes. Les comparto

ACLARO este archivo LUA lo trabajo en Canary server x13+

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)
npcHandler:eek:nThink(npc, interval)
end

npcType.onAppear = function(npc, creature)
npcHandler:eek:nAppear(npc, creature)
end

npcType.onDisappear = function(npc, creature)
npcHandler:eek:nDisappear(npc, creature)
end

npcType.onMove = function(npc, creature, fromPosition, toPosition)
npcHandler:eek:nMove(npc, creature, fromPosition, toPosition)
end

npcType.onSay = function(npc, creature, type, message)
npcHandler:eek:nSay(npc, creature, type, message)
end

npcType.onCloseChannel = function(npc, creature)
npcHandler:eek:nCloseChannel(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 ****************************************** city. Almost as ****************************************** 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 = {


--Alaistar-
{ 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)
 
Solution
Si les aparece un icono en el archivo Lua que subi, significa lo siguiente: npcHandler: on
Quitan el espacio entre los dos puntos y on. Editarian en cada npcHandler. Por alguna razon cuando subo el lua se agrega un icono
 
Mas facil, copian el texto del archivo y crean un nuevo archivo LUA (lo agarran de la carpeta NPC, cualquier NPC, una copia de ese npc, le cambian el nombre a "addons_items_seller" y copian todo del archivo descargado a ese nuevo npc
 

Attachments

  • addons items seller.txt
    9.5 KB · Views: 0

Tibia Server Lists

#1 FEATURED US Ultron OT 1,488 / 5,000Online EXPStages PROTO8.6 ENGINEUltron OT RANK PTS5.9 +100% VOTES0 #2 FEATURED US Nefera 185 / 0Online EXPx1 PROTO15.20 ENGINECrystal Server RANK PTS5.1 +100% VOTES0 #3 FEATURED ES Deixis 0 / 0Offline EXPStages PROTO1098 ENGINETFS RANK PTS3.7 +100% VOTES1 #4 FEATURED ES Maeli 8 / 150Online EXPx10 PROTO10.98 ENGINETFS 1.4.2 RANK PTS3.7 +100% VOTES0 #5 MX Marlboro War 43 / 300Online EXP999 PROTO8.6 ENGINETFS 0.3.7 RANK PTS5.5 -33% VOTES0 #6 BR Tibinha YurOts 17 / 150Online EXPStages PROTO7.4 ENGINEYurOTS 1.5 RANK PTS5.2 -14% VOTES0 #7 US Halera 3 / 0Online EXPStages PROTO10.98 ENGINETFS 1.4.2 RANK PTS4.9 -83% VOTES0 #8 BR Exordion Legacy 53 / 2,000Online EXPx2 PROTO7.72 ENGINEExordion RANK PTS4.9 +100% VOTES0 #9 PL Lubelski 4 / 1,000Online EXP200 PROTO7.6 ENGINELubelskiOTS 2.56.0 RANK PTS4.6 -15% VOTES0 #10 DE DBU Online 0 / 400Online EXP11 PROTO8.6 ENGINETFS 1.0 RANK PTS4.3 +100% VOTES0 #11 PL ReWar 0 / 2,000Online EXPcustom PROTO8.6 ENGINEOther RANK PTS4.3 0% VOTES0 #12 PL Velesta 0 / 1,000Offline EXP20 PROTO8.0 ENGINETFS 1.4.2 RANK PTS4.3 -99% VOTES0 #13 ES JustRL FreeTC 1530 16 / 250Online EXPx2 PROTO15.30 ENGINECrystal Server RANK PTS4.3 +100% VOTES0 #14 ES Farlia Global 2026 0 / 333Offline EXPx5 PROTO15.25 ENGINEFarliaServ 1.525 RANK PTS3.9 -22% VOTES0 #15 SE MortalisOT Custom 0 / 500Offline EXP100x -1.2x PROTO10.98 ENGINEMortalisOT V1 RANK PTS3.8 +100% VOTES0 #16 US Rommania 0 / 500Online EXPstages, x10 PROTO7.4 ENGINETFS 0.4 RANK PTS3.6 +100% VOTES0 #17 US BerethaOnline 3 / 2,000Online EXPStages PROTO10.98 ENGINETFS RANK PTS3.5 +100% VOTES0
Top