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
local config = {
npcstorage = 18687,
killstorage = 19001,
amountkills = 50,
rewarditem = 2160,
rewardexp = 12000
}
if(msgcontains(msg, 'mission')) then
if getPlayerStorageValue(cid, config.npcstorage) == -1 then
selfSay('So you want to do the mission? I want you to kill 50 players, do you accept?', cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, config.npcstorage) == 1 then
selfSay('Did you kill 50 players?', cid)
talkState[talkUser] = 1
else
selfSay('You already did your mission.', cid)
end
elseif(msgcontains(msg, 'yes')) and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, config.npcstorage) == -1 then
selfSay('Lets see if you can make it!', cid)
doPlayerSetStorageValue(cid, config.npcstorage, 1)
talkState[talkUser] = 0
return true
end
if getPlayerStorageValue(cid, config.npcstorage) == 1 and getPlayerStorageValue(cid, config.killstorage) >= config.amountkills then
selfSay('Well, didn\'t expected it, but well done, here is your reward.', cid)
doPlayerAddItem(cid, config.rewarditem, 1)
doPlayerAddExp(cid, config.rewardexp)
doPlayerSetStorageValue(cid, config.npcstorage, 2)
talkState[talkUser] = 0
else
selfSay('You killed '..(getPlayerStorageValue(cid, config.killstorage) +1)..' players, you need to kill '..config.amountkills..'!', cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
talkState[talkUser] = 0
selfSay('I knew you were not strong enough!', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())