Ir para conteúdo

Featured Replies

Postado

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

  • Respostas 8
  • Visualizações 1.9k
  • Created
  • Última resposta

Top Posters In This Topic

Postado
  • Autor

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

Postado

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

Postado
  • Autor

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})

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