local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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 creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local storage = 1000 --Set a storage value
if(msgcontains(msg, 'sams old backpack') or msgcontains(msg, 'sam')) then
npcHandler:say("Have sam's backpack?", cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if(doPlayerRemoveItem(cid, 3960, 1) == TRUE) then
npcHandler:say("Off you go!", cid)
setPlayerStorageValue(cid, storage, 1)
talkState[talkUser] = 0
else
npcHandler:say("You dont have the item.", cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
npcHandler:say("Then not.", cid)
talkState[talkUser] = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())