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
1) You're not updating securityCurrent. When you run ns.getServerSecurityLevel() it returns a number, which is what you assign to securityCurrent. So the if statement will either always run or never run, depending on the state of the server when you initialize the script.
2)The script doesn't sleep outside of that if block. If the condition is false (ie the server is already at minimum security), the script will keep checking the condition endlessly and never give control back to the game engine or other scripts. This is why the game freezes. The HGW script you posted doesn't have this problem, because it always executes an awaited function every loop.
If you were updating securityCurrent inside the loop, the weaken-only script would weaken the target to minimum then freeze the game. Because you're not, the script either never crashes or crashes immediately.
Hack (with weaken and grow) script:
Weaken only script:
I tend to do the same thing. The problem is that most of the in game functions don't return references to stats, they return the current value.
The HWG script looks good. It should actually grow and hack now.
That weaken-only script will eventually freeze the game if you run it. Once security gets down below securityMinimum it will keep running the while loop without doing anything/giving up control. If you want it to keep weakening forever, you could just remove the if statement,
while(true){
weaken
}
If you want it to exit gracefully there are a few things you could do. Easiest would probably be to move the condition into the while statement,
while(sec > secMin){
weaken
}
I just meant that If the script is skipping the if block and no pause/sleep is there, because the checks are not what it is looking for (such as no longer above min level) then a sleep would need to be in place (or as you did, a script kill) to resolve it (especially in a while true block). I use sleep on a lot of mine just for that reason so they can run until requirements are met again. Depending on my script, I have some I run from multiple servers that do 1 job while others are watch dogs running from another keeping the security down and cash flow up. Then I have one I run from my home system that is essentially a worm that does them all but installs scripts to each target to run.
Anyhow, glad you have it sorted either way.
(Taking a project management position several years ago might have been a nice bump in pay at the time. But I would easily take a pay cut if it means I can enjoy doing brain-work and improve my scripting/programming skills again.)
This might be a silly question. But I'm comparing this sleep method to other languages. Is that value (500) in milliseconds?
Yes, sleep is run in milliseconds in this game, but here's some quick tricks/references to help if you ever want to sleep for longer intervals like a minute or more:
Hope this helps!