Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

116
Visualizações
I am making a mineflayer pvp bot but it only attacks once

I am trying to make a pvp minecraft bot using mineflayer in javascript. This is my function for if the bot is requested to pvp:

bot.loadPlugin(pvp)
bot.on('chat', (username, message) =>{
if (message === 'fight me') {
    const player = bot.players[username]

    if (!player) {
      bot.chat("I can't see you.")
      return
    }
    bot.chat("Get ready to PvP in 10 seconds!")
    const sword = bot.inventory.items().find(item => item.name.includes('sword'))
    if (sword) bot.equip(sword, 'hand')
    const shield = bot.inventory.items().find(item => item.name.includes('shield'))
    if (shield) bot.equip(shield, 'off-hand')
   
    sleep(1500).then(() => {
    
    beeingAlive()
    bot.chat(`/tp notbreadbutter ${username}`)
    bot.pvp.attack(player.entity)})
    
  }

  if (message === 'stop') {
    bot.pvp.stop()
    
  }})

I want the bot to know when the player gets killed. I also want the bot to know if the bot itself gets killed. How should i modify my code?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda