Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

305
Vistas
I cant stop my interval and neither clearInterval() work;

I've made simple userscript for the game https://zty.pe/, The bot work on my modified version of the game, I'm trying to make it whenever I click "F" it starts running , but stops when I click " C ", the loop works normally after clicking C and it doesnt stop.

document.addEventListener('keydown', (e) => {
  key = e.keyCode
  if(key == 70){
  var zTypeBotAlphaChars = "abcdefghijklmnopqrstuvwxyz";
  var zTypeBotCharToType = 0;
  ztypebot = setInterval(function() {
  ig.game.shoot(
  zTypeBotAlphaChars.charAt(zTypeBotCharToType));
  }
  , 10);
  }
})


document.addEventListener('keydown', (e) => {
  if(e.keyCode == 67){
    clearInterval(ztypebot, 10);
  }
})
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Try adding window. before ztypebot interval to make it a global function:

document.addEventListener('keydown', (e) => {
  key = e.keyCode
  if(key == 70){
  var zTypeBotAlphaChars = "abcdefghijklmnopqrstuvwxyz";
  var zTypeBotCharToType = 0;
  window.ztypebot = setInterval(function() {
  ig.game.shoot(
  zTypeBotAlphaChars.charAt(zTypeBotCharToType));
  }
  , 10);
  }
})


document.addEventListener('keydown', (e) => {
  if(e.keyCode == 67){
    clearInterval(window.ztypebot, 10);
  }
})
about 4 years ago · Juan Pablo Isaza Denunciar

0

Your ztypebot variable is local in each function, you need to define it outside like so:

let ztypebot;

document.addEventListener('keydown', (e) => {
  ...
  ztypebot = setInterval(function() {
    ...
  }
})


document.addEventListener('keydown', (e) => {
  if(e.keyCode == 67){
    clearInterval(ztypebot, 10);
  }
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda