var mineflayer = require('mineflayer'); count = 160; relog(count); function relog(index){ console.log("Attempting to reconnect..."); bot = mineflayer.createBot({ version: 1.13, host: 'jasmc.eu', port: 25565, username: 'piessobronny'+index });bindEvents(bot); } function bindEvents(bot){ bot.on('windowOpen',function(window){ var items = window.slots; var clickid = 0; for(var x=1;x<54;x++){ if((window.slots[x]!=null)&&(window.slots[x].type!='')&&(window.slots[x].type!=undefined)){ if((window.slots[x].type!=window.slots[x-1].type)&&(x>0)){ console.log("ItemID: "+x); clickid = x; }}} console.log("I0: "+window.slots[clickid-1].type+" | I1: "+window.slots[clickid].type+" | I2: "+window.slots[clickid+1].type); bot.clickWindow(clickid-1,0,0); bot.chat('/register haslo1 haslo1'); //setTimeout(function(){bot.chat('/pay pendevv_pl 20000');bot.chat('/pay pendevv_pl 20000');},1000); }); bot.on('messagestr',function(messagestr){ if(messagestr.search('przychodzący')!=-1){ bot.chat('/garderoba'); setTimeout(function(){bot.chat('/hub');},300); setTimeout(function(){bot.chat('/pay pendevv_pl 20600');bot.chat('/pay pendevv_pl 20600');},800); setTimeout(function(){ count++; bot.end(); relog(count); },2500); } if(messagestr.search('wersje')!=-1){ count++; relog(count); console.log("MCDS: "+messagestr); } }); bot.on('end', function() { console.log("Bot has ended"); //setTimeout(function(){count=count+1;relog(count);}, 500); }); bot.on('kicked',function(reason,loggedin){ console.log("kicked ("+reason+" | "+loggedin+")"); }); }