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 greetCallback(cid)
if getPlayerStorageValue(cid,1250) <= 0 then
npcHandler:setMessage("Welcome traveler, I could use some {'help'}.")
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid,1250) == 1 then
npcHandler:say("Welcome back, do you have the items that I need help with?", cid)
talkState[talkUser] = 2
elseif getPlayerStorageValue(cid,1250) == 2 then
npcHandler:say('Hello again, I don\'t need any more help.',cid)
end
return true
end
function creatureSayCallback(cid, type, msg)
if talkState[talkUser] == 1 then
npcHandler:say('I need help on collecting 25 blueberries, do you want to help me?',cid)
talkState[talkUser] = 3
elseif talkState[talkUser] == 2 then
npcHandler:say('Have you gotten the blueberries yet?',cid)
talkState[talkUser] = 4
elseif talkState[talkUser] == 3 then
if msgcontains(msg,'yes') then
setPlayerStorageValue(cid,1250,1)
npcHandler:say('Thank you, talk to me again when you have all the blueberries!',cid)
elseif msgcontains(msg,'no') then
npcHandler:say('Than not!',cid)
return true
end
elseif talkState[talkUser] == 4 then
if msgcontains(msg,'yes') then
if doPlayerRemoveItem(cid,2677,25) then
doPlayerAddExperience(cid,500)
npcHandler:say('Thank you very much!',cid)
setPlayerStorageValue(cid,1250,2)
else
npcHandler:say('You don\'t have enough blueberries!',cid)
end
elseif msgcontains(msg,'no') then
npcHandler:say('Than not!',cid)
return true
end
return true
end
end
npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell, traveler!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Farewell, traveler |PLAYERNAME|!")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())