mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 12:15:44 +01:00
46 lines
1.4 KiB
Markdown
46 lines
1.4 KiB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
|
|
[Home](./index.md) > [bitburner](./bitburner.md) > [NS](./bitburner.ns.md) > [hackAnalyzeThreads](./bitburner.ns.hackanalyzethreads.md)
|
|
|
|
## NS.hackAnalyzeThreads() method
|
|
|
|
Calculate the decimal number of threads needed to hack a specified amount of money from a target host.
|
|
|
|
**Signature:**
|
|
|
|
```typescript
|
|
hackAnalyzeThreads(host: string, hackAmount: number): number;
|
|
```
|
|
|
|
## Parameters
|
|
|
|
| Parameter | Type | Description |
|
|
| --- | --- | --- |
|
|
| host | string | Hostname of the target server to analyze. |
|
|
| hackAmount | number | Amount of money you want to hack from the server. |
|
|
|
|
**Returns:**
|
|
|
|
number
|
|
|
|
The number of threads needed to hack the server for hackAmount money.
|
|
|
|
## Remarks
|
|
|
|
RAM cost: 1 GB
|
|
|
|
This function returns the decimal number of script threads you need when running the hack command to steal the specified amount of money from the target server. If hackAmount is less than zero, greater than the amount of money available on the server, or your hacking level is below the required level for the target server, then this function returns -1.
|
|
|
|
## Example
|
|
|
|
|
|
```js
|
|
// Calculate the thread count of a single hack that would take $100k from n00dles
|
|
const hackThreads = ns.hackAnalyzeThreads("n00dles", 1e5);
|
|
|
|
// Launching a script requires an integer thread count. The below would take less than the targeted $100k.
|
|
ns.run("noodleHack.js", Math.floor(hackThreads));
|
|
|
|
```
|
|
|