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
--------------------------------
------- NPC MISSION 2.0 --------
------ by Acubens - Otland.net -
--------------------------------
local first = {
-- Place true if you want to use the system of experience as a reward, false if you want to use items as a reward
useExpReward = true,
-- The experience that will get the player at the end of the mission
experience = 1000,
-- Id of the item that will be asking for the NPC to complete the mission
item = 2320,
-- Count of the item required
item_count = 1,
-- id of the gift that going to obtain the player at finish the mission
reward = 2152,
-- count of the gift item
reward_count = 5,
-- storage
storage = 1004,
-- name of the quest
questname = "Sewer Worker"
}
local npc_message ={
-- Proceed - message
"So did they overwhelm him and end up, err, killing... him?",
-- if you dont have items - message
"I need proof of what happened to my sewer worker.",
-- thanks - message
"Well, that is unfortunately bad news, but thank you for telling me what happened and at least you did his original job for me by exterminating the rats. Here is some cash, go buy some better gear and go exploring!",
-- already done - message
"Well we already know that the sewer worker is dead. You can hone your skills more before you leave town by killing more rats down there though if you would like to.",
-- ready to go - message
"I sent him down into the sewer to get rid of the rats, but who knows, maybe they {overwhelmed} him and, well, killed him.",
-- congratulations - message
"Congratulations, you have finished the quest: Sewer Worker"
}
if(msgcontains(msg, 'sewer')) then
selfSay(npc_message[5], cid)
end
if(msgcontains(msg, 'key')) and getPlayerStorageValue(cid, 1005) == 1 then
setPlayerStorageValue(cid, 1005, 2)
doItemSetAttribute(doPlayerAddItem(cid, 2089, 1), "aid", 2004)
elseif (msgcontains(msg, 'key')) and getPlayerStorageValue(cid, 1005) == 2 then
selfSay("I already gave you the key", cid)
end
if(msgcontains(msg, 'overwhelmed')) then
selfSay(npc_message[1], cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if (getPlayerStorageValue(cid,first.storage) == 3) then
selfSay(npc_message[4], cid)
else
if (first.item).itemaid == 2504 and (doPlayerRemoveItem(cid,first.item,first.item_count)) then
setPlayerStorageValue(cid,first.storage,3)
if(useExpReward) then
doPlayerAddExperience(cid,first.experience)
doPlayerAddItem(cid, 2152, 5)
else
doPlayerAddItem(cid,first.reward,first.reward_count)
doPlayerAddExp(cid, 4000)
end
selfSay(npc_message[3], cid)
doSendMagicEffect(getCreaturePosition(cid), 10)
doCreatureSay(cid, npc_message[6], TALKTYPE_ORANGE_1)
else
selfSay(npc_message[2], cid)
end
end
return true
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())