-- [url]http://otland.net/f132/help-npc-146299/[/url]
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)
if(not npcHandler:isFocused(cid)) then return false end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local exp = 121212 -- Experience
-- 100 green eggs id:6544 for exp or for a blue egg id:6543
if doMessageCheck(msg, "green eggs") then
if getPlayerItemCount(cid, 6544) >= 100 then
selfSay("you will trade for blue egg or more experience", cid)
talkState[talkUser] = 1
end
elseif talkState[talkUser] == 1 and doMessageCheck(msg, "blue egg") then
if doPlayerRemoveItem(cid, 6544, 100) then
doPlayerAddItem(cid, 6543, 1)
selfSay("here", cid)
else
selfSay("items?", cid)
end
talkState[talkUser] = 0
elseif talkState[talkUser] == 1 and doMessageCheck(msg, "exp") then
if doPlayerRemoveItem(cid, 6544, 100) then
doPlayerAddExperience(cid, exp)
selfSay("here", cid)
else
selfSay("items?", cid)
end
talkState[talkUser] = 0
-- msg "no"
elseif doMessageCheck(msg, 'no') and isInArray({1}, talkState[talkUser]) then
selfSay("Okay. Okey.", cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())