local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic= {}
local t = {
['Deep Sea Fishing'] = {
'The secret to Deep-Sea Fishing is to use the right kind of bait. I can sell you 100 special worms in exchange for 10 White Pearls. Interested?',
{ {2143, 10} },
{ {3976, 100} }
},
['Ice Fishing'] = {
'The secret to Ice Fishing is to use the right kind of bait. I can sell you 100 Shrimp in exchange for 3 Ice Cubes. Interested?',
{ {7441, 3} },
{ {2670, 100} }
},
['Lava Fishing'] = {
'The secret to Lava Fishing is to use the right kind of bait. I can sell you 100 Nails in exchange for 50 Talons. Interested?',
{ {2151, 50} },
{ {8309, 100} }
},
}
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
local evamsg = 'Here you are!!'
local noimsg = 'What are you trying to do? You don\'t have the appropriate items!'
local deny = 'Not sure, eh? Okay.'
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
for txt, v in pairs(t) do
if msgcontains(msg, txt) then
Topic[cid] = txt
selfSay(v[1], cid)
return true
end
end
if Topic[cid] and Topic[cid] ~= '' then
if msgcontains(msg, 'yes') then
local v = t[Topic[cid]]
for i = 1, #v[2] do
if getPlayerItemCount(cid, v[2][i][1]) < v[2][i][2] then
return selfSay(noimsg, cid)
end
end
for i = 1, #v[2] do
doPlayerRemoveItem(cid, v[2][i][1], v[2][i][2])
end
for i = 1, #v[3] do
doPlayerAddItem(cid, v[3][i][1], v[3][i][2])
end
selfSay(evamsg, cid)
else
selfSay(deny, cid)
end
Topic[cid] = ''
elseif msgcontains(msg, 'trade') then
selfSay('I sell fish bait for (Deep-Sea Fishing), (Ice Fishing) and (Lava Fishing). What type of fishing do you plan on doing?', cid)
Topic[cid] = ''
elseif msgcontains(msg, 'help') then
selfSay('To learn more about the different types of fishing speak with Fishing Guru, Marvin.', cid)
Topic[cid] = ''
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())