- Começando pelo NPC de Task de item
Vai em Data/NPC e crie o arquivo Breno.xml e adicione o código dentro:
<?xml version="1.0" encoding="UTF-8"?> <npc name="Breno" script="Breno.lua" walkinterval="0" floorchange="0" access="5" level="1" maglevel="1"> <health now="150" max="150"/> <look type="1421" head="114" body="119" legs="114" feet="114" corpse="2212"/> <parameters> <parameter key="message_greet" value="Olá |PLAYERNAME|, em que posso ajudar? Diga {help}, {ajuda} ou {task} para mais informações."/> </parameters> </npc>
Agora em Data/NPC/Scripts crie o arquivo Breno.lua (com codificação ANSI) e adicione o código dentro:
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 -- VARIÁVEIS -- local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid msg = string.lower(msg) local storage = 150000 local storage_start = 150001 local id_item = 12163 -- ID DO ITEM QUE O NPC PEDE local quantidade_item = 100 -- QUANTIDADE DE ITENS QUE O NPC PEDE local id_item_recebido = 16563 -- ID DO ITEM QUE RECEBE AO COMPLETAR A TASK local quantidade_item_recebido = 1 -- QUANTIDADE DE ITENS QUE RECEBE AO COMPLETAR A TASK ----------------------------------- [ DIALOGO COM NPC] --------------------------------- if msgcontains(msg, 'help') or msgcontains(msg, 'ajuda') or msgcontains(msg, 'task') then if getPlayerStorageValue(cid, storage) == 1 then selfSay("Você já completou minha task.", cid) talkState[talkUser] = 0 return true else selfSay("Preciso que você me traga " ..quantidade_item.. " " ..getItemNameById(id_item).. " Você trouxe?", cid) talkState[talkUser] = 1 return true end elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) and talkState[talkUser] == 1 then if getPlayerStorageValue(cid, storage_start) < 1 then setPlayerStorageValue(cid, storage_start, 1) return true end if getPlayerItemCount(cid, id_item) >= quantidade_item then doPlayerRemoveItem(cid, id_item, quantidade_item) selfSay("Parabéns! Você trouxe " ..quantidade_item.. " " ..getItemNameById(id_item).. " que eu precisava. Receba sua recompensa.", cid) doPlayerAddItem(cid, id_item_recebido, quantidade_item_recebido) doSendMagicEffect(getPlayerPosition(cid), 29) setPlayerStorageValue(cid, storage, 1) talkState[talkUser] = 0 return true else selfSay("Você ainda não trouxe " ..quantidade_item.. " " ..getItemNameById(id_item).. " que eu preciso.", cid) talkState[talkUser] = 0 return true end return true elseif (msgcontains(msg, 'no') or msgcontains(msg, 'não')) and talkState[talkUser] == 1 then if getPlayerStorageValue(cid, storage_start) < 1 then selfSay("Ok, fale comigo novamente caso queira fazer minha task.") talkState[talkUser] = 0 return true else selfSay("Então vá buscar os itens que eu pedi.") talkState[talkUser] = 0 return true end return true end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
- Agora é o NPC da Task que derrota Pokémon
Vá em Data/NPC e crie o arquivo Brime.xml e adicione o código dentro:
<?xml version="1.0" encoding="UTF-8"?> <npc name="Brime" script="Brime.lua" walkinterval="0" floorchange="0" access="5" level="1" maglevel="1"> <health now="150" max="150"/> <look type="1421" head="114" body="119" legs="114" feet="114" corpse="2212"/> <parameters> <parameter key="message_greet" value="Olá |PLAYERNAME|, eu recompenso jogadores que aceitam meus desafios. Diga {help}, {ajuda} ou {task} para mais informações."/> </parameters> </npc>
Agora em Data/NPC/Scripts crie o arquivo Brime.lua (com codificação ANSI) e adicione o código dentro:
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 -- VARIÁVEIS -- local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid msg = string.lower(msg) local nome_poke_task = "Scyther" local quantidade_pokemon = 50 local storage_npc = 120000 local storage_task = 110000 local storage_start = 121000 -- RECOMPENSAS -- local id_item = 12545 local quantidade_item = 1 local exp = 500000 ----------------------------------- [ DIALOGO COM NPC] --------------------------------- if msgcontains(msg, 'help') or msgcontains(msg, 'ajuda') or msgcontains(msg, 'task') then if getPlayerStorageValue(cid, storage_task) == 1 then -- VERIFICA SE TERMINOU A TASK selfSay("Você já completou minha missão.", cid) talkState[talkUser] = 0 return true else selfSay("Preciso que você derrote alguns {"..nome_poke_task.."} para mim. Você aceita este desafio?", cid) talkState[talkUser] = 1 return true end elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'sim') or (msgcontains(msg, 'ok'))) and talkState[talkUser] == 1 then if getPlayerStorageValue(cid, storage_start) < 1 then setPlayerStorageValue(cid, storage_start, 1) return true end if getPlayerStorageValue(cid, storage_npc) == 1 then selfSay("Parabéns! Você completou minha tarefa. Receba sua recompensa.", cid) doPlayerAddExp(cid, exp) doPlayerAddItem(cid, id_item, quantidade_item) doSendAnimatedText(getThingPos(cid), exp, 27) doSendMagicEffect(getPlayerPosition(cid), 29) setPlayerStorageValue(cid, storage_task, 1) talkState[talkUser] = 0 return true else if getPlayerStorageValue(cid, storage_npc) < 0 then selfSay("Vá derrotar todos os " ..quantidade_pokemon.. " " ..nome_poke_task.. " para mim.") setPlayerStorageValue(cid, storage_npc, 0) talkState[talkUser] = 0 return true elseif getPlayerStorageValue(cid, storage_npc) == 0 then selfSay("Você ainda não derrotou todos os " ..quantidade_pokemon.. " " ..nome_poke_task.. ". Vá derrotar os " ..nome_poke_task.. " restante antes de falar comigo.") talkState[talkUser] = 0 return true end return true end return true elseif (msgcontains(msg, 'no') or msgcontains(msg, 'não')) and talkState[talkUser] == 1 then if getPlayerStorageValue(cid, storage_start) < 1 then selfSay("Ok, fale comigo novamente caso queira fazer minha task.", cid) talkState[talkUser] = 0 return true else selfSay("Então vá completar sua tarefa.") talkState[talkUser] = 0 return true end return true end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Agora em Data/Creaturescripts/scripts crie o arquivo task_npc.lua (com a codificação ANSI do arquivo pelo fato de ter acentuação no português) e adicione o código dentro:
local storage_npc = 120000 local storage_contador = 120001 local pokemon = { [1] = {name = "Scyther", count = 50}, } local restante local nome = pokemon[1].name function onKill(cid, target) for _, t in ipairs(pokemon) do local quantidade = t.count if getCreatureName(target) == nome then if getPlayerStorageValue(cid, storage_npc) == 0 then if getPlayerStorageValue(cid, storage_contador) == quantidade then doPlayerSendTextMessage(cid, 27, "Não há mais " ..nome.. " para derrotar.") setPlayerStorageValue(cid, storage_contador, getPlayerStorageValue(cid, storage_contador) + 1) setPlayerStorageValue(cid, storage_npc, 1) return true elseif getPlayerStorageValue(cid, storage_contador) < quantidade then -- AS STORAGES COMEÇAM COM -1, ENTÃO NESSA PARTE EU APENAS DEFINO COMO 0 PARA NA LINHA SEGUINTE JÁ IR PARA 1. NÃO COLOQUE RETURN NESSE LAÇO PORQUE VAI ENCERRAR O ESCOPO E NÃO VAI CONTAR CORRETAMENTE -- if getPlayerStorageValue(cid, storage_contador) < 0 then setPlayerStorageValue(cid, storage_contador, 0) end setPlayerStorageValue(cid, storage_contador, getPlayerStorageValue(cid, storage_contador) + 1) restante = quantidade - getPlayerStorageValue(cid, storage_contador) doPlayerSendTextMessage(cid, 27, "Faltam " ..restante.. " " ..nome.. " para derrotar.") return true end elseif (getPlayerStorageValue(cid, storage_npc) < 0) or (getPlayerStorageValue(cid, storage_npc) > 0) then return true end return true end return true end end
Agora em Data/Creaturescripts abra o creaturescripts.xml e adiciona a tag:
<event type="kill" name="task_npc" script="task_npc.lua"/>
E por último em Data/Creaturescripts/Scripts abra o Login.lua e adicione a tag na parte de eventos:
registerCreatureEvent(cid, "task_npc")




info
Grupo: Artesão
Registrado: 22/07/11
Posts: 101
Reputação: +3
Gênero: Masculino
Char no Tibia: Clode
Alguem tem a script de npc de task??
1 - de item
2 - de matar x pokemon
Um script basica simples pra PDA!!
um npc de task de pegar item(loot) e outro de matar X pokemon.
quem puder posta aqui a script ^^