Ir para conteúdo
  • Cadastre-se

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


Ir para solução Resolvido por Summ,

Posts Recomendados

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
	
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

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

		elseif msgcontains(msg:lower(), 'portal') and talkState[talkUser] == 1 then
			if getPlayerStorageValue(cid, config.idiom) == 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}.', cid)
				talkState[talkUser] = 2
			elseif getPlayerStorageValue(cid, config.idiom) == 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}.', cid)
				talkState[talkUser] = 2
			end

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

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

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

return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Editado por Summ (veja o histórico de edições)

EQD4Qy4.gif

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

se não der tenta isso 

 

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
	
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

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

		elseif msgcontains(msg:lower(), 'portal') and talkState[talkUser] == 1 then
			if getPlayerStorageValue(cid, config.idiom) == 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}.', cid)
				talkState[talkUser] = 2
			elseif getPlayerStorageValue(cid, config.idiom) == 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}.', cid)
				talkState[talkUser] = 2
			end

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

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

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

return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
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

    96842
    Tópicos
    519594
    Posts



×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo