Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <mod name="Task System" version="0.4.0" author="Oskar" contact="oskar1121@gmail.com" enabled="yes">
- <config name="tasks_conf"><![CDATA[
- REWARD_ITEM = 0
- REWARD_EXP = 1
- REWARD_MONEY = 2
- REWARD_ADDON = 3
- REWARD_SKILL = 4
- REWARD_STORAGE = 5
- REWARD_LEVEL = 6
- AUTO_TASK_LIST = {
- [1] = { details = {'wolf'}, totalKills = 20, storage = 2001, name = 'wolves',
- rewards = {REWARD_ITEM, 2152, 5, REWARD_EXP, 0, 500}, -- 250 expa/500 gp -->
- requiredLevel = {1, 50000}, repeatable = false},
- [2] = { details = {'orc', 'orc spearman', 'orc warrior'}, totalKills = 1000, storage = 2002, name = 'orcs',
- rewards = {REWARD_MONEY, 2152, 5, REWARD_EXP, 0, 500}, -- 250 expa/500 gp -->
- requiredLevel = {1, 50000}, repeatable = false},
- }
- --[[function getDetails(cid, status, realCount)
- local count, detail, complete = #status.details / 2, '', true
- local subStorage = getCreatureStorage(cid, countStorage)
- local killsCount = subStorage ~= -1 and tostring(subStorage):explode('_')
- for i = 1, count do
- if status.var == TYPE_KILL and (not killsCount or ((tonumber(killsCount[i + 1]) or 0) < status.details[i * 2])) then
- complete = false
- elseif status.var == TYPE_ITEMBACK and getPlayerItemCount(cid, status.details[i * 2 - 1]) < status.details[i * 2] then
- complete = false
- end
- if status.var == TYPE_KILL then
- detail = detail .. (realCount and tonumber(killsCount[i + 1]) or status.details[i * 2]) .. 'x of ' .. status.details[i * 2 - 1]
- elseif status.var == TYPE_ITEMBACK then
- detail = detail .. status.details[i * 2] .. 'x of ' .. getItemNameById(status.details[i * 2 - 1])
- end
- if i < count - 1 and count > 2 then
- detail = detail .. ', '
- elseif i == count - 1 and count > 1 then
- detail = detail .. ' and '
- end
- end
- return detail, complete
- end]]
- ]]></config>
- <event type="kill" name="taskKill" event="script"><![CDATA[
- domodlib('tasks_conf')
- local function doTakeReward(cid, var)
- for i = 1, #var / 3 do
- if var[i * 3 - 2] == REWARD_ITEM then
- doPlayerAddItem(cid, var[i * 3 - 1], var[i * 3], true)
- elseif var[i * 3 - 2] == REWARD_EXP then
- doAddExp(cid, var[i * 3])
- elseif var[i * 3 - 2] == REWARD_STORAGE then
- doCreatureSetStorage(cid, var[i * 3 - 1], var[i * 3])
- elseif var[i * 3 - 2] == REWARD_MONEY then
- doPlayerAddMoney(cid, var[i * 3])
- elseif var[i * 3 - 2] == REWARD_SKILL then
- doPlayerSetSkill(cid, var[i * 3 - 1], getPlayerSkillLevel(cid, var[i * 3 - 1]) + var[i * 3])
- elseif var[i * 3 - 2] == REWARD_ADDON then
- doPlayerAddOutfit(cid, (getPlayerSex(cid) == 0 and var[i * 3 - 1][1] or var[i * 3 - 1][2]), var[i * 3])
- elseif var[i * 3 - 2] == REWARD_LEVEL then
- doPlayerAddLevel(cid, var[i * 3])
- end
- end
- end
- local function getTaskByName(name)
- for _, v in pairs(AUTO_TASK_LIST) do
- for i = 1, #v.details / 2 do
- if name == v.details[i * 2 - 1]:lower() then
- return v
- end
- end
- end
- return false
- end
- function onKill(cid, target)
- if not isMonster(target) or not isPlayer(cid) then
- return true
- end
- local var = getTaskByName(getCreatureName(target):lower())
- if not var then
- return true
- end
- local storage = math.max(0, getCreatureStorage(cid, var.storage))
- if storage >= var.totalKills then
- return true
- end
- storage = storage + 1
- if storage >= var.totalKills then
- doTakeReward(cid, var.rewards)
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations! You finished ' .. var.name .. ' task.')
- else
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have killed ' .. var.name .. '. [' .. storage .. '/' .. var.totalKills .. '].')
- end
- doCreatureSetStorage(cid, var.storage, storage)
- return true
- end
- ]]></event>
- <talkaction words='!mission' event='script'><![CDATA[
- domodlib('tasks_conf')
- function onSay(cid, words, param, channel)
- local id = tonumber(getCreatureStorage(cid, storage))
- local status = task[id]
- local message = ''
- if status then
- local detail, complete = getDetails(cid, status, true)
- message = 'Mission State [ ' .. id .. '] - ' .. detail
- if status.var == TYPE_KILL then
- message = message .. ' killed.'
- elseif status.var == TYPE_ITEMBACK then
- message = message .. ' gathered.'
- end
- else
- message = 'You are not started any task.'
- end
- doPlayerPopupFYI(cid, message)
- end
- ]]></talkaction>
- <event type="login" name="taskLogin" event="script"><![CDATA[
- function onLogin(cid)
- registerCreatureEvent(cid, 'taskKill')
- return true
- end
- ]]></event>
- </mod>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement