eduardoaam
Miembro
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!!
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)
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
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)
npcHandlernSay(npc, creature, type, message)
end
npcType.onCloseChannel = function(npc, creature)
npcHandlernCloseChannel(npc, creature)
end





