Ir para conteúdo

Featured Replies

Postado

Explicação: Gostaria de um script em que o player só passe pelo tile se tiver uma "x" storage. (TESTEI ALGUNS AQUI DO SITE, MAS NÃO DERAM RESULTADO).

 

explcp.png?1516483133

O novo jogador nasce no circulo ROSA, e precisa falar com o NPC para receber um pokemon, logo, queria que ele só passasse pelos quadrados LARANJA caso ele já tenha pego um dos pokemons doados pelo NPC.

 

Aqui está o script do NPC. (tenho duvida na storage que ganha após pegar os pokemons, mas creio que seja a "54842".

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

Script de npc adaptada pelo @Nazo.

Editado por tavarb (veja o histórico de edições)

Resolvido por Nazo

Ir para solução
Postado
  • Solução

Em movements.xml adicione a seguinte tag:

<movevent type="StepIn" actionid="9914" event="script" value="newbietile.lua"/>

Em movements/scripts/ crie o arquivo newbietile.lua e adicione o seguinte conteúdo:

-- by Nazo (tibiaking.com)

function onStepIn(cid, item, position, fromPosition)
	if(getPlayerStorageValue(cid,54842) == -1) then
		doTeleportThing(cid,fromPosition)
		doPlayerSendTextMessage(cid,22,"Pegue seu pokémon para passar por aqui.")
	end
	return true
end

 

Com o map editor, coloque o actionid "9914" (ou outro, caso você altere na tag XML) nos dois tiles.

Programador PHP, Lua, Java, database administrator.

 

"Nada é verdade, tudo é permitido."

Requiescat in pace.

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.7k

Informação Importante

Confirmação de Termo