Ir para conteúdo
  • Cadastre-se

(Resolvido)O que eu fiz de errado? NPC simples


Ir para solução Resolvido por Summ,

Posts Recomendados

4g56QDD.png
 
local strg1 = 200201 -- storage começando a task
local strg2 = 91001 -- storage finalizou a task (ganha qnd matar os monstros)
-- ["rat"] = {monster_race={"rat","cave rat"}, storage_start = 200201, storage = 91001,count = 10},
if string.lower(msg) == "task" then
    if getPlayerStorageValue(cid, strg1) == 0 then
        if getPlayerStorageValue(cid, 8971) == 1 then
            selfSay("Good one more coming soul of {portal}! Welcome, I hope you can help!")
        elseif getPlayerStorageValue(cid, 8971) == 2 then
            selfSay("Que bom mais uma alma vinda do {portal}! Seja bem vindo, espero que possa nos ajudar!.")
        end
        if string.lower(msg) == "portal" then
            if getPlayerStorageValue(cid, 8971) == 1 then
                selfSay("Crystal angel one came down here and Aurea and opened a portal of humans who comes from another dimension for us {save}.")
            elseif getPlayerStorageValue(cid, 8971) == 2 then
                selfSay("Crystal uma anja desceu até aqui e em Aurea e abriu um portal de humanos que vem de outra dimensão para nós {salvar}.")
            end
            if string.lower(msg) == "salvar" or string.lower(msg) == "save" then
                if getPlayerStorageValue(cid, 8971) == 1 then
                    selfSay("We are in an apocalyptic world, at war with several races. And you can be! {the chosen}")
                elseif getPlayerStorageValue(cid, 8971) == 2 then
                    selfSay("Estamos em um mundo apocalíptico, em guerra com varias raças. E voce pode ser o {escolhido}!")
                end
                if string.lower(msg) == "escolhido" or string.lower(msg) == "the chosen" then
                    if getPlayerStorageValue(cid, 8971) == 1 then
                        selfSay("Congratulations, now with permission.")
                    elseif getPlayerStorageValue(cid, 8971) == 2 then
                        selfSay("Calma primeiro precisamos treinar, voce deve nos ajudar com coisas {simples}, ate estar bem treinado!")
                        selfSay("Como por exemplo a nossa praga de {rats} na cidade que estão subindo pelos bueiros!")
                    end
                    if string.lower(msg) == "rats" then
                        if getPlayerStorageValue(cid, strg1) == 0 then
                            setPlayerStorageValue(cid, strg1, 1)
                            if getPlayerStorageValue(cid, 8971) == 1 then
                                selfSay("Congratulations, now with permission.")
                            elseif getPlayerStorageValue(cid, 8971) == 2 then
                                selfSay("Ok, então ajuda-nos a acabar com isso e mate 10 ratos no bueiro aqui na frente.")
                            end
                        elseif getPlayerStorageValue(cid, strg2) >= 1 then
                            if getPlayerStorageValue(cid, 8971) == 1 then
                                selfSay("Congratulations, now with permission.")
                            elseif getPlayerStorageValue(cid, 8971) == 2 then
                                selfSay("Voce concluiu a missao, tome aqui um Sabre, use ele ate chegar no nivel 8 e fale com o Oraculo no templo!")
                                selfSay("Ele ira te mandar para Aurea, la fale com !")
                            end         
                            doPlayerAddItem(cid,2385,1)
                        end
                    end
                end
            end
        end
    end
end
Link para o post
Compartilhar em outros sites
  • Respostas 22
  • Created
  • Última resposta

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

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:onCreatureD

Tentei compreender o que tu tava tentando fazer no script e fiz esse : local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) npcHandler.topic = {} 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 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 if not npcHandler:isFocused(cid) then return false end

Tentei compreender o que tu tava tentando fazer no script e fiz esse :

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
npcHandler.topic = {}

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 msg = msg:lower()

local config = {
	strg1 = 200201, -- storage começando a task
	strg2 = 91001, -- storage finalizou a task (ganha qnd matar os monstros)
	strg3 = 8971

}

		if msgcontains(msg, "task") then
			if getPlayerStorageValue(cid, config.strg2) < 1 then
				if getPlayerStorageValue(cid, config.strg1) < 1 then
					if getPlayerStorageValue(cid, config.strg3) == 1 then
						npcHandler:say("Good one more coming soul of {portal}! Welcome, I hope you can help!", cid)
						npcHandler.topic[cid] = 1
					elseif getPlayerStorageValue(cid, config.strg3) == 2 then
						npcHandler:say("Que bom mais uma alma vinda do {portal}! Seja bem vindo, espero que possa nos ajudar!.", cid)
						npcHandler.topic[cid] = 1
					end
				else
					npcHandler:say("you have to finish the task", cid)
					npcHandler.topic[cid] = 0
				end
			else
				npcHandler:say("Voce concluiu a missao, tome aqui um Sabre, use ele ate chegar no nivel 8 e fale com o Oraculo no templo!", cid)
				npcHandler:say("Ele ira te mandar para Aurea, la fale com !", cid)
				doPlayerAddItem(cid, 2385, 1)
				npcHandler.topic[cid] = 0
			end

		elseif msgcontains(msg, "portal") and npcHandler.topic[cid] == 1 then
			if getPlayerStorageValue(cid, config.strg3) == 1 then
				npcHandler:say("Crystal angel one came down here and Aurea and opened a portal of humans who comes from another dimension for us {save}.", cid)
				npcHandler.topic[cid] = 2
			elseif getPlayerStorageValue(cid, config.strg3) == 2 then
				npcHandler:say("Crystal uma anja desceu até aqui e em Aurea e abriu um portal de humanos que vem de outra dimensão para nós {salvar}.", cid)
				npcHandler.topic[cid] = 2
			end

		elseif msgcontains(msg, "salvar") or msgcontains(msg, "save") and npcHandler.topic[cid] == 2 then
			if getPlayerStorageValue(cid, config.strg3) == 1 then
				npcHandler:say("We are in an apocalyptic world, at war with several races. And you can be! {the chosen}", cid)
				npcHandler.topic[cid] = 3
			elseif getPlayerStorageValue(cid, config.strg3) == 2 then
				npcHandler:say("Estamos em um mundo apocalíptico, em guerra com varias raças. E voce pode ser o {escolhido}!", cid)
				npcHandler.topic[cid] = 3
			end

		elseif msgcontains(msg, "escolhido") or msgcontains(msg, "the chosen") and npcHandler.topic[cid] == 3 then
			if getPlayerStorageValue(cid, config.strg3) == 1 then
				npcHandler:say("Congratulations, now with permission.", cid)
				npcHandler:say("Such as our plague of {rats} in the city that are climbing down the drain!", cid)
				npcHandler.topic[cid] = 4
			elseif getPlayerStorageValue(cid, config.strg3) == 2 then
				npcHandler:say("Calma primeiro precisamos treinar, voce deve nos ajudar com coisas {simples}, ate estar bem treinado!", cid)
				npcHandler:say("Como por exemplo a nossa praga de {rats} na cidade que estão subindo pelos bueiros!", cid)
				npcHandler.topic[cid] = 4
			end

		elseif msgcontains(msg, "rats") and npcHandler.topic[cid] == 4 then
			if getPlayerStorageValue(cid, config.strg3) == 1 then
				npcHandler:say("Okay, so help us get this over with and kill 10 rats in the gutter in front here.", cid)
				setPlayerStorageValue(cid, strg1, 1)
				npcHandler.topic[cid] = 0
			elseif getPlayerStorageValue(cid, config.strg3) == 2 then
				npcHandler:say("Ok, então ajuda-nos a acabar com isso e mate 10 ratos no bueiro aqui na frente.", cid)
				setPlayerStorageValue(cid, strg1, 1)
				npcHandler.topic[cid] = 0
			end
		end

return true
end

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

EQD4Qy4.gif

Link para o post
Compartilhar em outros sites

Como eu nunca fiz um NPC devo ta fazendo besteira vou usar o seu @Summ, mas qnd eu falo hi, task o npc não me responde nada, sem nenhum erro no console, mas o npc não me responde

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
npcHandler.topic = {}
 
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 msg = msg:lower()
 
local config = {
strg1 = 200201, -- storage começando a task
strg2 = 91001, -- storage finalizou a task (ganha qnd matar os monstros)
idiom = 8971
 
}
 
if msgcontains(msg, "task") then
if getPlayerStorageValue(cid, config.strg2) < 1 then
if getPlayerStorageValue(cid, config.strg1) < 1 then
if getPlayerStorageValue(cid, config.idiom) == 1 then
npcHandler:say("Good one more coming soul of {portal}! Welcome, I hope you can help!", cid)
npcHandler.topic[cid] = 1
elseif getPlayerStorageValue(cid, config.idiom) == 2 then
npcHandler:say("Que bom mais uma alma vinda do {portal}! Seja bem vindo, espero que possa nos ajudar!.", cid)
npcHandler.topic[cid] = 1
end
else
npcHandler:say("you have to finish the task", cid)
npcHandler.topic[cid] = 0
end
else
npcHandler:say("Voce concluiu a missao, tome aqui um Sabre, use ele ate chegar no nivel 8 e fale com o Oraculo no templo!", cid)
npcHandler:say("Ele ira te mandar para Aurea, la fale com !", cid)
doPlayerAddItem(cid, 2385, 1)
npcHandler.topic[cid] = 0
end
 
elseif msgcontains(msg, "portal") and npcHandler.topic[cid] == 1 then
if getPlayerStorageValue(cid, config.idiom) == 1 then
npcHandler:say("Crystal angel one came down here and Aurea and opened a portal of humans who comes from another dimension for us {save}.", cid)
npcHandler.topic[cid] = 2
elseif getPlayerStorageValue(cid, config.idiom) == 2 then
npcHandler:say("Crystal uma anja desceu até aqui e em Aurea e abriu um portal de humanos que vem de outra dimensão para nós {salvar}.", cid)
npcHandler.topic[cid] = 2
end
 
elseif msgcontains(msg, "salvar") or msgcontains(msg, "save") and npcHandler.topic[cid] == 2 then
if getPlayerStorageValue(cid, config.idiom) == 1 then
npcHandler:say("We are in an apocalyptic world, at war with several races. And you can be! {the chosen}", cid)
npcHandler.topic[cid] = 3
elseif getPlayerStorageValue(cid, config.idiom) == 2 then
npcHandler:say("Estamos em um mundo apocalíptico, em guerra com varias raças. E voce pode ser o {escolhido}!", cid)
npcHandler.topic[cid] = 3
end
 
elseif msgcontains(msg, "escolhido") or msgcontains(msg, "the chosen") and npcHandler.topic[cid] == 3 then
if getPlayerStorageValue(cid, config.idiom) == 1 then
npcHandler:say("Congratulations, now with permission.", cid)
npcHandler:say("Such as our plague of {rats} in the city that are climbing down the drain!", cid)
npcHandler.topic[cid] = 4
elseif getPlayerStorageValue(cid, config.idiom) == 2 then
npcHandler:say("Calma primeiro precisamos treinar, voce deve nos ajudar com coisas {simples}, ate estar bem treinado!", cid)
npcHandler:say("Como por exemplo a nossa praga de {rats} na cidade que estão subindo pelos bueiros!", cid)
npcHandler.topic[cid] = 4
end
 
elseif msgcontains(msg, "rats") and npcHandler.topic[cid] == 4 then
if getPlayerStorageValue(cid, config.idiom) == 1 then
npcHandler:say("Okay, so help us get this over with and kill 10 rats in the gutter in front here.", cid)
setPlayerStorageValue(cid, strg1, 1)
npcHandler.topic[cid] = 0
elseif getPlayerStorageValue(cid, config.idiom) == 2 then
npcHandler:say("Ok, então ajuda-nos a acabar com isso e mate 10 ratos no bueiro aqui na frente.", cid)
setPlayerStorageValue(cid, strg1, 1)
npcHandler.topic[cid] = 0
end
end
 
return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

-- Dps eu do rep pra vcs pessoal já dei 5 pro summ

Editado por oliverarrow (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

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.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Estatísticas dos Fóruns

    96844
    Tópicos
    519612
    Posts



×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo