The3vilM0nk3y

hiveCluster/hack.js

Apr 26th, 2022
1,124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /** @param {NS} ns **/
  2. export async function main(ns) {
  3.     //Args - target, timeToFinish, executionTime, actionID
  4.     var server = ns.args[0];
  5.     var timeToFinish = ns.args[1];
  6.     let doWait = true;
  7.     while (doWait){
  8.         if (performance.now() + ns.getHackTime(server) >= timeToFinish) break;
  9.         await ns.sleep(1);
  10.     }
  11.     //if (performance.now() + ns.getHackTime(server) >= timeToFinish + 50) {
  12.         //ns.tprint("Hack is going to be late! Terminating instead.");
  13.         //return;
  14.     //}
  15.     await ns.hack(server);
  16.     if(performance.now + 50 > timeToFinish) ns.tprint("Hack Finished late!! " + performance.now());
  17. }
Advertisement
Add Comment
Please, Sign In to add comment