armyman
Member
- Joined
- Feb 15, 2014
- Messages
- 318
- Reaction score
- 13
I got this error in console when i talk with him.
NPC Script
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/aldee.lua:onCreatureSay
data/npc/scripts/aldee.lua:12: attempt to call method 'AddFocus' (a nil value)
stack traceback:
[C]: in function 'AddFocus'
data/npc/scripts/aldee.lua:12: in function 'callback'
data/npc/lib/npcsystem/npchandler.lua:401: in function 'onCreatureSay'
data/npc/scripts/aldee.lua:7: in function <data/npc/scripts/aldee.lua:7>
NPC Script
Lua:
local keywordHandler = KeywordHandler:new()
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
function AlDeeBehaviour (cid, type, msg)
npcHandler:AddFocus({"hi", "hello"}, "Hello, hello, |PLAYERNAME|! Please come in, look, and buy!", 0, cid, msg)
npcHandler:AddQueue({"hi", "hello"}, "I'll be with you in a moment, |PLAYERNAME|.", 0, cid, msg)
npcHandler:RemoveFocus({"bye", "farewell"}, "Bye, bye.", 0, cid, msg)
if(not npcHandler:isFocused(cid)) then
return 0
end
if(msgcontains(msg, 'pick') or msgcontains(msg, 'small axe')) then
npcHandler:say("Picks are hard to come by. I trade them only for high quality small axes. Do you want to trade?",cid)
npcHandler:doTopic(cid, 1)
elseif(msgcontains(msg, "yes")) and (npcHandler.Topic == 1) then
if doPlayerRemoveItem(cid,2559,1) == TRUE then
doPlayerAddItem(cid,2553,1)
npcHandler:say("Splendid! Here take your pickaxe.",cid)
npcHandler:doTopic(cid, 0)
else
npcHandler:say("Sorry, I am looking for a SMALL axe.", cid)
npcHandler:doTopic(cid, 0)
end
elseif(npcHandler.Topic == 1) then
npcHandler:say("Well, then not.", cid)
npcHandler:doTopic(cid, 0)
end
local keywords = {
["how are you"] = {response = "I am fine. I'm so glad to have you here as my customer."},
["sell"] = {response = "I sell much. Just read the blackboards for my awesome wares or just ask me."},
["job"] = {response = "I am a merchant. What can I do for you?"},
["name"] = {response = "My name is Al Dee, but you can call me Al. Do you want to buy something?"},
["time"] = {response = "It is about "..getTime()..". I am so sorry, I have no watches to sell. Do you want to buy something else?"},
["help"] = {response = "I sell stuff to prices that low, that all other merchants would mock at my stupidity."},
["monster"] = {response = "If you want to challenge the monsters, you need some weapons and armor I sell. You need them definitely!"},
["dungeon"] = {response = "If you want to explore the dungeons, you have to equip yourself with the vital stuff I am selling. It's vital in the deepest sense of the word."},
["sewer"] = {response = "Oh, our sewer system is very primitive; so primitive it's overrun by rats. But the stuff I sell is save from them. Do you want to buy some of it?"},
["king"] = {response = "The king encouraged salesmen to travel here, but only I dared to take the risk, and a risk it was!"},
["dallheim"] = {response = "Some call him a hero."},
["bug"] = {response = "Bugs plague this isle, but my wares are bugfree, totally bugfree."},
["stuff"] = {response = "I sell equipment of all kinds, all kind available on this isle. Just ask me about my wares if you are interested."},
["tibia"] = {response = "One day I will return to the continent as a rich, a very rich man!"},
["thais"] = {response = "Thais is a crowded town."},
["wares"] = {response = "I sell weapons, shields, armor, helmets, and equipment. For what do you want to ask?"},
["offer"] = {response = "I sell weapons, shields, armor, helmets, and equipment. For what do you want to ask?"},
["weapon"] = {response = "I sell spears, rapiers, sabres, daggers, hand axes, axes, and short swords. Just tell me what you want to buy."},
["armor"] = {response = "I sell jackets, coats, doublets, leather armor, and leather legs. Just tell me what you want to buy."},
["helmet"] = {response = "I sell leather helmets, studded helmets, and chain helmets. Just tell me what you want to buy."},
["shield"] = {response = "I sell wooden shields and studded shields. Just tell me what you want to buy."},
["equipment"] = {response = "I sell torches, bags, scrolls, shovels, picks, backpacks, sickles, scythes, ropes and fishing rods. Just tell me what you want to buy."},
["do you sell"] = {response = "What do you need? I sell weapons, armor, helmets, shields, and equipment."},
["do you have"] = {response = "What do you need? I sell weapons, armor, helmets, shields, and equipment."},
["club"] = {response = "I don't buy this garbage!"},
}
for v in pairs(keywords) do
if (msgcontains(msg, v)) then
npcHandler:say(keywords[v].response, cid)
npcHandler:doTopic(cid, 0)
end
end
return 1
end
------BUYABLE_ITEMS-----
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addBuyableItem({'spear'}, 2389, 10)
shopModule:addBuyableItem({'rapier'}, 2384, 15)
shopModule:addBuyableItem({'sabre'}, 2385, 25)
shopModule:addBuyableItem({'dagger'}, 2379, 5)
shopModule:addBuyableItem({'sickle'}, 2405, 8)
shopModule:addBuyableItem({'hand axe'}, 2380, 8)
shopModule:addBuyableItem({'axe'}, 2386, 20)
shopModule:addBuyableItem({'short sword'}, 2406, 30)
shopModule:addBuyableItem({'jacket'}, 2650, 10)
shopModule:addBuyableItem({'coat'}, 2651, 8)
shopModule:addBuyableItem({'doublet'}, 2485, 16)
shopModule:addBuyableItem({'leather armor'}, 2467, 25)
shopModule:addBuyableItem({'leather legs'}, 2649, 10)
shopModule:addBuyableItem({'leather helmet'}, 2461, 12)
shopModule:addBuyableItem({'studded helmet'}, 2482, 63)
shopModule:addBuyableItem({'chain helmet'}, 2458, 52)
shopModule:addBuyableItem({'wooden shield'}, 2512, 15)
shopModule:addBuyableItem({'studded shield'}, 2526, 50)
shopModule:addBuyableItem({'torch'}, 2050, 2)
shopModule:addBuyableItem({'bag'}, 1987, 4)
shopModule:addBuyableItem({'scroll'}, 1949, 5)
shopModule:addBuyableItem({'shovel'}, 2554, 10)
shopModule:addBuyableItem({'backpack'}, 1988, 10)
shopModule:addBuyableItem({'scythe'}, 2550, 12)
shopModule:addBuyableItem({'rope'}, 2120, 50)
shopModule:addBuyableItem({'rod'}, 2580, 150)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, AlDeeBehaviour)