local quests =
{
{ 1111, "Rat", 30, "Congratulations! You finished a first quest of Rats!" }, -- storage of starts quest, monster, count to kill, gift id, gift count, message on finish
{ 1112, "Demon", 100, "Congratulations!" },
{ 1113, "Rat", 5, "Congratulations! You finished a second quest of Rats!" }
}
function onKill(cid, target, lastHit)
if (not isMonster(target)) then
return false
end
for i=1, #quests do
if (getCreatureName(target) == quests[2] and not (getPlayerStorageValue(cid, quests[1]) > quests[3])) then
if (getPlayerStorageValue(cid, quests[1]) == -1) then
doPlayerSetStorageValue(cid, quests[1], 0)
end
doPlayerSetStorageValue(cid, quests[1], (getPlayerStorageValue(cid, quests[1])+1))
if (getPlayerStorageValue(cid, quests[1]) == quests[3]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, quests[4])
end
return true
end
end
return true
end
a w tym localdoPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Zabiles " .. killedMonsters .. " ")
zeby liczylo ile i jakiego monstera.. killedMonsters ..
local quests =
{
{ 1111, "Rat", 30 }, -- storage of starts quest, monster, count to kill
{ 1112, "Demon", 100 },
{ 1113, "Rat", 5 }
}
function onKill(cid, target, lastHit)
if (not isMonster(target)) then
return false
end
for i=1, #quests do
if (getCreatureName(target) == quests[i][2] and getPlayerStorageValue(cid, quests[i][1]) ~= -1 and not (getPlayerStorageValue(cid, quests[i][1]) > quests[i][3])) then
if (getPlayerStorageValue(cid, quests[i][1]) == quests[i][3]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Ukonczyles misje, biegnij do NPC po nagrode")
end
doPlayerSetStorageValue(cid, quests[i][1], (getPlayerStorageValue(cid, quests[i][1])+1))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Zabiles " .. getPlayerStorageValue(cid, quests[i][1]) .. " " .. getPlayerStorageValue(cid, quests[i][2]) .."")
return true
end
end
return true
end
local tasks =
{
{ name = "Rats First", questStorage = 1111, killsRequired = 30, raceName = "Rats", rewards = {type = "exp", values = 200}},
{ name = "Demons Mission", questStorage = 1112, killsRequired = 100, raceName = "Demons", rewards = {type = "item", values = 2160, count = 10}},
{ name = "Rats Second", questStorage = 1111, killsRequired = 5, raceName = "Rats", rewards = {type = "exp", values = 600}}
}
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
if msgcontains(msg, 'start') then
selfSay('What mission?', cid)
talkState[cid] = 1
elseif msgcontains(msg, 'reward') then
talkState[cid] = 2
elseif talkState[cid] == 1 then
for i=1, #tasks do
if (msg == tasks[i].name) then
doPlayerSetStorageValue(cid, tasks[i].questStorage, 0)
selfSay('Started! Let\'s Go!', cid)
talkState[cid] = 0
break
end
end
elseif talkState[cid] == 2 then
for i=1, #tasks do
if (msg == tasks[i].name) then
if (getPlayerStorageValue(cid, tasks[i].questStorage) == tasks[i].killsRequired) then
if(tasks[i].rewards.type == "exp") then
doPlayerAddExperience(cid, tasks[i].rewards.values)
elseif(tasks[i].rewards.first.type == "item") then
doPlayerAddItem(cid, tasks[i].rewards.values[1], tasks[i].rewards.values[2])
end
doPlayerSetStorageValue(cid, tasks[i].questStorage, 65000)
selfSay('Congratulations!', cid)
break
end
end
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())