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 = {
{item = 11198, count = 100, storage = 700, value = 1, percent_lv = 5}, --tarantula egg
{item = 11226, count = 150, storage = 701, value = 1, percent_lv = 7}, --strands of medusa hair
{item = 5882, count = 300, storage = 702, value = 1, percent_lv = 6}, --red dragon scales
{item = 5920, count = 400, storage = 703, value = 1, percent_lv = 5} --green dragon scales
}
if(msgcontains(msg, 'quest')) then
selfSay('To start this quest tell {mission}', cid) --This is just an example, In this script added 4 mission for you ;)
end
if(msgcontains(msg, 'mission')) then
for i = 1, #config do
if getPlayerStorageValue(cid, config[i].storage) == -1 then
selfSay('Your mission will be to get '..config[i].count..' {'..getItemNameById(config[i].item)..'}.', cid)
talkState[talkUser] = i
elseif (getPlayerStorageValue(cid,703) == 1) then --zmieniac w zaleznosci od ostatniego storage!!
selfSay('You have done all missions.', cid)
return true
end
---------------------------------------
if msgcontains(msg, getItemNameById(config[i].item)) and talkState[talkUser] == i then
if doPlayerRemoveItem(cid, config[i].item, config[i].count) then
doPlayerSetStorageValue(cid, config[i].storage, config[i].value)
doPlayerAddPercentLevel(cid, config[i].percent_lv)
selfSay('Thank you.', cid)
return true
else
selfSay('To end mission you need have '..config[i].count..' {'..getItemNameById(config[i].item)..'}.', cid)
end
end
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())