local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
local storage = 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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addBuyableItem({"mug of beer"}, 2012, 10, 3, "mug of beer")
shopModule:addBuyableItem({"mug of water"}, 2012, 5, 1, "mug of water")
shopModule:addBuyableItem({"salmon"}, 2668, 15, 1, "salmon")
shopModule:addBuyableItem({"rainbow trout"}, 7158, 15, 1, "rainbow trout")
shopModule:addBuyableItem({"green perch"}, 7159, 15, 1, "green perch")
shopModule:addSellableItem({"worm"}, 3976, 1, 1, "worm")
shopModule:addSellableItem({"fish"}, 2667, 3, 1, "fish")
function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and (not npcHandler:isFocused(cid)) then
npcHandler:say("Why hello "..getCreatureName(cid)..". What can I do for you?", cid, TRUE)
Topic[talkUser] = 0
npcHandler:addFocus(cid)
elseif(not npcHandler:isFocused(cid)) then
return false
elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
npcHandler:say("Good bye.", cid, TRUE)
Topic[talkUser] = 0
npcHandler:releaseFocus(cid)
elseif msgcontains(msg, "mission") or msgcontains(msg, "quest") or msgcontains(msg, "task") then
local s = getPlayerStorageValue(cid, storage)
if s < 1 then
npcHandler:say("I'm just a bartender, trying to earn some money to support my family. We make our living on {fish}, you know, and I have absolutely no time to be fidling around with you and your silly missions.", cid)
Topic[talkUser] = 1
elseif s == 1 then
npcHandler:say("Your current task is to bring me 20 {fish}.", cid)
Topic[talkUser] = 0
elseif s == 2 then
npcHandler:say("OHH! That's right, the quest you wanted to do. Well this quest requires you to face horrible creatures that could get you killed! Are you sure you want to do this?", cid)
Topic[talkUser] = 2
end
elseif Topic[talkUser] == 1 and msgcontains(msg, "fish") and getPlayerStorageValue(cid, storage) < 1 then
npcHandler:say("Wait a minute, that's not a bad idea. If you bring me 20 {fish}, I'll be glad to tell you about a {quest} you can do. Here, take these worms and my lucky fishing pole.", cid)
doPlayerAddItem(cid, 3976, 30)
doPlayerAddItem(cid, 2580, 1)
setPlayerStorageValue(cid, storage, 1)
Topic[talkUser] = 0
elseif msgcontains(msg, "fish") and getPlayerStorageValue(cid, storage) == 1 then
if getPlayerItemCount(cid, 2580) > 0 and doPlayerRemoveItem(cid, 2667, 20) == TRUE then
doPlayerRemoveItem(cid, 2580, 1)
npcHandler:say("Oh my, am I glad you got those fish for me! I thank you for these magnificent looking fish, but if only I had some gold to reward you.", cid)
setPlayerStorageValue(cid, storage, 2)
else
npcHandler:say("You have bring me 20 fish and my fishing pole back.", cid)
end
Topic[talkUser] = 0
elseif Topic[talkUser] == 2 then
if msgcontains(msg, "yes") then
npcHandler:say("Ok then, listen well...", cid, FALSE, FALSE)
npcHandler:say("A few weeks ago my friend, Sam, went into a deserted forest to find the Lost Cave of Brotherhood with his dearest friend, Hagred, and Sam's brother, Billy. They found the cave alright, but they also found some terrible creatures...", cid, FALSE, FALSE)
npcHandler:say("Unfortunately, Sam di... He d...He died defending his brother. <crying> Billy and Hagred made it out alive, but what people didnt understand until a few days ago was that they weren't only finding this cave, they were looking for a liquid that could control anything its used against...", cid, FALSE, FALSE)
npcHandler:say("What I want you to do is find Sam's backpack in the forest, near this cave and return it to me. Leave the liquid in the backpack.", cid, FALSE, FALSE)
setPlayerStorageValue(cid, storage, 3)
else
npcHandler:say("Perhaps you've made a right decision.", cid)
end
Topic[talkUser] = 0
end
return TRUE
end
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)