Ir para conteúdo

Líderes

Conteúdo Popular

Exibindo conteúdo com a maior reputação em 09/02/20 em todas áreas

  1. Luga03

    Task System 2016

    Olá! Eu estava ajudando um cara com um task system , ele disse que pegou na net, mas as alterações que ele queria eu tive que refazer algumas partes do sistemas! Testei e funcionou perfeitamente! Funciona com Poketibia e Tibia! Vamos deixar de enrolação e adicionar o sistema! Lembrando também que funciona com tfs 0.3.6 e tfs 0.4! Não testei com tfs 1.x mas acho que não funciona. Vá em creaturescripts.xml e adicione isso: <event type="kill" name="KillTask" event="script" value="task.lua"/> No login.lua adiciona isso com os demais: registerCreatureEvent(cid, "KillTask") Agora crie um arquivo chamado task.lua e adicione isso: local tasksss = { [1] = {name = "Blastoise", sto = 10212, count = 3, time_sto = 5457, time = 1*24*60*60, sto_count = 14129, money = 100, rewardid = 7621, rewardcount = 100, rewardexp = 10000, text = "Congratulations! You finished this task. In 24h, you will be able to do it again."}, [2] = {name = "Charizard", sto = 10213, count = 5, time_sto = 5458, time = 1*24*60*60, sto_count = 14130, money = 100, rewardid = 7621, rewardcount = 100, rewardexp = 10000, text = "Congratulations! You finished this task. In 24h, you will be able to do it again."},}function onKill(cid, target) for _, t in ipairs(tasksss) do local total_count = t.count local m_sto = t.sto local count_sto = t.sto_count if getPlayerStorageValue(cid, m_sto) ~= -1 then if getCreatureName(target) == t.name then if (total_count - getPlayerStorageValue(cid, count_sto)) == 1 then setPlayerStorageValue(cid, count_sto, getPlayerStorageValue(cid, count_sto) + 1) doPlayerSendTextMessage(cid, 20, "You are killed ".. getPlayerStorageValue(cid, count_sto) .." " .. t.name .. " and finished the task!") return true elseif (total_count - getPlayerStorageValue(cid, count_sto)) >= 1 then setPlayerStorageValue(cid, count_sto, getPlayerStorageValue(cid, count_sto) + 1) doPlayerSendTextMessage(cid, 20, "You are killed ".. getPlayerStorageValue(cid, count_sto) .." of ".. total_count .." " .. t.name .. " kills to finish the task.") return true end end end end return trueend Agora vá em npc/scripts e crie um arquivo chamado task.lua e adicione isso: local tasksss = { [1] = {name = "Blastoise", sto = 10212, count = 3, time_sto = 5457, time = 1*24*60*60, sto_count = 14129, money = 100, rewardid = 7621, rewardcount = 100, rewardexp = 10000, text = "Congratulations! You finished this task. In 24h, you will be able to do it again."}, [2] = {name = "Charizard", sto = 10213, count = 5, time_sto = 5458, time = 1*24*60*60, sto_count = 14130, money = 100, rewardid = 7621, rewardcount = 100, rewardexp = 10000, text = "Congratulations! You finished this task. In 24h, you will be able to do it again."},}local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)local talkState = {}function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) endfunction onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) endfunction onThink() npcHandler:onThink() endfunction creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid value = -1 for i = 1, #tasksss do if msgcontains(msg, tasksss[i].name) and not value ~= -1 then value = i end end if value == -1 then selfSay('I don\'t have a this task!', cid) talkState[talkUser] = 0 return true end local configss = tasksss[value] local name = configss.name local m_sto = configss.sto local time_sto = configss.time_sto local count_sto = configss.sto_count local total_count = configss.count local rest = total_count - getPlayerStorageValue(cid, count_sto) if getPlayerStorageValue(cid, time_sto) < os.time() then -- verifica se o player ainda está no prazo if getPlayerStorageValue(cid, m_sto) <= 0 then -- verifica se o player não pegou está task selfSay('Ready! Now you need kill a '.. total_count .. ' '.. name .. '!', cid) setPlayerStorageValue(cid, m_sto, 1) setPlayerStorageValue(cid, total_count, 0) talkState[talkUser] = 0 else if rest <= 0 then -- Verifica se o player matou todos os monstros nescessários doPlayerAddItem(cid, configss.rewardid, configss.rewardcount) setPlayerStorageValue(cid, count_sto, 0) setPlayerStorageValue(cid, m_sto, -1) setPlayerStorageValue(cid, time_sto, os.time() + configss.time) doPlayerAddExperience(cid, configss.rewardexp) doSendAnimatedText(getCreaturePosition(cid), configss.rewardexp, 215) selfSay(configss.text, cid) talkState[talkUser] = 0 else selfSay('You need to kill '..rest..' '..name..' to gain a reward.', cid) talkState[talkUser] = 0 end end else selfSay('You already did this task, player. Wait '..math.ceil((getPlayerStorageValue(cid, time_sto) - os.time())/(60*60))..' hours to do it again.', cid) talkState[talkUser] = 0 endendnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:addModule(FocusModule:new()) Pronto, agora volte para a pasta npc e crie um novo arquivo .xml chamado de Task e adicione isso lá: <?xml version="1.0" encoding="UTF-8"?><npc name="Npc Nome" script="task.lua" walkinterval="350000" floorchange="0" speed="0"> <health now="150" max="150"/> <look type="369" head="91" body="102" legs="83" feet="0"/> <parameters> <parameter key="message_greet" value="You want gain a task of {Blastoise}?"/> </parameters></npc> Pronto, agora o sistema de task está funcionando, e para adicionar um novo monstro pra fazer a task? Basta editar a tabela, mas não esqueça que tem que atualizar a tabela nos 2 scripts .lua !! local tasksss = { [1] = {name = "Blastoise", sto = 10212, count = 3, time_sto = 5457, time = 1*24*60*60, sto_count = 14129, money = 100, rewardid = 7621, rewardcount = 100, rewardexp = 10000, text = "Congratulations! You finished this task. In 24h, you will be able to do it again."}, [2] = {name = "Charizard", sto = 10213, count = 5, time_sto = 5458, time = 1*24*60*60, sto_count = 14130, money = 100, rewardid = 7621, rewardcount = 100, rewardexp = 10000, text = "Congratulations! You finished this task. In 24h, you will be able to do it again."},} Para configurar siga as seguintes instruções: Modificações da versão 2.0: Corrigido bug de apenas o primeiro monstro configurado funcionava, agora todos configurados funcionam! Quando player fala qual quer coisa que não seja o nome do monstro, diz que não tem aquela task! Modificado modo de contagem de kill, agora monstra quantos você matou e o total que precisa matar, quando mata o ultimo monstro, aparece a mensagem que terminou a task! Créditos: Criador @miguel223 Drazyn1291 -- Editei e reformulei muita coisa! Adicionei coisas como a contagem que falta ao matar os monstros, editei pra fazer a task apenas se o player falar com o NPC e outras coisas!
    1 ponto
Líderes está configurado para São Paulo/GMT-03:00
×
×
  • Criar Novo...