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 goldenNuggetID = 2157
local storageValue = 16000
local goldenHelmetID = 2471
local name = getPlayerName(cid)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
-----------------------------------------
if msgcontains(msg, 'golden helmet') then
if getPlayerItemCount(cid, goldenNuggetID) >= 2 then
if getPlayerStorageValue(cid, storageValue) == -1 then
setPlayerStorageValue(cid, storageValue, 1)
selfSay('You got 2 golden nuggets to exchange?', cid)
talkState[talkUser] = 1
else
selfSay('You already made this quest', cid)
talkState[talkUser] = 0
end
else
selfSay('You don\'t have a golden helmet!', cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
doPlayerRemoveItem(cid, goldenNuggetID, 2)
doPlayerAddItem(cid, goldenHelmetID, 1)
selfSay('Thank you ' .. name ..'', cid)
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end
-----------------------------------------
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())