2019-03-03 04:08:54 +01:00
|
|
|
hackAnalyzeThreads() Netscript Function
|
|
|
|
=======================================
|
|
|
|
|
2021-03-12 08:51:56 +01:00
|
|
|
.. js:function:: hackAnalyzeThreads(hostname, hackAmount)
|
2019-03-03 04:08:54 +01:00
|
|
|
|
|
|
|
:RAM cost: 1 GB
|
2021-03-12 08:51:56 +01:00
|
|
|
:param string hostname: Hostname of server to analyze.
|
|
|
|
:param number hackAmount: Amount of money you want to hack from the server.
|
|
|
|
:returns: The number of threads needed to :doc:`hack<hack>` the server for
|
|
|
|
``hackAmount`` money.
|
2019-03-03 04:08:54 +01:00
|
|
|
|
|
|
|
This function returns the number of script threads you need when running
|
2021-03-12 08:51:56 +01:00
|
|
|
the :doc:`hack<hack>` command to steal the specified amount of money from
|
|
|
|
the target server.
|
2019-03-03 04:08:54 +01:00
|
|
|
|
2021-03-12 08:51:56 +01:00
|
|
|
If ``hackAmount`` is less than zero or greater than the amount of money
|
|
|
|
available on the server, then this function returns -1.
|
2019-03-03 04:08:54 +01:00
|
|
|
|
2021-03-12 08:51:56 +01:00
|
|
|
For example, let's say the 'foodnstuff' server has $10m and you run:
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
2019-03-03 04:08:54 +01:00
|
|
|
|
|
|
|
hackAnalyzeThreads("foodnstuff", 1e6);
|
|
|
|
|
2021-03-12 08:51:56 +01:00
|
|
|
If this function returns 50, this means that if your next :doc:`hack<hack>` call
|
2019-03-03 04:08:54 +01:00
|
|
|
is run on a script with 50 threads, it will steal $1m from the `foodnstuff` server.
|
|
|
|
|
2019-05-17 08:55:21 +02:00
|
|
|
.. warning:: The value returned by this function isn't necessarily a whole number.
|
|
|
|
.. warning:: It is possible for this function to return :code:`Infinity` or :code:`NaN` in
|
|
|
|
certain uncommon scenarios. This is because in JavaScript:
|
|
|
|
|
|
|
|
* :code:`0 / 0 = NaN`
|
|
|
|
* :code:`N / 0 = Infinity` for 0 < N < Infinity.
|
|
|
|
|
|
|
|
For example, if a server has no money available and you want to hack some positive
|
|
|
|
amount from it, then the function would return :code:`Infinity` because
|
|
|
|
this would be impossible.
|