Ir para conteúdo
  • 0
Entre para seguir isso  
Luan MF

Scripting Repetir as Tasks 7.6

Pergunta

Luan MF    7
Luan MF

Olá, primeiramente estou usando um OT Global 7.6 full OTX2

estou com um probleminha no sistema de tasks, eu queria que os players pudessem repedir as task assim que terminassem ela. ja tentei retirar o storage das tasks no mods/tasks.xml, mas o NPC sempre entrega o prremio da ultima task da lista, independente de qual task eu escolher, então não deu certo. tbm tentei voltar ao normal  com as storages e tenta retirar o CheckTask script do npc, mas o npc sempre buga e para de responder.

Script do NPC:

Spoiler

domodlib('task_func')

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 msg = string.lower(msg)

if isInArray({"task","tasks","missao","mission"}, msg) then

npcHandler:say("You can choose the following missions task: troll, goblin, rotworm, cyclops, minotaur, dragon, giant spider, warlock, demon, hydra!", cid)

talkState[talkUser] = 1

elseif talkState[talkUser] == 1 then

if tasktabble[msg] then

if CheckTask(cid) ~= true then

local contagem = getPlayerStorageValue(cid, tasktabble[msg].storage)

if (contagem == -1) then contagem = 1 end

if not tonumber(contagem) then npcHandler:say('Sorry, but you have already completed the task of '..msg, cid) return true end

setPlayerStorageValue(cid, tasktabble[msg].storage_start, 1)

npcHandler:say("Congratulations, you are now participating in the mission task of "..msg..", You have not killed the "..string.sub(((contagem)-1)-tasktabble[msg].count, 2).." "..msg, cid)

talkState[talkUser] = 0

else

npcHandler:say('Sorry, but you already in a task!', cid)

talkState[talkUser] = 0

end

else

npcHandler:say('enter the correct name of the mission task! for more information say {!task}', cid)

talkState[talkUser] = 1

end

elseif isInArray({"receber","reward","recompensa","report","reportar"}, msg) then

if CheckTask(cid) then

for k, v in pairs(tasktabble) do

racetype = k

if getPlayerStorageValue(cid,v.storage_start) >= 1 then

local contagem = getPlayerStorageValue(cid, v.storage)

if (contagem == -1) then contagem = 1 end

if not tonumber(contagem) then npcHandler:say('you can only receive the items 1x!', cid) return true end

if (((contagem)-1) >= v.count) then

for _, check in pairs(configbosses_task) do

if string.lower(check.race) == string.lower(racetype) then

local on = getPlayersOnline()

for i=1, #on do

if HavePlayerPosition(on, check.FromPosToPos[1],check.FromPosToPos[2]) then

selfSay('wait a few moments, there are people doing the task.', cid) return true

end

end

doTeleportThing(cid, check.Playerpos)

local function checkArea(cid)

if not isCreature(cid) then return LUA_ERROR end

if HavePlayerPosition(cid, check.FromPosToPos[1],check.FromPosToPos[2]) then

doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))

end

end

addEvent(checkArea, check.time*60*1000, cid)

end

end

local str = ""

if v.exp ~= nil then doPlayerAddExp(cid, v.exp ) str = str.."".. (str == "" and "" or ",") .." "..v.exp.." de exp" end

if v.money ~= nil then doPlayerAddMoney(cid, v.money) str = str.."".. (str == "" and "" or ",") ..""..v.money.." gps" end

if v.reward ~= nil then doAddItemsFromList(cid,v.reward) str = str.."".. (str == "" and "" or ",") ..""..getItemsFromList(v.reward) end

npcHandler:say("Thanks for your help Rewards: "..(str == "" and "nothing" or ""..str.."").." for having completed the task of "..k, cid)

setPlayerStorageValue(cid, v.storage, "Finished")

setPlayerStorageValue(cid, v.storage_start, 0)

setPlayerStorageValue(cid, 521456, getPlayerStorageValue(cid, 521456) == -1 and 1 or getPlayerStorageValue(cid, 521456)+1)

finisheAllTask(cid)

else

npcHandler:say('Sorry, but you just killed '..((contagem)-1)..' of '..v.count..' '..k, cid)

end

end

end

else

npcHandler:say("You are not on any mission task", cid)

end

elseif isInArray({"sair","leave","exit"}, msg) then

if CheckTask(cid) then

talkState[talkUser] = 2

for k, v in pairs(tasktabble) do

if getPlayerStorageValue(cid,v.storage_start) >= 1 then

storagesair = v.storage_start

local contagem = getPlayerStorageValue(cid, v.storage)

if (contagem == -1) then contagem = 1 end

npcHandler:say('you are participating in a mission task of '..k..' and already have '..((contagem)-1)..' '..k..' dead, do you really want to leave?', cid)

end

end

else

npcHandler:say("You are not on any mission task.", cid)

end

elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then

setPlayerStorageValue(cid, storagesair, 0)

npcHandler:say("You have been successfully removed from the task!", cid)

elseif msg == "no" then  

selfSay("Okay then", cid)  

talkState[talkUser] = 0  

npcHandler:releaseFocus(cid)  

end

return TRUE

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

e o MOD das tasks:

Spoiler

<?xml version="1.0" encoding="UTF-8"?>  

<mod name="Simple Task" version="3.0" author="Vodkart" contact="************.com" enabled="yes">  

<config name="task_func"><![CDATA[


tasktabble = {

["troll"] = {monster_race={"troll","frost troll","furious troll","island troll","swamp troll","troll champion","troll legionnaire"}, storage_start = 200201, storage = 91001,count = 30,exp = 50000,money = 3000},

["globin"] = {monster_race={"goblin","goblin assassin","goblin leader"}, storage_start = 200202, storage = 91002,count = 30,exp = 70000,money = 3000},

["rotworm"] = {monster_race={"rotworm","carrion worm"}, storage_start = 200203, storage = 91003,count = 10,exp = 40000,money = 2500},

["cyclops"] = {monster_race={"cyclops","cyclops smith","cyclops drone"}, storage_start = 200204, storage = 91004,count = 50,exp = 90000,money = 6000},

["minotaur"] = {monster_race={"minotaur","minotaur archer","minotaur mage","minotaur guard"}, storage_start = 200209, storage = 91009,count = 60,exp = 100000,money = 5000},

["dragon"] = {monster_race={"dragon","dragon lord","frost dragon"}, storage_start = 200214, storage = 91014,count= 30, exp = 350000,money = 8000},

["giant spider"] = {monster_race={"giant spider"}, storage_start = 200215, storage = 91016,count = 50, exp = 500000, money = 15000},

["warlock"] = {monster_race={"warlock"}, storage_start = 200216, storage = 91017, count = 30, exp = 33000000, money = 150000},

["demon"] = {monster_race={"demon"}, storage_start = 200217, storage = 91018, count = 66, exp = 66666666, money = 500000},

["hydra"] = {monster_race={"hydra"}, storage_start = 200218, storage = 91019, count = 20, exp = 6000000, money = 100000},

}

 

configbosses_task = {

{race = "cave rat",Playerpos = {x = 189, y = 57, z = 7}, FromPosToPos = {{x = 186, y = 54, z = 7},{x = 193, y = 60, z = 7}},time = 5},

}


function CheckTask(cid)

for k, v in pairs(tasktabble) do

if getPlayerStorageValue(cid,v.storage_start) >= 1 then return true end

end

return false

end

function finisheAllTask(cid)

local config = {

exp = {true,100000},

money = {true,200000},

items ={false,{{2124,2},{2173,1}}},

premium ={true,5}

}

local x = true

for k, v in pairs(tasktabble) do

if tonumber(getPlayerStorageValue(cid,v.storage)) then

x = false

end

end

if x == true then

setPlayerStorageValue(cid, 521456, 0)

local b = getGlobalStorageValue(63005) if b == -1 then b = 1 end

if b < 11 then

setGlobalStorageValue(63005,b+1)

doBroadcastMessage('[Task Mission Complete] '..getCreatureName(cid)..' was the '..b..' to finish the task!.')

doPlayerAddPremiumDays(cid, config.premium[1] == true and config.premium[2] or 0)

doPlayerAddExp(cid, config.exp[1] == true and config.exp[2] or 0)

doPlayerAddMoney(cid, config.money[1] == true and config.money[2] or 0)

if config.items[1] == true then doAddItemsFromList(cid,config.items[2]) end

doItemSetAttribute(doPlayerAddItem(cid, 7369), "name", "trophy "..getCreatureName(cid).." completed all the task.")

end

end

end

function HavePlayerPosition(cid, from, to)

    return isInRange(getPlayerPosition(cid), from, to) and true or false

end

function getRankStorage(cid, value, max, RankName) -- by vodka

local str =""

str = "--[".. (RankName == nil and "RANK STORAGE" or ""..RankName.."") .."]--\n\n"

local query = db.getResult("SELECT `player_id`, `value` FROM `player_storage` WHERE `key` = "..value.." ORDER BY cast(value as INTEGER) DESC;")

if (query:getID() ~= -1) then k = 1 repeat if k > max then break end

str = str .. "\n " .. k .. ". "..getPlayerNameByGUID(query:getDataString("player_id")).." - [" .. query:getDataInt("value") .. "]"

k = k + 1 until not query:next() end return doShowTextDialog(cid, 2529, str)

end

function getItemsInContainerById(container, itemid) -- Function By Kydrai

            local items = {}

            if isContainer(container) and getContainerSize(container) > 0 then

                            for slot=0, (getContainerSize(container)-1) do

                                            local item = getContainerItem(container, slot)

                                            if isContainer(item.uid) then

                                                            local itemsbag = getItemsInContainerById(item.uid, itemid)

                                                            for i=0, #itemsbag do

                                                                            table.insert(items, itemsbag)

                                                            end

                                            else

                                                            if itemid == item.itemid then

                                                                            table.insert(items, item.uid)

                                                            end

                                            end

                            end

            end

            return items

end

function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo

    local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)

    local piles = 0

    if #item > 0 then

            for i,x in pairs(item) do

                    if getThing(x).type < 100 then

                            local it = getThing(x)

                            doTransformItem(it.uid, itemid, it.type+quant)

                            if it.type+quant > 100 then

                                    doPlayerAddItem(cid, itemid, it.type+quant-100)

                            end

                    else

                           piles = piles+1

                    end

            end

    else

            return doPlayerAddItem(cid, itemid, quant)

    end

    if piles == #item then

            doPlayerAddItem(cid, itemid, quant)

    end

end

function getItemsFromList(items) -- by vodka

local str = ''

if table.maxn(items) > 0 then

for i = 1, table.maxn(items) do

str = str .. items[2] .. ' ' .. getItemNameById(items[1])

if i ~= table.maxn(items) then str = str .. ', ' end end end

return str

end

function doAddItemsFromList(cid,items) -- by vodka

if table.maxn(items) > 0 then

for i = 1, table.maxn(items) do

local count = items[2]

while count > 0 do

if isItemStackable(items[1]) then

doPlayerAddItemStacking(cid, items[1], 1)

else

doPlayerAddItem(cid, items[1],1)

end

count = count - 1

end

end

end

end

        function pairsByKeys(t, f)

          local a = {}

          for n in pairs(t) do table.insert(a, n) end

          table.sort(a, f)

          local i = 0

          local iter = function ()

                i = i + 1

                if a == nil then return nil

                else return a, t[a]

                end

          end

          return iter

        end

]]></config>

<event type="login" name="TaskLogin" event="script"><![CDATA[

function onLogin(cid)

registerCreatureEvent(cid, "KillTask")

return true

end]]></event>    

<event type="kill" name="KillTask" event="script"><![CDATA[

domodlib('task_func')

function onKill(cid, target, lastHit)

if(isMonster(target) == true) then

local n = string.lower(getCreatureName(target))

for race, mob in pairs(tasktabble) do

if getPlayerStorageValue(cid,mob .storage_start) >= 1 then

for i = 1,#mob.monster_race do

if n == mob.monster_race then

local contagem = getPlayerStorageValue(cid, mob.storage)

if (contagem == -1) then contagem = 1 end

if not tonumber(contagem) then return true end

if contagem > mob.count then return true end

if contagem > mob.count then return true end

setPlayerStorageValue(cid, mob.storage, contagem+1)

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,""..(contagem == mob.count and "Congratulations! You finished the task of "..race.."." or "defeated. Total [" .. contagem .. "/" .. mob.count .. "] " .. race .. ".").."")

end

end

end

end

end

return true

end]]></event>

</mod>

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

3 respostass a esta questão

Recommended Posts

  • 0
Majesty    1755
Majesty

Você tem o Simple Task System v3.0 e o v4.0, estude os sistemas + Lua e tente adaptar para o que você quer. Você está fazendo o seu servidor via Suporte deste fórum, não é para isso que esta seção serve.

Tópico Fechado.

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
Majesty    1755
Majesty

Simple Task System v4.0 (Task System + Daily Task System):

Spoiler

Removido:

 

*Boss Room

*Rank Task

*Prêmios para os 10 primeiros a terminar todas as tasks

 

Adicionado:

 

*Daily Task System (Sistema exclusivo de Task diario, podendo pegar 1x a cada 24 hrs)

*Task agora é por progresso, você não pode sair e voltar, terá que terminar a task 1 para avançar para a task  2, assim sucessivamente.

*Task Points

*Level para realizar a task

*Nova talkaction que mostra uma janela de informações sobre o level da task, premios que irá receber, progresso, etc...

*Items para entrega(Se o jogador deverá levar algum item junto com a quantidade de monstro morta) para finalizar a task

*Sistema de look Task (Varia de acordo com a sua quantidade de Task Points, podendo ficar por exemplo como "Huntsman", "Ranger", etc...(alterável)

*Mods e npc mais "clean", várias linhas removidas e o sistema está mais rápido

*"Scripts extras" Como:

--> Tile que só passa quem tiver permissão depois de finalizar determinada quest

 --> Npc de Boss Room para entrar e enfrentar o monstro quem fez determinada quest

 

 

[+] Resumo do Task System + Daily Task System [+]

 

Task System: É o sistema de task "original", onde consiste em matar determinada quantidade de monstros(E entregar certo itens <- é configurável), para receber recompensas como Exp, Money e Items.

 

Algumas mudanças do simple task 3.0 para o 4.0 foram:

 

[+] O sistema agora é por progresso, isso quer dizer que você terá que ir terminando a quest para avançar para a seguinte.

[+] O sistema Também recebeu uma alteração, fazendo com que as Tasks precisem que o jogador tenha um level determinado

[+] A tabela para edição está mais fácil, fazendo com que você adicione ou remova monstros com mais tranquilidade, inclusive alterações das Rewards da Task.

 

Daily Task System: É um sistema para que os jogadores sempre estejam se comunicando com o npc de Task, no caso da Task Diaria, varia de acordo com o level do jogador, por exemplo:

 

Jogadores entre level 6 ao 49 poderá cair em uma dessas 3 Task Diarias: Orcs, Tarantulas ou Wyverns

Jogadores entre level 50 ao 79 poderá cair em uma dessas 3 Task Diarias: Dragons, Wailing Widows ou Ancient Scarabs

 

E por ai vai, claro que você poderá aumentar as Task Diarias dependendo do level, eu fiz 3 para cada level que é pra postar, mas tudo isso você pode aumentar! Dependendo do seu servidor.

 

E sim, você pode fazer a TASK "ORIGINAL" e a TASK "DIARIA" ao mesmo tempo! Ambas são distintas e possuem Rewards diferenciadas!

 

No caso da Task diaria, levando em conta que você começou a fazer ela no dia 08/01 ás 20:00 Hrs, você tem até o dia 09/01 ás 20:00Hrs para termina-la e receber a recompensa, caso termine antes, a Task diaria só irá ficar disponível para repetição a partir desta mesma data 09/01 20:00 Hrs;

 

[+] Caso você não termine a tempo, não tem problema, basta esperar este horário e começar uma nova Task.

[+] Caso você começou a Daily Task e terminou antes desta data. mas por algum motivo esqueceu de entregar e a mesma passou do prazo, não tem importância, caso você tenha matado todos os monstros até 09/01 20:00 Hrs, você poderá entregar está Task em qualquer horário para receber suas Rewards e começar uma task a partir do momento em que você entregou!

 

[+] Comandos Adicionais [+]

/task -- Mostra as informações da sua Task Atual, como Nome da Task, Level, Rewards, Monstros que você poderá matar, Se tem que entregar algum Item junto, etc...

/task daily -- É basicamente mostra a mesma informação da Task Principal, porém mostra também qual o prazo limite para entrega da task.

/task counter -- É um comando que ATIVA ou DESATIVA o contador de monstros mortos na task no seu Channel.

 

[+] Imagens [+]

Cline neste link para ver algumas imagens da Task : http://imgur.com/a/eLIY3

------------------------------------------------ // --------------------------------------------------------------

[+] Instalação do Sistema [+]

 

Requisitos: Nível Médio de conhecimento em scripting LUA

Pasta Mods

Simple Task.xml

https://pastebin.com/raw/P5hqMC3j

 

NPC:

Ludger.xml

https://pastebin.com/raw/R56yLWHw

 

simple_task.lua

https://pastebin.com/raw/1mRzJ6aJ

---------------------------------------------- // ----------------------------------

[+] configuração [+ ]

 

Task System Principal

 


task_sys = {
	[1] = {name = "Trolls", start = 176201, monsters_list = {"Troll","Troll champion"}, level = 8, count = 40, points = 0, items = {}, reward = {}, exp = 2000, money = 2000}
}

 

[1]  --> O número entre os colchetes [] significa a ordem da Task, como a Task é por progresso sempre começará no 1 e irá pro [2], assim sucessivamente.

name --> É o nome da task que o jogador irá fazer.

start --> é a storage que indicará se o jogador começou a Task

monster_list ={} --> É o nome dos monstros em que o jogador deverá caçar para completar a Task

level --> É o level necessário para dar inicio á Task

count --> É o número de monstros que o jogador tem que matar para completar a Task

points --> Aqui determinada quantos Task points o jogador irá receber ao completar a Task

items = {} --> Aqui determinada se além de matar os monstros, o jogador terá que entregar item também! Caso tenha só colocar o {ITEM_ID, QUANTIDADE} EX:


items = {{2173,1}{2160,10},{2493,2}}

rewad --> Aqui determinada se o jogador irá receber itens ao terminar a Task, mesma formula do items /\


reward = {{2520,1},{2173,1}}

exp --> Se o jogador irá receber Exp ao terminar a task. 0 ou quantidade de exp

Money --> Se o jogador irá receber dinheiro ao terminar a task. 0 ou quantidade de dinheiro

 

 

Daily Task System

 


daily_task = {
	[1] = {name = "Orcs" ,monsters_list = {"Orc Berserker","Orc Rider","Orc Leader","Orc Warlord"}, count = 100, points = 0, reward = {}, exp = 5000, money = 10000}
}

 

Segue o padrão da Task original, exceto que não precisa entregar items para o npc!

 

Como funciona A randomização de level de acordo com a Daily task?

 

Procure por esta tabela em MODS

 


	local t = {
		[{6,49}] = {1,3},
		[{50,79}] = {4,6},
		[{80,129}] = {7,9},
		[{130,math.huge}] = {10,12}
	}

 

entre as chaves e colchetes é o level do jogador para as Daily Task, Você pode adicionar quantas você quiser!

 

Digamos que:

 

[{6,49}] = {1,3}  --> Quer dizer que entre o level 6 ao 49 o jogador poderá cair na Daily Task número 1(Orcs), 2(Tarantulas) ou 3(Wyvern)!

[{50,79}] = {4,6} --> Quer dizer que entre o level 50 ao 79 o jogador poderá cair na Daily Task número 4(Dragons), 5(Wailing Widows) ou 6(Ancient Scarabs)!

...

[{130,math.huge}] = {10,12} --> Quer dizer que o jogador level 130 ou MAIS poderá cair na Daily Task número 10(Undead Dragons), 11(HydraS) ou 12(Ghastly Dragons)!

 

 

Look Rank System

Procure por está tabela em MODS

 


	local ranks = {
		[{1, 20}] = "Huntsman", 
		[{21, 50}] = "Ranger",
		[{51, 100}] = "Big Game Hunter",
		[{101, 200}] = "Trophy Hunter",		
		[{201, math.huge}] = "Elite Hunter"
	}

 

Entre 1-20 Task points o Rank será Huntsman

Entre 21-50 Task posints o Rank será Ranger

Entre 51-100 Task Points o rank será Big Game Hunter

etc...

Altere como quiser!

Altere no arquivo mods/simpletask.xml, de:

if isPlayer(cid) and isMonster(target) and not isSummon(target) then

Para:

if isPlayer(cid) and isMonster(target) then

Créditos: Vodkart.

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
Luan MF    7
Luan MF

Testei aqui e o sistema esta funcionando bem, mas o npc não me da a opção de escolher qual task eu quero fazer, ele faz eu passar por todas as tasks da mais facil para a mais dificil, e depois que termina não pode repetir. as daily tao funcionando normal

Compartilhar este post


Link para o post
Compartilhar em outros sites
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×