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
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addBuyableItem({'Lyre'}, 2071, 120, 'Ape Fur')
shopModule:addBuyableItem({'Drum'}, 2073, 140, 'Drum')
shopModule:addBuyableItem({'Lute'}, 2072, 195, 'Lute')
shopModule:addBuyableItem({'Simple Fanfare'}, 2075, 150, 'Simple Fanfare')
item = 'You do not have the required items.'
done = 'Here you are.'
local cost = 200
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'love poem') then
selfSay('Do you want to buy a love poem for 200 gold?', cid)
talkState[talkUser] = 4
if msgcontains(msg, 'yes') then
if(doPlayerRemoveMoney(cid, cost) == TRUE) then
doPlayerAddItem(cid,8189,1)
end
else
npcHandler:say('You don\'t have ' .. cost .. ' gp! Come back when you will be ready!', cid)
end
elseif msgcontains(msg, 'green piece of cloth') then
if getPlayerItemCount(cid,2652) >= 1 then
selfSay('Did you bring me the Green Tunic ?', cid)
talk_state = 13
else
selfSay('I need a Green Tunic, to give you the Green Piece of Cloth. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 13 then
talk_state = 0
if getPlayerItemCount(cid,2652) >= 1 then
if doPlayerRemoveItem(cid,2652,1) == TRUE then
doPlayerAddItem(cid,5910,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'red piece of cloth') then
if getPlayerItemCount(cid,2655) >= 1 then
selfSay('Did you bring me the Red Robe ?', cid)
talk_state = 14
else
selfSay('I need a Red Robe, to give you the Red Piece of Cloth. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 14 then
talk_state = 0
if getPlayerItemCount(cid,2655) >= 1 then
if doPlayerRemoveItem(cid,2655,1) == TRUE then
doPlayerAddItem(cid,5911,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay('Ok then.')
talk_state = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())