Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ########################################################
- -- ##### Name: Adriano Swatt' #####
- -- ##### Version: 3.0 #####
- -- ########################################################
- -- ##### Developed by Adriano Swatt' #####
- -- ##### Contact: [email protected] #####
- -- ##### PERSONALIZED TASK SYSTEM BY SWATT' #####
- -- ########################################################
- -- [[ EXPLAIN // EXPLICAÇÃO // COMO CONFIGURAR ]] --
- -- storage = Storage Que Salva: Task Ativa/Repetição/Dia/Hora/Minute
- -- countSto = Storage Que Salva Quantidade que Matou
- -- count = Quantidade Total Que Precisará Matar
- -- price = Preço da Task em Gold Coins
- -- repeated = Quantas Vezes Pode Realizar a Task
- -- inDay = Day Value: Quantos dias para realizar // false: se a task fica ativa até a conclusão
- -- awards = [1] = {id = Premio, multiply = quantidade} // seguindo modelo // usar [1] = {id = "exp", multiply = QUANTIDADE}
- -- DICA: Deixe sempre a Experiência por último
- _SETTING_TASK_SYSTEM_CONFIG = {
- taskAtSameTime = 3, -- Quantas Tasks Ativas Ao Mesmo Tempo
- }
- _MONSTERS_TASK_SYSTEM_CONFIG = {
- ["minotaur"] = {storage = 20001, countSto = 30001, count = 10, price = 5000, repeated = 5, inDay = false,
- mlist = {"minotaur", "minotaur archer", "minotaur guard"},
- awards = {
- [1] = {id = 2430, multiply = 1},
- [2] = {id = 2160, multiply = 2},
- [3] = {id = "exp", multiply = 5000}
- }
- },
- -- [[ SPACE ]] --
- ["cyclops"] = {storage = 20002, countSto = 30002, count = 15, price = 7000, repeated = 3, inDay = false,
- mlist = {"cyclops", "cyclops drone", "cyclops smith"},
- awards = {
- [1] = {id = 2195, multiply = 1},
- [2] = {id = 2160, multiply = 5},
- [3] = {id = "exp", multiply = 15000}
- }
- },
- -- [[ SPACE ]] --
- ["demon"] = {storage = 20003, countSto = 30003, count = 6666, price = 50000, repeated = 3, inDay = 5,
- mlist = {"demon"},
- awards = {
- [1] = {id = 2195, multiply = 1},
- [2] = {id = 2160, multiply = 10},
- [3] = {id = "exp", multiply = 100000}
- }
- },
- -- [[ SPACE ]] --
- ["orc"] = {storage = 20004, countSto = 30004, count = 20, price = 5000, repeated = 3, inDay = 5,
- mlist = {"orc", "orc berserker", "orc leader", "orc warrior"},
- awards = {
- [1] = {id = 2195, multiply = 1},
- [2] = {id = 6561, multiply = 1},
- [3] = {id = 2160, multiply = 10},
- [4] = {id = "exp", multiply = 100000}
- }
- },
- }
- -- [[ Storage: ativo (1) / repetição / Prazo ]] --
- function checkPlayerIsInTask(cid) -- RETURN: True if he can do some task // MonsterName if he can't
- getSto = doOrganizeTaskSto(_MONSTERS_TASK_SYSTEM_CONFIG)
- if isPlayer(cid) then
- pTaskTab = {}
- for a = getSto[1], getSto[#getSto] do
- if getPlayerStorageValue(cid, a) ~= -1 then
- onCheck = doCutTaskStorage(cid, a, "/")
- if #onCheck > 0 then
- active = tonumber(onCheck[1]:sub(2, 2))
- if active >= 1 then
- mName = whatTaskIsActive(cid, a)
- table.insert(pTaskTab, mName)
- end
- end
- end
- end
- return pTaskTab
- end
- return true
- end
- function checkPlayerRepetationTask(cid) -- RETURN: List of Repetation Tasks
- getSto = doOrganizeTaskSto(_MONSTERS_TASK_SYSTEM_CONFIG)
- if isPlayer(cid) then
- pTaskTab = {}
- for a = getSto[1], getSto[#getSto] do
- if getPlayerStorageValue(cid, a) ~= -1 then
- onCheck = doCutTaskStorage(cid, a, "/")
- if #onCheck > 0 then
- active = tonumber(onCheck[2])
- if active >= 1 then
- mName = whatTaskIsActive(cid, a)
- table.insert(pTaskTab, mName)
- end
- end
- end
- end
- return pTaskTab
- end
- return true
- end
- function checkAlreadyDoingThisTask(cid, name, list) -- Return Monster Name if Can Do, or false if can't
- cfg = _MONSTERS_TASK_SYSTEM_CONFIG
- for i = 1, #list do
- getArray = cfg[list[i]].mlist
- if getArray then
- if isInArray(getArray, name) then
- return list[i]
- end
- end
- end
- return false
- end
- function getInfoPlayerTask(cid, mName) -- Returns: [1] Repetition, [2] full date from Especific Task.
- local infoTab = {}
- getList = _MONSTERS_TASK_SYSTEM_CONFIG
- if isPlayer(cid) then
- getInfo = getList[mName:lower()]
- if getInfo then
- if getPlayerStorageValue(cid, getInfo.storage) ~= -1 then
- local onCut = doCutTaskStorage(cid, getInfo.storage, "/")
- if #onCut > 0 then
- for a = 2, 3 do
- table.insert(infoTab, tonumber(onCut[a]))
- end
- return infoTab
- else
- return true
- end
- else
- return false
- end
- end
- end
- end
- function doCutTaskStorage(cid, storageKey, cutType) -- cutType [Ex: ","]
- local cutSto = {}
- local string = tostring(getPlayerStorageValue(cid, storageKey))
- local cutSto = string:explode(cutType)
- if #cutSto > 0 then
- for i = 1, #cutSto do
- table.insert(cutSto, cutSto[i])
- end
- return cutSto
- else
- return true
- end
- end
- function whatTaskIsActive(cid, stoKey) -- Retorna Nome das Task Ativa
- taskList = _MONSTERS_TASK_SYSTEM_CONFIG
- for index, result in pairs(taskList) do
- if result.storage == stoKey then
- return index
- end
- end
- end
- function getAwardsList(cid, list) -- Retorna Lista de Premiação
- local awardList = ''
- get = list
- for a = 1, #list do
- if isNumber(list[a].id) then
- if list[a].multiply <= 1 then
- awardList = awardList.."{"..list[a].multiply.."x "..getItemNameById(list[a].id).."}, "
- else
- awardList = awardList.."{"..list[a].multiply.."x "..getItemPluralNameById(list[a].id).."}, "
- end
- else
- cawardList = awardList:sub(1, (#awardList-2))
- awardList = cawardList.." and {"..list[a].multiply.." experience points}"
- end
- end
- return awardList
- end
- function doGiveTaskAwards(cid, list) -- Entrega Lista de Prêmios
- if isPlayer(cid) then
- for a = 1, #list do
- if isNumber(list[a].id) then
- doPlayerAddItem(cid, list[a].id, list[a].multiply)
- else
- doPlayerAddExp(cid, list[a].multiply)
- end
- end
- end
- return true
- end
- function doGiveTaskMonsterList(cid, list) -- Retorna Lista de Task Ativas [Tabela Monster Names]
- if isPlayer(cid) then
- name = ""
- for a = 1, #list do
- if a == 1 then
- name = "{"..list[a].."}"
- elseif a > 1 and a < #list then
- name = ""..name..", {"..list[a].."}"
- else
- name = ""..name.." and {"..list[a].."}"
- end
- end
- end
- return name
- end
- function doCloseTimedTask(cid, monster)
- getInfo = getInfoPlayerTask(cid, monster)
- taskList = _MONSTERS_TASK_SYSTEM_CONFIG
- getM = taskList[monster]
- if getM then
- if getInfo then
- repet = getInfo[1]
- data = getInfo[2]
- newValue = "&0/"..repet.."/"..data..""
- setPlayerStorageValue(cid, getM.storage, newValue)
- setPlayerStorageValue(cid, getM.countSto, 0)
- end
- end
- end
- function doPlayerDonePersoTask(cid)
- taskList = checkPlayerIsInTask(cid)
- if #taskList > 0 then
- mList = _MONSTERS_TASK_SYSTEM_CONFIG
- for i = 1, #taskList do
- task = mList[taskList[i]]
- if task then
- killeds = getPlayerStorageValue(cid, task.countSto)
- if killeds == task.count then
- return taskList[i]
- end
- end
- end
- else
- return false
- end
- end
- function doOrganizeTaskSto(taskList) -- Retorna Primeira e Última Storage de Todas Tasks
- local tabSto = {}
- taskList = _MONSTERS_TASK_SYSTEM_CONFIG
- for index, result in pairs(taskList) do
- if result.storage then
- table.insert(tabSto, result.storage)
- end
- end
- table.sort(tabSto, function(a, b) return a < b end)
- return tabSto
- end
Advertisement
Add Comment
Please, Sign In to add comment