The3vilM0nk3y

/tools/server

Apr 23rd, 2022
1,118
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.     const args = ns.flags([["help", false]]);
  4.     let mem = args._[0];
  5.     if (!mem || args.help) {
  6.         ns.tprint("This script get the cost of a server at the specified RAM.");
  7.         ns.tprint(`Usage: run ${ns.getScriptName()} MEMSIZE`);
  8.         ns.tprint("Example:");
  9.         ns.tprint(`> run ${ns.getScriptName()} 32`);
  10.         return;
  11.     }
  12.     if (!ns.args[0]) {
  13.         let str = "";
  14.         let x = 1;
  15.         while (x <= ns.getPurchasedServerMaxRam()) {
  16.             str += x + ", ";
  17.             x = x * 2;
  18.         }
  19.         ns.tprint("Valid sizes are - " + str);
  20.     } else {
  21.         ns.tprint("Server Cost: ", ns.getPurchasedServerCost(ns.args[0]).toLocaleString("en-US"));
  22.     }
  23. }
  24. export function autocomplete(data, args) {
  25.     return ["1", "2", "4", "8", "16", "32", "64", "128", "256", "512",
  26.     "1024", "2048", "4096", "8192", "16384", "32768", "65536", "131072", "262144", "524288", "1048576"];
  27. }
Advertisement
Add Comment
Please, Sign In to add comment