Bitburner-Scripts/no-ports/hack.js

15 lines
397 B
JavaScript
Raw Normal View History

2023-11-02 11:04:03 -03:00
/** @param {NS} ns */
export async function main(ns) {
var target = ns.args[0]
var moneyThresh = ns.args[1]
var securityThresh = ns.args[2]
while (true) {
if (ns.getServerSecurityLevel(target) > securityThresh) {
await ns.weaken(target);
} else if (ns.getServerMoneyAvailable(target) < moneyThresh) {
await ns.grow(target);
} else {
await ns.hack(target);
}
}
}