Get the list of servers connected to a server.Ĭheck if any script with a filename is running. Start another script on the current server. Prints a formatted string to the script’s logs. Prints one or more values or variables to the script’s logs. Get a copy of the data from a port without popping it. Returns whether the player has access to the darkweb.Ĭhecks the status of the logging for the given function. Get the security increase for a number of threads.Ĭheck if you have root access on a server. Get the chance of successfully hacking a server. Get the part of money stolen with a single thread. GrowthAnalyzeSecurity(threads, hostname, cores)Ĭalculate the security increase for a number of threads. Spoof money in a server's bank account, increasing the amount available.Ĭalculate the number of grow threads needed to grow a server by a certain multiplier. Get the execution time of a weaken() call. Returns the amount of time in milliseconds that have passed since you last installed Augmentations. Returns the required hacking level of the target server.Ĭalculate your share power. Returns the number of open ports required to successfully run NUKE.exe on the specified server. Returns the minimum security level of the target server. Get the maximum amount of RAM on a server. Get the maximum money available on a server. ![]() Defaults to the running script's server if host is not specified. Returns a server object for the given server. GetRunningScript(filename, hostname, args) Get an array of recently killed scripts across all servers. Get cost of upgrading a purchased server to the given ram. GetPurchasedServerUpgradeCost(hostname, ram) Returns an array with the hostnames of all of the servers you have purchased. Returns the maximum RAM that a purchased server can have. Returns the maximum number of servers you can purchase. Get information about the sources of income for this run. Returns a string with the hostname of the server that the script is running on. Returns the player’s current hacking level. Returns the amount of Faction favor required to be able to donate to a faction. Terminates the current script immediately. You should prefer 'sleep' over 'asleep' except when doing very complex UI work.Īdd callback function when the script dies With 'push' you can add a value to the end of an array and with 'pop' you can remove an element from the end of an array (while return the value).įor (let i = servers.length i < ns.getPurchasedServerLimit() i++) else if (ns.Export async function main ( ns ) Next up is 'includes', this gives you a boolean value (true or false) depending on wheter a value is present in an array. So lets start with the 'length' property, using this on an array will give you the amount of elements in an array. ![]() Other uses of an array you will be using in this script are the 'length' property and the 'includes' function, optionally you could use things like 'push' and 'pop' as well. Arrays provide a lot more utility than just iteration though, if you want some in depth information I suggest you take a look at this link. There are several things you can do with an array, one you'va already used: iteration. That may have seemed like a rather strange intermezzo, but I'll be talking about arrays for a bit now, so I felt that had to be clarified. Intermezzo: arraysBy now you may have noticed that I am using the terms 'list' and 'array' interchangeably, but the name of the data-structure in javascript is an array and a list is not actually a thing in javascript (it is in some other languages), so I'm using it in the sense of 'making a todo list' or 'making a shopping list'. Being strict means that the two values need to be exactly the same, this is easiest shown in an example: The '=' and '=' operators compare two values, the difference is that '=' is strict. If you don't know what logical operators are, you can easily find some good information about them online (you could check this wikipedia link for example). ![]() The '&' operator is the logical and operator (a conjunction), while the '||' operator is the logical or operator (a disjunction). The reason for this is that '&' and '||' can link multiple smaller conditional statements together to get a single bigger conditional statement and that's why they are different from the other conditional operators. Lets start with the reason I split up that list with the word 'and' towards the end. There are couple of operators you'll frequently see when writing conditional statements, these are: '=', '=', '>', '=', '!', '!=', '!=' and '&', '||'. If you don't, stick around for a bit.Ī conditional statement is an expression that evaluates to a boolean value (a lot of fancy words to say: a statement that is either true of false). If you know about conditional statements you can head straight into the next section.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |