-
Notifications
You must be signed in to change notification settings - Fork 0
/
purchaseServer8GB.js
31 lines (28 loc) · 1.04 KB
/
purchaseServer8GB.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/** @param {NS} ns */
export async function main(ns) {
var ram = 8; //RAM for the new server
var i = 0; //counter for new servers
var attackScript = "/simplehack/simplehack-template.js";
var target = "joesguns";
var secThresh = 1;
var moneyThresh = 0.9;
var baseName = "pserv-";
var loopQueenScript = "/loophack/loop-queen-pserv.js";
while (i < ns.getPurchasedServerLimit()) {
//check if enough money is available
if (ns.getServerMoneyAvailable("home") >= ns.getPurchasedServerCost(ram)) {
//1. buy one
//2. copy file over
//3. execute file
//4. increment iterator
var hostname = ns.purchaseServer(baseName + i, ram);
await ns.scp(attackScript, hostname, "home");
ns.exec(attackScript, hostname, 3, target, secThresh, moneyThresh);
i++;
}
//wait some time to prevent strange names, if script is started with enough money to buy several servers
await ns.sleep(1000);
}
//Once we got all servers we could buy, we start loop-hacking on them.
ns.spawn(loopQueenScript, 1, target);
}