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 getS_LUBO_AMBER = getCreatureStorage(cid, 111111yourstoragenr111111) -- change here
local getS_TMP_OS_TIME = getCreatureStorage(cid, 22222yourstoragenr22222) -- change here
local lubo_amber_time = 2*3600 -- ?h*3600sek
-- CITIZEN -- addon 1
-- <outfit id="1">
--- <list gender="0" lookType="136" name="Citizen"/>
-- <list gender="1" lookType="128" name="Citizen"/>
-- 5878 - 100 Minotaur Leathers
-- addon 1 info
if doMessageCheck(msg, 'addon') and getS_LUBO_AMBER == -1 then
selfSay("Sorry, the backpack I wear is not for sale. It's handmade from rare {minotaur leather}.", cid)
talkState[talkUser] = 1
elseif doMessageCheck(msg, 'minotaur leather') and talkState[talkUser] == 1 then
selfSay("Well, if you really like this backpack, I could make one for you, but minotaur leather is hard to come by these days. Are you willing to put some work into this?", cid)
talkState[talkUser] = 2
elseif doMessageCheck(msg, 'yes') and talkState[talkUser] == 2 then
doCreatureSetStorage(cid, S_LUBO_AMBER, 1)
selfSay("Alright then, if you bring me 100 pieces of fine minotaur leather I will see what I can do for you. You probably have to kill really many minotaurs though... so good luck!", cid)
talkState[talkUser] = 0
-- daje na backpack i ma przyjsc po 2h
elseif (doMessageCheck(msg, 'backpack') or doMessageCheck(msg, 'minotaur leather') or doMessageCheck(msg, 'addon')) and getS_LUBO_AMBER == 1 then
selfSay("Ah, right, almost forgot about the backpack! Have you brought me 100 pieces of minotaur leather as requested?", cid)
talkState[talkUser] = 3
elseif doMessageCheck(msg, 'yes') and talkState[talkUser] == 3 then
if getPlayerItemCount(cid,5878) >= 100 then
if doPlayerRemoveItem(cid, 5878, 100) then
doCreatureSetStorage(cid, S_LUBO_AMBER, 2)
doCreatureSetStorage(cid, S_TMP_OS_TIME, os.time())
selfSay("Great! Alright, I need a while to finish this backpack for you. Come ask me later, okay?", cid)
end
else
selfSay('You do not have all the required items.', cid)
end
talkState[talkUser] = 0
-- przyszedl
elseif doMessageCheck(msg, 'addon') and getS_LUBO_AMBER == 2 then
if canPlayerWearOutfitId(cid, 1, 1) then
selfSay("It seems you already have this addon, don't you try to mock me son!", cid)
elseif not isPremium(cid) then
selfSay("You need to buy premium in order to get this.", cid)
elseif (os.time() - lubo_amber_time) >= getS_TMP_OS_TIME then -- po 2h
selfSay("Just in time! Your backpack is finished. Here you go, I hope you like it.", cid)
doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_RED)
doPlayerAddOutfitId(cid, 1, 1)
else -- przed 2h
selfSay("Uh... I didn't expect you to return that early. Sorry, but I'm not finished yet with your backpack. I'm doing the best I can, promised.", cid)
end
talkState[talkUser] = 0
-- notebook quest
elseif doMessageCheck(msg, 'notebook') then
local tmp = getPlayerItemById(cid, true, 1955).uid
if tmp > 0 and getItemAttribute(tmp, "name") == "Amber's Notebook" then
if doRemoveItem(tmp, 1) then
doPlayerAddItem(cid, 2406, 1)
selfSay("Danke! Danke sehr!", cid)
else
selfSay("You don't even have that item, ".. getCreatureName(cid) .."!", cid)
end
else
selfSay("You don't even have that item, ".. getCreatureName(cid) .."!", cid)
end
talkState[talkUser] = 0
-- no
elseif doMessageCheck(msg, 'no') and isInArray({2,3}, talkState[talkUser]) then
selfSay('Ok then.', cid)
talkState[talkUser] = 0
end
return true
end
function thinkCallback()
local talk = math.random(1,1200)
if talk == 2 then
doCreatureSay(getNpcId(), "I wish I could eat some salmon right now... best prepared in Liberty Bay style... yummy.", TALKTYPE_YELL)
elseif talk == 4 then
doCreatureSay(getNpcId(), "Wow, I'm tired. I really should get some sleep... zzzz.", TALKTYPE_YELL)
elseif talk == 6 then
doCreatureSay(getNpcId(), "What was that word again in Orcish language... hmm.", TALKTYPE_YELL)
elseif talk == 8 then
doCreatureSay(getNpcId(), "Hey you! Are you an adventurer, too?", TALKTYPE_YELL)
elseif talk == 10 then
doCreatureSay(getNpcId(), "<sings> Stormy weathers, stormy weathers... stormy weathers on the sea!", TALKTYPE_YELL)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
npcHandler:addModule(FocusModule:new())