Ir para conteúdo
  • Cadastre-se

[ajuda] npc guild master


Posts Recomendados

Estou fazendo um server e o ot server que eu baixei é o Crystal Server 9.31 ( baixei aqui no tibiaking mesmo). O problema é que não tem o NPC guildmaster. Alguem poderia me ajudar a botá-lo?

se me ajudarem ou pelo menos tentar é rep+ =)

obrigado!

Link para o post
Compartilhar em outros sites

Vá em \data\npc e crie um arquivo com o nome Guild Master.xml

e cole isso dentro

<?xml version="1.0"?>


<npc name="Guild Master" script="data/npc/scripts/guild.lua" access="3" lookdir="1">

<health now="1" max="1"/>

<look type="57" head="20" body="30" legs="40" feet="50" corpse="3128"/>

</npc>
feito isso, vá em \data\npc\scripts e crie outro arquivo com o nome guild.lua e coloque o codigo abaixo dentro
local focus = 0

local talk_start = 0

local target = 0

local following = false

local attacking = false


function onThingMove(creature, thing, oldpos, oldstackpos)


end



function onCreatureAppear(creature)


end



function onCreatureDisappear(cid, pos)

if focus == cid then

		 selfSay('Good bye then.')

		 focus = 0

		 talk_start = 0

end

end



function onCreatureTurn(creature)


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)

msg = string.lower(msg)


if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then

selfSay('Hello ' .. getCreatureName(cid) .. '! If you want make a guild, talk info.')

focus = cid

talk_start = os.clock()


elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')


elseif focus == cid then

talk_start = os.clock()


if msgcontains(msg, 'info') then

selfSay('You can create a guild talking "!createguild ...and the name...". When you create go for the Guild-Chat, and talk "!commands" that will go talk the commands for guild.')



	 elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

		 selfSay('Bye ' .. creatureGetName(cid) .. ', Come back.')

		 focus = 0

		 talk_start = 0


	 elseif msg ~= "" then

		 selfSay('What?')

		 talk_state = 0

	 end

end

end


function onCreatureChangeOutfit(creature)

end


function onThink()

doNpcSetCreatureFocus(focus)

if (os.clock() - talk_start) > 30 then

	 if focus > 0 then

		 selfSay('Next...')

	 end

	 focus = 0

	 talk_start = 0

end

if focus ~= 0 then

	 if getDistanceToCreature(focus) > 5 then

		 selfSay('Good Bye')

		 focus = 0

		 talk_start = 0

	 end

end

end

Depois é só ir no RME > File > IMPORT> MOnster/NPC e escolher o NPC que você acabou de criar e colocar ele no mapa :D

Se der algum erro poste aqui :D

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

Te ajudei?
Se você achar que eu mereço, me dê uma "rep+" e selecione meu post como "melhor resposta"

 

Skype: JoadsonAion

Link para o post
Compartilhar em outros sites

Dá algum erro no distro?

Te ajudei?
Se você achar que eu mereço, me dê uma "rep+" e selecione meu post como "melhor resposta"

 

Skype: JoadsonAion

Link para o post
Compartilhar em outros sites

Tente com esse script agora.

é o guild.lua


function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end

function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end

function creatureSayCallback(cid, type, msg) npcHandler:creatureSayCallback(cid, type, msg) end

function onThink() npcHandler:onThink() end

function onPlayerEndTrade(cid) npcHandler:onPlayerEndTrade(cid) end

function onPlayerCloseChannel(cid) npcHandler:onPlayerCloseChannel(cid) end


npcHandler:addModule(FocusModule:new())


local focus = 0

local talk_start = 0

local target = 0

local following = false

local attacking = false


function onThingMove(creature, thing, oldpos, oldstackpos)


end



function onCreatureAppear(creature)


end



function onCreatureDisappear(cid, pos)

if focus == cid then

		 selfSay('Good bye then.')

		 focus = 0

		 talk_start = 0

end

end



function onCreatureTurn(creature)


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 creatureSayCallback(cid, type, msg)

msg = string.lower(msg)


if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then

selfSay('Hello ' .. getCreatureName(cid) .. '! If you want make a guild, talk info.')

focus = cid

talk_start = os.clock()


elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')


elseif focus == cid then

talk_start = os.clock()


if msgcontains(msg, 'info') then

selfSay('You can create a guild talking "!createguild ...and the name...". When you create go for the Guild-Chat, and talk "!commands" that will go talk the commands for guild.')



	 elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

		 selfSay('Bye ' .. creatureGetName(cid) .. ', Come back.')

		 focus = 0

		 talk_start = 0


	 elseif msg ~= "" then

		 selfSay('What?')

		 talk_state = 0

	 end

end

end


function onCreatureChangeOutfit(creature)

end


function onThink()

doNpcSetCreatureFocus(focus)

if (os.clock() - talk_start) > 30 then

	 if focus > 0 then

		 selfSay('Next...')

	 end

	 focus = 0

	 talk_start = 0

end

if focus ~= 0 then

	 if getDistanceToCreature(focus) > 5 then

		 selfSay('Good Bye')

		 focus = 0

		 talk_start = 0

	 end

end

end

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

Te ajudei?
Se você achar que eu mereço, me dê uma "rep+" e selecione meu post como "melhor resposta"

 

Skype: JoadsonAion

Link para o post
Compartilhar em outros sites

Bom, eu acho que esse novo script vai da certo, porem apareceu um erro na hora de da load nele, o erro foi o seguinte data/npc/script/guild.lua:8: attempt to index global 'npcHandler' (a nil value). E embaixo desse erro da o erro do load. O que da dando de errado ?

OBS: Não sei se eu entendi mas parece que o npcHandler ta recebendo um valor nulo ;p

Link para o post
Compartilhar em outros sites

Sorry, esqueci algumas linhas kkk

teste esse aqui

local keywordHandler = KeywordHandler:new()

local npcHandler = NpcHandler:new(keywordHandler)

NpcSystem.parseParameters(npcHandler)


function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid)             end

function onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid)         end

function creatureSayCallback(cid, type, msg) npcHandler:creatureSayCallback(cid, type, msg) end

function onThink()                             npcHandler:onThink()                         end

function onPlayerEndTrade(cid)                npcHandler:onPlayerEndTrade(cid)            end

function onPlayerCloseChannel(cid)            npcHandler:onPlayerCloseChannel(cid)        end


npcHandler:addModule(FocusModule:new())


local focus = 0

local talk_start = 0

local target = 0

local following = false

local attacking = false


function onThingMove(creature, thing, oldpos, oldstackpos)


end



function onCreatureAppear(creature)


end



function onCreatureDisappear(cid, pos)

if focus == cid then

				 selfSay('Good bye then.')

				 focus = 0

				 talk_start = 0

end

end



function onCreatureTurn(creature)


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 creatureSayCallback(cid, type, msg)

msg = string.lower(msg)


if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then

selfSay('Hello ' .. getCreatureName(cid) .. '! If you want make a guild, talk info.')

focus = cid

talk_start = os.clock()


elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')


elseif focus == cid then

talk_start = os.clock()


if msgcontains(msg, 'info') then

selfSay('You can create a guild talking "!createguild ...and the name...". When you create go for the Guild-Chat, and talk "!commands" that will go talk the commands for guild.')



		 elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

				 selfSay('Bye ' .. creatureGetName(cid) .. ', Come back.')

				 focus = 0

				 talk_start = 0


		 elseif msg ~= "" then

				 selfSay('What?')

				 talk_state = 0

		 end

end

end


function onCreatureChangeOutfit(creature)

end


function onThink()

doNpcSetCreatureFocus(focus)

if (os.clock() - talk_start) > 30 then

		 if focus > 0 then

				 selfSay('Next...')

		 end

		 focus = 0

		 talk_start = 0

end

if focus ~= 0 then

		 if getDistanceToCreature(focus) > 5 then

				 selfSay('Good Bye')

				 focus = 0

				 talk_start = 0

		 end

end

end

Te ajudei?
Se você achar que eu mereço, me dê uma "rep+" e selecione meu post como "melhor resposta"

 

Skype: JoadsonAion

Link para o post
Compartilhar em outros sites

Ele continua sem responder quando eu falo hi ou qualquer outra coisa KKK

Um exemplo de um npc que tenho no meu server, só algumas linhas :

local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})

node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, promotion = 1, text = 'Congratulations! You are now promoted.'})

node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})

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.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo