The Forgotten Server, version 0.3.6 (Crying Damson)
Qual o motivo deste tópico?
NPC QUEST nenhum npc task funciona na minha base o npc fala faz tudo mais o task mata pokemon nao funciona testei varias task diferente maiss nenhum deles funciona
E vá em Data/NPC/Scripts e crie um arquivo Peter.lua 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_segundo_npc = "Joey"
----------------------------------- [ DIALOGO COM NPC] ---------------------------------
if msgcontains(msg, 'help') or msgcontains(msg, 'ajuda') or msgcontains(msg, 'missao') then
if getPlayerStorageValue(cid, 10000) == 1 then -- VERIFICA SE FALOU COM SEGUNDO NPC
if getPlayerStorageValue(cid, 10001) == 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 {Charmanders} para mim. Você quer fazer essa missão?", cid)
talkState[talkUser] = 1
return true
end
else
selfSay("Você deve falar com o NPC " ..nome_segundo_npc.. " para conseguir fazer minha missão.", cid)
talkState[talkUser] = 0
return true
end
elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'sim') or (msgcontains(msg, 'task'))) and talkState[talkUser] == 1 then
local id_item = 12545
local quantidade_item = 1
local exp = 10000
if getPlayerStorageValue(cid, 10002) == 1 then
selfSay("Você completou minha missão! Receba sua recompensa.", cid)
doPlayerAddExp(cid, exp)
doPlayerAddItem(cid, id_item, quantidade_item)
doSendAnimatedText(getThingPos(cid), exp, 27)
setPlayerStorageValue(cid, 72451, 1)
talkState[talkUser] = 0
return true
else
if getPlayerStorageValue(cid, 10002) < 0 then
selfSay("Vá derrotar todos os {Charmanders} para mim.")
setPlayerStorageValue(cid, 35000, 0)
talkState[talkUser] = 0
return true
elseif getPlayerStorageValue(cid, 10002) == 0 then
selfSay("Você ainda não derrotou todos os {100 Charmanders}. Termine a missão primeiro 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
selfSay("Ok, fale comigo novamente caso queira fazer minha missão.", cid)
talkState[talkUser] = 0
return true
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Vá em Data/Creaturescripts/Scripts crie um arquivo chamado task_peter.lua e adicione o código dentro:
local nome_terceiro_npc = "Peter"
local storage_npc = 10002
local storage_contador = 10003
local pokemon = {
[1] = {name = "Charmander", count = 100},
}
local nome = pokemon[1].name
local restante
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.")
doPlayerSendTextMessage(cid, 20, "Parabéns! Você concluiu a task do " ..nome_terceiro_npc)
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.. "s 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
Pergunta
kamus9629 8
Creditos : @Yan18
Qual servidor ou website você utiliza como base?
The Forgotten Server, version 0.3.6 (Crying Damson)
Qual o motivo deste tópico?
NPC QUEST nenhum npc task funciona na minha base o npc fala faz tudo mais o task mata pokemon nao funciona testei varias task diferente maiss nenhum deles funciona
E vá em Data/NPC/Scripts e crie um arquivo Peter.lua 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_segundo_npc = "Joey" ----------------------------------- [ DIALOGO COM NPC] --------------------------------- if msgcontains(msg, 'help') or msgcontains(msg, 'ajuda') or msgcontains(msg, 'missao') then if getPlayerStorageValue(cid, 10000) == 1 then -- VERIFICA SE FALOU COM SEGUNDO NPC if getPlayerStorageValue(cid, 10001) == 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 {Charmanders} para mim. Você quer fazer essa missão?", cid) talkState[talkUser] = 1 return true end else selfSay("Você deve falar com o NPC " ..nome_segundo_npc.. " para conseguir fazer minha missão.", cid) talkState[talkUser] = 0 return true end elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'sim') or (msgcontains(msg, 'task'))) and talkState[talkUser] == 1 then local id_item = 12545 local quantidade_item = 1 local exp = 10000 if getPlayerStorageValue(cid, 10002) == 1 then selfSay("Você completou minha missão! Receba sua recompensa.", cid) doPlayerAddExp(cid, exp) doPlayerAddItem(cid, id_item, quantidade_item) doSendAnimatedText(getThingPos(cid), exp, 27) setPlayerStorageValue(cid, 72451, 1) talkState[talkUser] = 0 return true else if getPlayerStorageValue(cid, 10002) < 0 then selfSay("Vá derrotar todos os {Charmanders} para mim.") setPlayerStorageValue(cid, 35000, 0) talkState[talkUser] = 0 return true elseif getPlayerStorageValue(cid, 10002) == 0 then selfSay("Você ainda não derrotou todos os {100 Charmanders}. Termine a missão primeiro 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 selfSay("Ok, fale comigo novamente caso queira fazer minha missão.", cid) talkState[talkUser] = 0 return true end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Vá em Data/Creaturescripts/Scripts crie um arquivo chamado task_peter.lua e adicione o código dentro:
local nome_terceiro_npc = "Peter" local storage_npc = 10002 local storage_contador = 10003 local pokemon = { [1] = {name = "Charmander", count = 100}, } local nome = pokemon[1].name local restante 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.") doPlayerSendTextMessage(cid, 20, "Parabéns! Você concluiu a task do " ..nome_terceiro_npc) 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.. "s 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
Link para o comentário
Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados