Ir para conteúdo

Posts Recomendados

Fala ae galera do xTibia.

Tudo blz?

Bom o meu pedido hoje é uma adição a um comando que já possuo em meu servidor.

Ele funciona da seguinte forma.

!task npcs (Ele me mostrará qual os npcs que tenho quests pendentes)

!task [nome do npc] (Ele me mostra o nome, objetivo, local e recompensa da quest)

Porém, ele só me mostra as quests que são de kill.

E eu as configuro da seguinte forma.

Primeiramente, script do npc.

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 task = {
["Junior"] = {{"Pidgey", 20}, {"Rattata", 15}},
}

if msgcontains(msg, 'quest') or msgcontains(msg, 'Quest') then
if isMyTaskComplete(cid, getNpcCid()) then
selfSay("Voce e um bravo treinador! Agora esta pronto para seguir sua jornada, use esta berry quando seu pokemon inicial alcancar o level 15!", cid)
doPlayerAddItem(cid, 11448, 1) --premio
local sto = getMyTaskSto(cid, getNpcCid())
setPlayerStorageValue(cid, sto, -1)
talkState[talkUser] = 0
return true
else
selfSay("Hehe e oque vejo e verdade, seu pokemon esta realmente sem coragem para evoluir, eu tenho uma berry que aumenta a coragem dele. Mas voce precisa me provar que a merece. Derrote {20 Pidgeys e 15 Rattatas}, voce aceita este desafio?", cid)
talkState[talkUser] = 2
end
elseif (msgcontains(msg, 'sim') or msgcontains(msg, 'Sim')) and talkState[talkUser] == 2 then
if getMyTaskSto(cid, getNpcCid()) ~= -1 then
selfSay("Voce ja esta fazendo o meu desafio! va termina-lo!", cid)
talkState[talkUser] = 0
return true
end
local sto = getFreeTaskStorage(cid)
if sto == -1 then
selfSay("Voce nao pode pegar mais quests! sua lista de tarefas esta lotada com "..(maxTasks).." quests!", cid)
talkState[talkUser] = 0
return true
end

selfSay("Okay entao... Va e faca o seu melhor!", cid)
setStorageArray(cid, sto, task)
talkState[talkUser] = 0
return true
end

return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

E depois vou na seguinte linha no meu arquivo configuration.lua na pasta lib, e adiciono as informações que aparecerão no comando !task [nome do npc]

Que é assim:

----------------------- TASK SYSTEM ------------------------
maxTasks = 30 --numero maximo de tasks q um player pode ter simultaniamente... aconcelho 30~40maximo!
---
npcsTask = { --["npc name"] = {"city do npc", "task", "reward"},
["Junior"] = {"Pallet Town", "Treinador de coragem", "Courage Berry"},
---

 

Daí então fica tudo certinho e aparece tudo de boas no game.

Contudo, meu servidor possui muito rpg, sendo assim, muitas quests.

E as quests de drop(loot) não aparecem neste sistema, e seria muito bacana aparecer também pra facilitar a vida dos players.

Aqui está o script do npc que da uma quest de drop.

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 stg = 17760 -- storage para falar com o npc
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

if msgcontains(msg, 'quest') then
if getPlayerStorageValue(cid, stg) >= 12191 then
selfSay("Desculpe, mas voce ja fez a minha quest!!", cid)
talkState[talkUser] = 0
else
selfSay("Eu estava procurando Pokemon's insetos, mas a minha isca acabou... Voce pode trazer 30 Folhas I para mim?", cid)
talkState[talkUser] = 1
end
end
---------------------------------------------------------
if (msgcontains(msg, "yes") or msgcontains(msg, "sim")) and talkState[talkUser] == 1 then
if doPlayerRemoveItem(cid, 26596, 30) == TRUE then
selfSay("Obrigado. Hey voce pode ser um otimo Bug Catcher, procure meus irmaos!", cid)
setPlayerStorageValue(cid, stg, 12191) -- para ele nao fazer a missao novamente
doPlayerAddExperience(cid,15000) -- experiencia
local bags = getPlayerSlotItem(cid, 3)
doAddContainerItem(bags.uid, 26479, 1) -- Caterpie egg
doAddContainerItem(bags.uid, 26480, 1) -- Weedle egg
else
selfSay("Seja rapido, me traga logo essas folhas !.", cid)
talkState[talkUser] = 0
end
elseif (msgcontains(msg, "no") or msgcontains(msg, "nao")) and talkState[talkUser] == 1 then
selfSay("Entao saia daqui", cid)
talkState[talkUser] = 0
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

E aqui o script do comando !task

function onSay(cid, words, param)

if param == '' then
sendMsgToPlayer(cid, 20, "Param required.\n!task [name npc] ou !task npcs")
return true
end

if param == "npcs" or param == "Npcs" then
local str = "Name of npcs of task: \n\n"
local send = false
for i = 91001, (91000+maxTasks) do
if getPlayerStorageValue(cid, i) ~= -1 and tostring(getPlayerStorageValue(cid, i)) then
local array = getArrayFromStorage(cid, i)
if arrayHasContent(array) then
for e, f in pairs(array) do
local j = e
if string.find(e, "Trainer") then
if getPlayerStorageValue(cid, 854789) == 5 then
j = j.."_1"
elseif getPlayerStorageValue(cid, 854789) == 7 then
j = j.."_2"
end
end
if npcsTask[j] then
str = str..e.."\n"
send = true
end
end
end
end
end
if send then
doShowTextDialog(cid, 2395, str)
else
doShowTextDialog(cid, 2395, "Voce nao tem nenhuma quest!")
end
return true
end

local npc = doCorrectString(tostring(param))
local npc2 = npc
local sto = getMyTaskSto(cid, npc)
local str = "Name: "..npc..".\n"

if npcsTask[npc.."_1"] then
if getPlayerStorageValue(cid, 854789) == 5 then
npc2 = npc2.."_1"
elseif getPlayerStorageValue(cid, 854789) == 7 then
npc2 = npc2.."_2"
end
end

if sto == -1 or not npcsTask[npc2] then
doShowTextDialog(cid, 2395, "Voce nao tem quest deste npc!")
return true
end

if isMyTaskComplete(cid, npc) then
str = str.."Task: "..npcsTask[npc2][2]..".\n"
str = str.."Status: Completa.\n"
str = str.."Local: "..npcsTask[npc2][1]..".\n"
str = str.."Recompenca: "..npcsTask[npc2][3].."."
else
str = str.."Task: "..npcsTask[npc2][2]..".\n"
str = str.."Status: Pendente.\n"
str = str.."Derrote: "..getStingOfTask(cid, npc)
str = str.."Local: "..npcsTask[npc2][1]..".\n"
str = str.."Recompenca: "..npcsTask[npc2][3].."."
end
doShowTextDialog(cid, 2395, str)
return true
end

 

E aqui o Task que fica em creaturescript

function onKill(cid, target)

local continue = true

if ehMonstro(target) then
for i = 91001, (91000+maxTasks) do
local sto = getPlayerStorageValue(cid, i)
if type(sto) == "string" then
local array = getArrayFromStorage(cid, i)
if arrayHasContent(array) then
for e, f in pairs(array) do
for a = 1, #f do
if tostring(f[a][1]) == getCreatureName(target) and tonumber(f[a][2]) >= 1 then
if getDamageMapPercent(cid, target) < 0.5 then
continue = false
elseif (pokes[getPlayerStorageValue(cid, 854787)] and getCreatureName(getCreatureSummons(cid)[1]) ~= getPlayerStorageValue(cid, 854787)) then
if npcsTask[tostring(e).."_1"] then
continue = false --task clan
end
end
if continue then
f[a][2] = f[a][2]-1
if f[a][2] == 0 then
sendMsgToPlayer(cid, 20, tostring(e)..": Quest Done!")
else
sendMsgToPlayer(cid, 20, tostring(e)..": You need to kill more "..f[a][2].." "..f[a][1]..(f[a][2] == 1 and "." or "s."))
end
setStorageArray(cid, i, array)
end
continue = true
end
end
end
end
end
end
end

return true
end

 

Abaixo vou deixar uma imagem pra mostrar como o sistema funciona com o kill.

E como eu queria que funcionasse com os drops( A imagem de drop é monstagem)

Meu servidor é PDA 8.54, se precisar de mais infos é só me solicitar, obrigado desde já Rep+


up

post-382083-0-35086000-1431609175.png

post-382083-0-84917100-1431609175.png

Editado por Elias Palermo
Link para o comentário
https://xtibia.com/forum/topic/233900-pedido-adicionar-quest-de-drop-no-comando-task/
Compartilhar em outros sites

  • 1 month later...
Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...