Ir para conteúdo

Featured Replies

Postado
  • Solução
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 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())
  • Respostas 22
  • Visualizações 1.3k
  • Created
  • Última resposta

Top Posters In This Topic

Most 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 N

  • Tentei compreender o que tu tava tentando fazer no script e fiz esse : local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHand

  • local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:on

Postado
  • Autor
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 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())

 

Mesmo problema, spawna o NPC, fala hi, ele responde com a do xml certinho, mas qnd fala task ou qlqr fala ele n responde

Postado
  • Autor

Acho q não é esse o problema, pq tentei assim tbm e não foi

0 é ainda não escolheu

1 é ingles

2 é portugues

 

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 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 or  getPlayerStorageValue(cid, config.idiom) == 0 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 or  getPlayerStorageValue(cid, config.idiom) == 0 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 or  getPlayerStorageValue(cid, config.idiom) == 0 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 or  getPlayerStorageValue(cid, config.idiom) == 0 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 or  getPlayerStorageValue(cid, config.idiom) == 0 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())
Postado
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local config = {
	strg1 = 200201, -- storage começando a task
	strg2 = 91001, -- storage finalizou a task (ganha qnd matar os monstros)
	idiom = 8971
}

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)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	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("That good, one more soul coming from the {portal}! Welcome, I hope you can help.", cid)
				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)
				end
				talkState[talkUser] = 1
			else
				if(getPlayerStorageValue(cid, config.idiom) == 1) then
					selfSay("you have to finish the task.", cid)
				elseif(getPlayerStorageValue(cid, config.idiom) == 2) then
					selfSay("Você tem que terminar a missão.", cid)
				end
				talkState[talkUser] = 0
			end
		else
			if(getPlayerStorageValue(cid, config.strg2) == 1) then
				if(getPlayerStorageValue(cid, config.idiom) == 1) then
					selfSay("You have finished the mission! Take it a Sabre, use it until you reach on level 8 and talk with Oracle in the temple.", cid)
					selfSay("He will send you to Aurea, there talk with  !", cid)
				elseif(getPlayerStorageValue(cid, config.idiom) == 2) then
					selfSay("Você concluiu a missão! 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)
				end
				doPlayerAddItem(cid, 2385, 1)
			else
				if(getPlayerStorageValue(cid, config.idiom) == 1) then
					selfSay("You already finished this task.", cid)
				elseif(getPlayerStorageValue(cid, config.idiom) == 2) then
					selfSay("Você já terminou essa task.", cid)
				end
			end
			talkState[talkUser] = 0
		end

	elseif(msgcontains(msg:lower(), "portal") and talkState[talkUser] == 1) then
		if(getPlayerStorageValue(cid, config.idiom) == 1) then
			selfSay("Crystal, a angel come down here and in Aurea and opened a portal of humans who comes from another dimension for us {save}.", cid)
		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 nos {salvar}.", cid)
		end
		talkState[talkUser] = 2

	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)
		elseif(getPlayerStorageValue(cid, config.idiom) == 2) then
			selfSay("Estamos em um mundo apocalíptico, em guerra com varias raças. E você pode ser o {escolhido}!", cid)
		end
		talkState[talkUser] = 3

	elseif(msgcontains(msg:lower(), "escolhido") or msgcontains(msg:lower(), "the chosen") and talkState[talkUser] == 3) then
		if(getPlayerStorageValue(cid, config.idiom) == 1) then
			selfSay("Calm down, first we need to train, you have to help us with simple things until you are trained!", cid)
			selfSay("As for example our plague of {rats} in the city that are rising by storm drains!", cid)
		elseif(getPlayerStorageValue(cid, config.idiom) == 2) then
			selfSay("Calma, primeiro precisamos treinar, você deve nos ajudar com coisas simples, até estar bem treinado!", cid)
			selfSay("Como por exemplo a nossa praga de {rats} na cidade que estão subindo pelos bueiros!", cid)
		end
		talkState[talkUser] = 4

	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 storm drain in front here.", cid)
		elseif(getPlayerStorageValue(cid, config.idiom) == 2) then
			selfSay("Ok, então ajude-nos a acabar com isso e mate 10 ratos no bueiro aqui na frente.", cid)
		end
		setPlayerStorageValue(cid, strg1, 1)
		talkState[talkUser] = 0
	end
	return true
end

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

 Não testei.

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo