Buy Server Script

Script


//EDIT 2022-01-06: Added the line 'money = ns.getPlayer().money;' to the end of the for-loop to update the 'money' variable in the argument.

var ram = Math.pow(2,20);

var list = ns.getPurchasedServers();

var money = ns.getPlayer().money;

var ramCost = ns.getPurchasedServerCost(ram);

var i;

for( i = list.length; i < 25 && money >= ramCost; i++ )

{

ns.purchaseServer("H" + parseInt(i+1),ram);

ns.tprint("Purchased server H" + parseInt(i+1));

money = ns.getPlayer().money;

}

list = ns.getPurchasedServers();

ns.tprint("Total Purchased Servers: " + list.length);

Source: https://steamcommunity.com/sharedfiles/filedetails/?id=2709244193					

More Bitburner guilds