Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Explicação: Gostaria de uma adaptação no tipo de say do npc, fazendo com que abra o channel NPCs(da mensagem azul) e que não precise seguir a ordem para receber o primeiro pokemon.

prof.png?1516740901

o npc e o seu tipo de say.

 

outfits.png?1516741206

O tipo de mensagem que quero.

 

SCRIPT NPC:

local focus = 0 -- NÃO EDITE ISSO
local talk_start = 0 -- NÃO EDITE ISSO
local target = 0 -- NÃO EDITE ISSO
local following = false -- NÃO EDITE ISSO
local attacking = false -- NÃO EDITE ISSO
local newbie = 1010101
function onCreatureDisappear(cid, pos)
	if focus == cid then
		selfSay('Good bye then.')
		focus = 0
		talk_start = 0
	end
end

function msgcontains(txt, str)
	return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end
	
function onCreatureSay(cid, type, msg)
	local health = 1000
	local maxhealth = 1000
	newbies = getPlayerStorageValue(cid,newbie)
	msg = string.lower(msg)
	newperson = getPlayerStorageValue(cid,newbie)
	if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
		selfSay('Hello, I am Professor Carvalho. I was once a legendary pokemon trainer. Today I {help} beginner coaches and study in the laboratory of Professor Oak.')
		focus = cid
		talk_start = os.clock()
	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
		selfSay('Sorry, wait your turn.')
	elseif focus == cid then
		talk_start = os.clock()
		if msgcontains(msg, 'help') and newbies <= 0 then
			selfSay('I have a {bulbasaur}, {charmander} and {squirtle}. I can give you one pokemon to help you make your journey, would you like?')
			talk_state = 1
		elseif talk_state == 1 and newbies <= 0 then
			if msgcontains(msg, 'yes') then
				selfSay('Ok, so what pokemon you like?')
				talk_state_s = 2
			elseif talk_state_s == 2 then
				if msgcontains(msg, 'bulbasaur') then
					addPokeToPlayer(cid, "Bulbasaur", 0, nil, "poke")
					doPlayerAddItem(cid, 2394, 16)
					doPlayerAddItem(cid, 2391, 4)
					doPlayerAddItem(cid, 2393, 1)
					doPlayerAddItem(cid, 12348, 1)
					doPlayerAddSoul(cid, 1)
					setPlayerStorageValue(cid, 54842, "Bulbasaur, ")
					selfSay("Here is your Bulbasaur and some supplies.")
					setPlayerStorageValue(cid,newbie,1)
				elseif msgcontains(msg, 'charmander') then
					local description = "Contains a Charmander."
					local poke1 = "This is Charmander's pokeball. HP = ["..health.."/"..maxhealth.."]"
					addPokeToPlayer(cid, "Charmander", 0, nil, "poke")
					doPlayerAddItem(cid, 2394, 14)
					doPlayerAddItem(cid, 2391, 2)
					doPlayerAddItem(cid, 12347, 1)
					doPlayerAddSoul(cid, 1)
					setPlayerStorageValue(cid, 54842, "Charmander, ")
					selfSay("Here is your Charmander and some supplies.")
					setPlayerStorageValue(cid,newbie,1)
				elseif msgcontains(msg, 'squirtle') then
					local description = "Contains a Squirtle."
					local poke1 = "This is Squirtle's pokeball. HP = ["..health.."/"..maxhealth.."]"
					addPokeToPlayer(cid, "Squirtle", 0, nil, "poke")
					doPlayerAddItem(cid, 2394, 18)
					doPlayerAddItem(cid, 2391, 6)
					doPlayerAddItem(cid, 2392, 1)
					doPlayerAddItem(cid, 12346, 1)
					doPlayerAddSoul(cid, 1)
					setPlayerStorageValue(cid, 54842, "Squirtle, ")
					selfSay("Here is your Squirtle and some supplies.")
					setPlayerStorageValue(cid,newbie,1)
				elseif msgcontains(msg, 'no') then
					selfSay("OK... What you want?")
				elseif msgcontains(msg, 'bye') then
					selfSay("OK! Bye...")
					focus = 0
					talk_start = 0
				else
					selfSay("Tell me what pokemon you like?")
				end
			elseif msgcontains(msg, 'no') then
				selfSay("OK... What you want?")
				talk_state = 0
			elseif msgcontains(msg, 'bye') then
				selfSay("OK! Bye...")
				focus = 0
				talk_start = 0
			end
		elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 2 then
			selfSay('Good bye!')
			focus = 0
			talk_start = 0
		end
	end
end
	
function onThink()
	doNpcSetCreatureFocus(focus)
	if (os.clock() - talk_start) > 30 then
		if focus > 0 then
			selfSay('Bye...')
		end
		focus = 0
	end
	if focus ~= 0 then
		if getDistanceToCreature(focus) >= 2 then
			selfSay('Good bye then.')
			focus = 0
		end
	end
end

 

obs: se puder tirar esses "talk_state = 1" (que são utilizados para seguir uma linha de mensagens...) e tem um pequeno erro na distância pra falar "hi" entre o npc e o jogador, o jogador tem que estar a 1 sqm do npc para falar, senão o npc fala "bye". (ajustar para o normal, 3 sqms)

 

Agradeço!

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.

  • Conteúdo Similar

    • Por LeoTK
      Salve galera neste tópico irei postar algumas prints do mapa do servidor para quem queira acompanhar e quem sabe até utilizar de inspiração para mapear o seu NTO.
       
      #Att 11/08/2022

       
       
       
       
      Konoha (Em Desenvolvimento)
       
       
       
       
    • Por DiigooMix
      Como o título já diz, será que alguém possui sprite do hitto e se possível as transformações dele?
    • Por OmegaZero
      Olá gostaria que alguém me ajudasse com uma "scripting" não sei se é pela mesma, seria o seguinte uma determinada arma teria a chance de dar double hit e não sei oque fazer alguem poderia ajudar?

      OBS:não sei se é o local correto se não for mova, desculpe
    • Por Madarasenju
      Olá galera do Tibia King, queria por uns npc's no meu server que não tem função de trade nem nada do tipo, queria que eles só andassem como enfeite, Rep+ Pra quem me ajudar... grato desde já.
    • Por SilenceRoot
      A magia é assim o você usa a a magia e ela ficará ativado por 10 segundos, até que o inimigo lance a primeira magia ou todos de uma vez, quando ele lançar a primeira magia, ele não lhe acertará ou seja esquivando dela, e logo em seguida será teletransportado aleatoriamente ao redor do inimigo que usou.
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo