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
local storage = 5000
citizen = 23000
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, "addon") or msgcontains(msg, "backpack") or msgcontains(msg, "outfit") then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay("Sorry, the backpack I wear is not for sale. It\'s handmade from rare {minotaur leather}.", cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 1 then
selfSay("Ah, right, almost forgot about the backpack! Have you brought me 100 pieces of minotaur leather as requested?", cid)
talkState[talkUser] = 3
else
selfSay("I have already made a backpack for you.", cid)
end
elseif msgcontains(msg, "minotaur leather") and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay("Well, if you really like this backpack, I could make one for you, but minotaur leather is hard to come by these days. Are you willing to put some work into this?", cid)
talkState[talkUser] = 2
end
elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay("Alright then, if you bring me 100 pieces of fine minotaur leather I will see what I can do for you. You probably have to kill really many minotaurs though.. so good luck!", cid)
setPlayerStorageValue(cid, storage, 1)
end
elseif msgcontains(msg, "yes") then
if getPlayerStorageValue(cid, storage) == 1 and doPlayerRemoveItem(cid,5878,100) then
selfSay("Here you go, I hope you like it.", cid)
doSendMagicEffect(getCreaturePosition(cid), 13)
doPlayerAddOutfit(cid, 128, 1)
doPlayerAddOutfit(cid, 136, 1)
setPlayerStorageValue(cid,citizen,1)
setPlayerStorageValue(cid,storage,2)
else
selfSay("You do not have the leather.", cid)
end
talkState[talkUser] = 0
elseif msgcontains(msg, "no") and talkState[talkUser] == 2 then
selfSay("Ok then.", cid)
elseif msgcontains(msg, "no") and talkState[talkUser] == 3 then
selfSay("What are you waiting for? Without the leather I cannot make a backpack for you.", cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())