Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem









I noticed this on the forums whjen I was pasting code. I was able to fix it using [code][noparse] [/code][/noparse]
export function allServers(ns) {
var AllServ = ns.scan();
for (var i = 0; i < AllServ.length; ++i) {
var Serv = (AllServ );
var TempServ = [];
var TempServ = ns.scan(Serv.toString());
for (var ii = 0; ii < TempServ.length; ++ii) {
if (AllServ.includes(TempServ[ii])) { }
else { AllServ.push(TempServ[ii]); }
}
}
return AllServ;
}
[code]
for (var idx = 0; idx < checkList.length; idx++) {
var servers = await ns.scan(checkList[idx]);
if (!serverChecked.includes(checkList[idx] )) {
serverChecked.push(checkList[idx] );
[/code]
async function printArray(ns, serverList) {
for (var server in serverList) {
//try get root
if (!ns.hasRootAccess(serverList[server])){
await tryhack(ns,serverList[server])
}
//copy worker.js
if (! await ns.fileExists('worker.js',serverList[server])){
await ns.scp("worker.js","home",serverList[server]);
await ns.tprint("copy worker.js to",serverList[server]);
}
//run worker
ns.killall(serverList[server]);
var ram_server = await ns.getServerMaxRam(serverList[server]);
var ram_script = await ns.getScriptRam("worker.js");
var count_treat = await div(ram_server,ram_script);
if(count_treat < 1){ continue;}
await ns.exec("worker.js",serverList[server],count_treat);
}
Here is mine, i took advantage of the fact that in JS you can populate an array you are iterating on :)
export function getServersList(ns){
var hosts = ["home"]
for (var i of hosts){
for (let j of ns.scan(i)){
if(!hosts.includes(j) && !ns.getPurchasedServers().includes(j)) {
hosts.push(j)
}
}
}
ns.tprint(hosts)
}
Seems to still happen, and I've noticed (not sure if related) but the pid continuesly increases with every attempt on running it but it says below the run command:
"[home ~/]> run Find-all-servers.js
Running script with 1 thread(s), pid 834 and args: []."