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 onPlayerEndTrade(cid) npcHandler:onPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid) npcHandler:onPlayerCloseChannel(cid) 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 item = 11111 -- need item
local outfit = 111 -- give outfit
-- prize
if doMessageCheck(msg, 'outfit') then
selfSay('blabla outfit?', cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 and doMessageCheck(msg, 'yes') then
if isPremium(cid) then
if doPlayerRemoveItem(cid, item, 100) then
if not canPlayerWearOutfitId(cid, outfit, 1) then
selfSay('Congratulations! Here, from now on you can wear our lovely potion belt as accessory.', cid)
doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_RED)
doPlayerAddOutfit(cid, outfit, 1)
else
selfSay('It seems you already have this addon, don\'t you try to mock me son!', cid)
end
else
selfSay('You do not have required items.')
end
else
selfSay('You have no premium acount!', cid)
end
talkState[talkUser] = 0
-- no
elseif(doMessageCheck(msg, 'no') and isInArray({1}, talkState[talkUser])) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())