local gifts = { [1] = { [1] = {6512, 1}, [2] = {6531, 1}, [3] = {11255, 1}, [4] = {11263, 1} }, [2] = { [1] = {2168, 100}, [2] = {2173, 100}, [3] = {6572, 1}, [4] = {6570, 1}, [5] = {6571, 1}, [6] = {2688, 20}, [7] = {6574, 20}, [8] = {6569, 100}, [9] = {2675, 20}, [10] = {6513, 1}, [11] = {6501, 5} }, [3] = { ['fireborn giant armor'] = 8881, ['earthborn titan armor'] = 8882, ['windborn colossus armor'] = 8883, ['robe of the underworld'] = 8890, ['nightmare shield'] = 6391, ['necromancer shield'] = 6433, ['koshei\'s ancient amulet'] = 8266 } } local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local topic, item, storage = {}, {}, 12115 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 if msgcontains(msg, 'present') or msgcontains(msg, 'gift') or msgcontains(msg, 'box') then if getPlayerLevel(cid) >= 100 then if getCreatureStorage(cid, storage) == EMPTY_STORAGE then selfSay('Have you been nice this year?', cid) topic[cid] = 1 else selfSay('I can give you gift only once.', cid) end else selfSay('You must be at least level 100 to receive gift.', cid) end elseif msgcontains(msg, 'yes') and topic[cid] == 1 then local n if math.random(1, 50) == 1 then n = gifts[1][math.random(#gifts[1])] else n = gifts[2][math.random(#gifts[2])] end doPlayerAddItem(cid, n[1], math.random(n[2])) doCreaturesetStorage(cid, storage, 1) selfSay('Here you are.', cid) topic[cid] = nil elseif msgcontains(msg, 'tokens') then selfSay('I can offer you {robe of the underworld}, {fireborn giant armor}, {earthborn titan armor}, {windborn colossus armor}, {nightmare shield}, {necromancer shield} and {koshei\'s ancient amulet}. Each item is 500 christmas tokens.', cid) topic[cid] = 2 elseif gifts[3][msg:lower()] and topic[cid] == 2 then selfSay('Do you want to give me 500 christmas tokens for {'.. msg ..'}?', cid) item[cid] = gifts[3][msg:lower()] topic[cid] = 2 elseif msgcontains(msg, 'yes') and topic[cid] == 2 then if doPlayerRemoveItem(cid, 6527, 500) then doPlayerAddItem(cid, item[cid], 1) selfSay('Here you are.', cid) else selfSay('You don\'t have enough christmas tokens.', cid) end topic[cid] = nil item[cid] = nil elseif msgcontains(msg, 'no') and isInArray({1, 2}, topic[cid]) then selfSay('Ok then.', cid) talkState[talkUser] = nil end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:setMessage(MESSAGE_GREET, 'Ho, ho, ho! Merry christmas |PLAYERNAME|. I can give you {present} if you were nice or exchange my items for your christmas {tokens}.') npcHandler:addModule(FocusModule:new())