Postado Fevereiro 14, 2015 10 anos Autor <?xml version="1.0" encoding="UTF-8"?> <npc name="Lucca" script="data/npc/scripts/tasks/taskbase.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="131" head="59" body="95" legs="94" feet="113" addons="0"/> <parameters> <parameter key="message_greet" value="Hello |PLAYERNAME|! I npc {task}!"/> <parameter key="message_farewell" value="Good bye."/> <parameter key="message_walkaway" value="Farewell then.." /> </parameters> </npc>
Postado Fevereiro 15, 2015 10 anos Pronto, já testei e está funcional. Incrementei o diálogo do NPC também e arrumei o inglês, tive que usar uma tabela para as frases para não precisar toda hora de if e elseif para a linguagem do NPC. Boa sorte. 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 local storages = { 200201, -- Controla o estado da task [Disponibilidade/Em Curso/Terminada] 91001, -- Controla o número de monstros mortos 8971, -- Controla a linguagem do NPC } local sentences = { [1] = { [1] = "Great! A new soul arrived from the {portal}! Welcome, I hope you can help me.", [2] = "Ótimo! Uma nova alma chegou do {portal}! Seja bem-vindo, espero que você possa me ajudar.", }, [2] = { [1] = "A crystal angel came down here, in Aurea, and opened a portal where humans arrive from another dimension to {save} us.", [2] = "Um anjo de cristal desceu aqui, em Aurea, e abriu um portal onde humanos chegam de outra dimensão para nos {salvar}.", }, [3] = { [1] = "We live in a apocalyptic world, in a war of several races... and you can be the {chosen} one!", [2] = "Nós vivemos em um mundo apocalíptico, em uma guerra de várias raças... e você pode ser o {escolhido}!", }, [4] = { [1] = { "Calm down! First we need to train you... you need to help us with simple tasks, until you are strong enough...", "For example, we are facing a {rat} plague, they are coming out of sewers!", }, [2] = { "Acalme-se! Primeiro, precisamos treinar você... você precisa nos ajudar com tarefas simples, até que esteja forte o bastante...", "Como por exemplo, estamos enfrentando uma praga de {ratos}, eles estão saindo dos bueiros!", }, }, [5] = { [1] = "I am glad you can help us, please kill 10 rats, they are in the sewer in front of the store.", [2] = "Estou grato que você pode nos ajudar, por favor mate 10 ratos, eles estão no bueiro na frente da loja.", }, [6] = { [1] = "You already killed 10 rats?", [2] = "Você já matou 10 ratos?", }, [7] = { [1] = { "You have completed the task! Keep this Saber and train until you get Level 8, then talk to the Oracle in the temple.", "He will send you to Aurea, there talk to", }, [2] = { "Você completou a tarefa! Fique com este Sabre e treine até atingir o Level 8, então fale com o Oráculo no templo.", "Ele irá te mandar para Aurea, lá fale com", }, }, [8] = { [1] = "I can hear the rats' noise from here... I think you didn't killed 10 rats...", [2] = "Posso ouvir o barulho dos ratos daqui... Acho que você não matou 10 ratos...", }, [9] = { [1] = "You already completed the task!", [2] = "Você já completou a tarefa!", }, } function _onCreatureSay(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local language = math.max(getCreatureStorage(cid, storages[3]), 1) -- Por padrão, a linguagem será Inglês (?) if msgcontains(msg:lower(), "task") then if getCreatureStorage(cid, storages[1]) == -1 then -- Task disponível selfSay(sentences[1][language], cid) talkState[talkUser] = 1 elseif getCreatureStorage(cid, storages[1]) == 1 then -- Task em curso selfSay(sentences[6][language], cid) talkState[talkUser] = 5 elseif getCreatureStorage(cid, storages[1]) == 2 then selfSay(sentences[9][language], cid) npcHandler:releaseFocus(cid) end end if talkState[talkUser] == 1 then if msgcontains(msg, "portal") then selfSay(sentences[2][language], cid) talkState[talkUser] = 2 end elseif talkState[talkUser] == 2 then if msgcontains(msg, "save") or msgcontains(msg, "salvar") then selfSay(sentences[3][language], cid) talkState[talkUser] = 3 end elseif talkState[talkUser] == 3 then if msgcontains(msg, "chosen") or msgcontains(msg, "escolhido") then selfSay(sentences[4][language][1], cid) selfSay(sentences[4][language][2], cid) talkState[talkUser] = 4 end elseif talkState[talkUser] == 4 then if msgcontains(msg, "rat") or msgcontains(msg, "ratos") then selfSay(sentences[5][language], cid) doCreatureSetStorage(cid, storages[1], 1) -- Task em curso npcHandler:releaseFocus(cid) end elseif talkState[talkUser] == 5 then if msgcontains(msg, "yes") or msgcontains(msg, "sim") then if getCreatureStorage(cid, storages[2]) >= 10 then -- Checar número de ratos mortos doCreatureSetStorage(cid, storages[1], 2) -- Task finalizada doPlayerAddItem(cid, 2385, 1) selfSay(sentences[7][language][1], cid) selfSay(sentences[7][language][2], cid) else selfSay(sentences[8][language], cid) end end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, _onCreatureSay) npcHandler:addModule(FocusModule:new()) Editado Fevereiro 15, 2015 10 anos por Garou (veja o histórico de edições)
Postado Fevereiro 15, 2015 10 anos Autor Valeu mano vou te encher de reps seu lindo --- vou reputar todos aqui, acabou meu limite ;( Editado Fevereiro 15, 2015 10 anos por oliverarrow (veja o histórico de edições)
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.