2022-10-21 17:16:00 +02:00
|
|
|
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
|
|
|
|
|
|
[Home](./index.md) > [bitburner](./bitburner.md) > [NS](./bitburner.ns.md) > [getPurchasedServerCost](./bitburner.ns.getpurchasedservercost.md)
|
|
|
|
|
|
|
|
## NS.getPurchasedServerCost() method
|
|
|
|
|
|
|
|
Get cost of purchasing a server.
|
|
|
|
|
2023-02-11 19:18:50 +01:00
|
|
|
**Signature:**
|
2022-10-21 17:16:00 +02:00
|
|
|
|
|
|
|
```typescript
|
|
|
|
getPurchasedServerCost(ram: number): number;
|
|
|
|
```
|
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
|
|
|
| Parameter | Type | Description |
|
|
|
|
| --- | --- | --- |
|
|
|
|
| ram | number | Amount of RAM of a potential purchased server, in GB. Must be a power of 2 (2, 4, 8, 16, etc.). Maximum value of 1048576 (2^20). |
|
|
|
|
|
2023-02-11 19:18:50 +01:00
|
|
|
**Returns:**
|
2022-10-21 17:16:00 +02:00
|
|
|
|
|
|
|
number
|
|
|
|
|
|
|
|
The cost to purchase a server with the specified amount of ram.
|
|
|
|
|
|
|
|
## Remarks
|
|
|
|
|
|
|
|
RAM cost: 0.25 GB
|
|
|
|
|
|
|
|
Returns the cost to purchase a server with the specified amount of ram.
|
|
|
|
|
2023-04-28 20:19:30 +02:00
|
|
|
## Example
|
2022-10-21 17:16:00 +02:00
|
|
|
|
|
|
|
|
2023-04-28 20:19:30 +02:00
|
|
|
```js
|
|
|
|
const ram = 2 ** 20;
|
|
|
|
const cost = ns.getPurchasedServerCost(ram);
|
2024-05-23 10:42:47 +02:00
|
|
|
ns.tprint(`A purchased server with ${ns.formatRam(ram)} costs $${ns.formatNumber(cost)}`);
|
2022-10-21 17:16:00 +02:00
|
|
|
```
|
|
|
|
|