Stormworks: Build and Rescue Guide

Ultimate Guide to Dedicated Servers for Stormworks: Build and Rescue

Ultimate Guide to Dedicated Servers

Overview

A detailed guide of how to install, config and run a dedicated server.Developed based off of Beginner’s guide, with alot of lessons learned along the way.Much credit goes to Beginner

Prerequsites

Exposition

The server is mostly responsible for calculating the physics of the creations in-game. To do this, the server process relies on the FPU (Floating Point Unit) or better known as the math coprocessor built into the CPU in order to compare and resolve the positions of vehicles and their subgrids.

(Yes, this is why vehicles with lots of subgrids destroy servers.)

Now that I have explained the what the server wants the most, lets help you decide what you want to run the server.

Hardware

CPU
FPU speed does not scale much with the product stack of a processor. Instead, FPU speed scales with processor generation. Biggest leap is 5000 series Ryzen, which saw 2x performance leap in FPU speed over previous gen. CPU clock speed and single threaded performance also helps, so basically get 5000 series Ryzen.

Good FPU, high clock speeds and single threaded performance.

Min: 4-7th gen i3-i5, 1st gen Ryzen
Good: 4-7th gen i7, 2-3rd gen Ryzen
Great: 8-11th gen i3-i9, 5th gen Ryzen

RAM
The server program has a memory leak issue, so high ram amounts are just stability buffer.
The whole system only needs minimum 4gb of ram to run the server properly, but a popular server will need around 8gb.

Low ram usage, but memory leak will hamper uptime and stability.

Min: 4gb DDR3
Good: 8-16gb DDR4
Great: 32-64gb DDR4 ECC

GPU
The server process does not need one, but your eyeballs might. If intel, you have integrated graphics, if AMD, you are going to need a gt 710 or something.

Storage
Nothing special here, but you should be using an SSD of some sort as a boot drive when using windows 10.

The faster the better. Storage does not matter.

Min: 30gb HDD
Good: 64gb SSD
Great: 128gb NVME SSD

Network
Large amounts of data is only sent and received when a new vehicle is spawned. Other than that, idle bandwidth usage is around 300kbps per player. That’s 3.6mbps for 12 players. Latency should be the biggest worry of a network.

Speed is negligible, ping is our worry

Min: 10mbps with 30ms ping (Average DSL)
Good: 50mbps with 20ms ping (Slow cable)
Great: 100mbps with 2ms ping (Really slow fiber)

OS
This whole guide is written for windows 10 (both normal and server), but the server is said to work on windows 7, 8, and 8.1. Some brave souls also say that it can run on linux, but if you are reading a guide on how to use the dedicated servers, you are not skilled enough to configure this on linux. (Im not hating on you, im just clearing up our expectations).

I love windows, and you should too.

Min: Windows 10
Good: WIndows 10 Pro, Edu, or LTSC
Great: Windows Server 2019

Our three system categories

Min: An acceptable experience, fit for up to 8 players or so. Consider 8gb RAM.
i3-4370, r3 1200
4gb DDR3/4
30gb HDD
10mbps internet with 30ms ping (Average DSL)
Windows 7

Good: A great start for dedicated server hosting, ripe for a single 12 player server or two servers with few players.
i7-7700, r5 2600
16gb DDR3/4
64gb SSD
50mbps internet with 20ms ping (Slow cable)
Windows 10 LTSC

Great: An excellent experience. This is the ideal system, fit for up to 6 servers, and ready for handling insane uptimes and a super active community.
i9-10900k, r5 5600x (remember, 5th gen has upgraded FPU and incredible single core performance)
64gb DDR4 ECC
128gb NVME SSD
100mbps internet with 2ms ping (Really slow fiber)
Windows Server 2019

And there is our hardware configurations! Funnily enough, the optimization of the server software is just so bad that upgrading any part of any one of the builds (aside from maybe storage) will increase its function at least a little bit. Obviously the min spec build would like to see any part be better, but even our “good” build could benefit from a better cpu, more ram, lower latency internet, and maybe even windows server.

Hopefully this lets you gauge the kind of experience you can expect to get from the computer you plan to use for your server.

Installation

We will be installing steamcmd on windows, which is steam, but command line (do not be scared)

  • Download SteamCMD
  • Unzip to C:steamcmd
  • Go to folder and launch steamcmd
  • Paste this code into it (it installs the stormworks server)
    login anonymous force_install_dir c:swds app_update 1247090 validate

  • Once it finished type quit to exit and close SteamCMD
  • Go to the server folder and run server.exe at least once to create a server_config.xml file that will be in %appdata%Stormworks folder by default.
  • Complete!

Configuring the XML File

Hit Win+R and type in %appdata%Stormworks in order to access the configuration file for the server.
Edit that file with any text editor such as default Notepad or more advanced Notepad++
(Notepad++ highly recomended, get it here[notepad-plus-plus.org].)

What do the settings mean?
port=”25564″ set the game and query ports that will be used for the server name=”Stormworks” set the name of the server seed=”” set the seed that will be used for the world generation (empty is random) save_name=”” set the world save name that will be used for save and loading max_players=”32″ set the max number of the players for server password=”” set the password (empty means no password) day_night_length=”60″ set the length of the day in minutes base_island=”” set what player base will be owned on start (empty is start base)

Tile Name Guide
Main Biome data/tiles/island_15.xml Creative Island data/tiles/island_43_multiplayer_base.xml Multiplayer Base data/tiles/island_34_military.xml Military Base data/tiles/island_25.xml Harbour Base data/tiles/island12.xml Starter Base data/tiles/test_tile.xml Helicopter Base data/tiles/island_24.xml Airstrip Base data/tiles/island_33_tile_33.xml Mainland Airstrip data/tiles/island_33_tile_32.xml Terminal Spycakes data/tiles/island_33_tile_end.xml Terminal Camodo Custom Bases data/tiles/island_29_playerbase_submarine.xml Custom Base Submarine data/tiles/island_32_playerbase_heli.xml Custom Base Heli data/tiles/island_30_playerbase_boat.xml Custom Base Large Boat data/tiles/island_31_playerbase_combo.xml Custom Base Small Boat data/tiles/oil_rig_playerbase.xml Custom Base Oil Rig Arcitc Islands data/tiles/arctic_island_playerbase.xml Arctic Island Base data/tiles/arctic_tile_22.xml Arctic Mainland Outpost data/tiles/arctic_tile_12_oilrig.xml Arctic Oil Platform Sawyer Islands data/tiles/mega_island_2_6.xml Harrison Airbase data/tiles/mega_island_12_6.xml O’Neill Airbase data/tiles/mega_island_9_8.xml North Harbor Dock data/tiles/mega_island_15_2.xml Fishing Village Dock

Adding Admins

This section is needed to give admin permissions for clients by using Steam64 ID. To find ID of your or your friends accounts you can use websites like [link].

Example:

<admins> <id value=”76561198080294966″/> </admins>

Player Type Dictionary

Blacklist: Blacklist is simply a ban list. We fill it in the same way as we add admins. Accounts of players that were banned by admins will be automatically stored here too.

Whitelist: Whitelist also fills the same way but note that the server will be automatically switched into whitelist mode if there will be at least one entry. In that mode only players from that list will be able to connect.

Authorized: A list of players that allowed to interact with workbench. By default only admins and whitelisted players are allowed to spawn, despawn and return vehicles so if you want other players to have that permission then you should add them to that list.

Alright, now that we have our server settings set up (what a mouthful), lets jump over to making sure we can join the server.

Networking!

Stormworks servers use UDP packets to transfer all data. Most data is transferred on random ports that are willing to accept application data, but to see the server in the server list, your computer must ping the server.

The other server guide wants you to forward the port that you set in the XML file as well as the 2 ports that follow, but stormworks only sends and receives data on the third port (eg, if you set your port to 25564, data is only being sent on 25566) (This is old information, forward all ports)

To keep your network as safe as possible (open ports are major security vulnerabilities), I recommend forwarding only the third port.

In the port forwarding rules section of your internet router, please forward all three ports, and only the UDP portion of that port. This should allow your server to be viewable in the server browser.

Should you fail to see your server, you may be on the same network or even computer as the server. If this is the case, you must install the microsoft loopback adapter.

Installing Microsoft Loopback Adapter
  • Open Control Panel > Device Manager and select Network Adapters
  • Select menu Action > Add legacy hardware
  • Next
  • Select Install the hardware that I manually select from a list (Advanced)
  • Next
  • Select Network Adapters in the list
  • Next
  • Select Microsoft in Manufacturer list
  • Select Microsoft KM-TEST Loopback Adapter in Model list
  • Next > Next > Finish
  • Close Device Manager window
  • Open Control Panel > Network and Internet > Network Connections
  • You should see a new connection that uses Microsoft Loopback Adapter but cannot establish connection
  • Right click on that connection and select Properties
  • Double click Internet Protocol Version 4 (TCP/IPv4)
  • Select Use the following IP address
  • NOTE: If it was already selected and you see some IPs entered then you opened a wrong connection. Get out of here by clicking Cancel in both windows.
  • Enter in IP address field your external IP address (you can see it here for example [link])
  • You can leave default Subnet mask
  • Click OK buttons in opened windows to save settings

Ready for the Real First Run

Hopefully you completed all previous steps correctly. If not, complete the previous steps correctly.

RUN THE SERVER

(server64.exe that is, server.exe can only address 4gb of ram[www.quora.com])

Hopefully you can use the server now, but if you have issues, contact me on discord (thatcoolcat1#6969)

The glee and glory may be empowering right now, but what if the server crashes while you are away?

What if you want to authorize anyone that joins?

Well you are in the ONLY guide that provides this information. Continue on to save hours of coding and waiting for help on the sw official discord lua chat.

In-Game Scripts

Ripe for the picking, here are some mission scripts that you can use to preform different things in the game.

Mission scripts normally reside in the C:swdsromdatamissions directory. here you can find the default missions, and also where you should most likely put your missions as well.

ALL MISSIONS NEED TO BE REFRENCED AT THE BOTTOM OF THE CONFIG XML FILE TO LOAD.

For the following missions, preform this process to transfer the file.

  • Paste the code into the lua editor in the mission editor
  • Save the mission
  • Copy the mission folder from the %appdata%RoamingStormworksdatamissions directory
  • Paste the mission folder into the C:swdsromdatamissions directory
  • Reference the mission in the server config XML file

Now for the scripts!

Automatic Authentication (AutoAuth)
function onPlayerJoin(steam_id, name, peer_id, admin, auth) server.addAuth(peer_id) end

Popup on Join
–[[ Author: Miep3r Description: Displays a message upon server join, hides after ?ok is entered in chat ]] function onPlayerJoin(steam_id, name, peer_id, admin, auth) server.removePopup(peer_id, 0) server.setPopupScreen(peer_id, 0, name, true, “Attention: this is a NO WORKSHOP server! This means that you are only allowed to spawn vehicles that you yourself have made! Type ?ok to confirm that you understand this.”, 0, 0) end function onCustomCommand(full_message, user_peer_id, is_admin, is_auth, command, one, two, three, four, five) if command == “?ok” then server.removePopup(user_peer_id, 0) end end

Despawn on Command
–[[ Author: Miep3r Description: Clears all peer spawned vehicles. ]] local m_vehicles = {} function onVehicleSpawn(vehicle_id, peer_id, x, y, z, cost) local plr = getPlayerByPeerId(peer_id) local o = { owner = plr.id, vid = vehicle_id } table.insert(m_vehicles, o) end function onVehicleDespawn(vehicle_id, peer_id) local vehicle = getVehicle(vehicle_id) for i,v in pairs(m_vehicles) do if v == vehicle.vid then return table.remove(m_vehicles, i) end end end function getVehicle(vehicle_id) for _,v in pairs(m_vehicles) do if v.vid == vehicle_id then return v end end end function getPlayerByPeerId(peer_id) local plrs = server.getPlayers() for _,v in pairs(plrs) do if v[‘id’] == peer_id then return v end end end function onCustomCommand(full_message, user_peer_id, is_admin, is_auth, command, one, two, three, four, five) if command == “?clr” then local plr = getPlayerByPeerId(user_peer_id) c = 0 for i,v in pairs(m_vehicles) do if v.owner == user_peer_id then table.remove(m_vehicles, i) server.despawnVehicle(v.vid, true) c = c + 1 end end server.notify(user_peer_id, ‘Vehicle despawn’, ‘Despawned ‘ .. c .. ‘ vehicles!’, 0) end end

Server Management Scripting

Over the past month or so, I have been working on an interconnected system of autohotkey scripts in order to automatically restart my server, while also reporting to a log in a discord channel.

Here is a guide on how to implement that same system. script included.

Firstly, you must create a .bat file with this code and place it in the root directory (C:)

@echo off C:Steamcmdsteamcmd.exe +login anonymous +force_install_dir C:swds +app_update 1247090 +quit

This code updates the server application when it is run, and is a dependency of the server management script.

Next, we have to install autohotkey so the script can be run.

Installing AutoHotKey
  • Go here[www.autohotkey.com]
  • Download
  • Install
  • Done

And get a discord web hook set up in our discord server

  • Open your Server Settings and head into the Integrations tab:
  • Click the “Create Webhook” button to create a new webhook!

Now that we have the program to run the script, and the webhook set up, we must now paste the script.

  • Right click on the desktop and select “new autohotkey script”
  • Name the file “server manager”
  • Right click on the file and open with notepad++
  • Paste following code, and follow instructions after the code block

Server Manager.ahk
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. ; #Warn ; Enable warnings to assist with detecting common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. ;Script created by thatcoolcat1#6969 ;Do not directly redistribute, this file should only be obtained from the dedicated server steam guide. OnExit(“ExitFunc”) url:=”insert discord webhook URL” failcount = 0 mgmt= ( { “content”: “:toolbox: Server 1 management script online.” } ) restart1= ( { “content”: “:arrows_counterclockwise: Server 1 application is not running, starting it…” } ) restart2= ( { “content”: “:poop: Server 1 application crashed!, restarting it…” } ) fail1= ( { “content”: “:x: Failed to start server 1 application! Reattempting **now**.” } ) fail2= ( { “content”: “:x::alarm_clock: Failed to start server 1 application! Reattempting **in 10 minutes**.” } ) fail2timer = 10 * 60000 fixme= ( { “content”: “:wave: Fix me now please.” } ) sucess= ( { “content”: “:white_check_mark: Server 1 application sucessfully launched! Join now!” } ) WebRequest := ComObjCreate(“WinHttp.WinHttpRequest.5.1”) ;this does something WebRequest.Open(“POST”, url, false) ;this does something else WebRequest.SetRequestHeader(“Content-Type”, “application/json”) ;this does the last thing WebRequest.Send(mgmt) Loop { Process, Exist, server64.exe ;check if the server is running If (ErrorLevel = 0) ;if it is not running, commence the process { failcount += 1 ;register that it has failed sleep 10 ;wait 0.01 seconds Loop, 4 { if (A_Index > 3) ;if this is the fourth loop, do this { WebRequest.Send(fail2) ;says that it will wait 10 minutes WebRequest.Send(fixme) ;it now asks politely to be fixed sleep, fail2timer ;waits 10 minutes break } if (failcount = 1) ;if this is the first time that the server process is not running, treat it like startup { WebRequest.Send(restart1) } if (failcount > 1) ;if this is not the first time that the server process is not running, treat it like a crash { WebRequest.Send(restart2) } WebRequest.Send(restart) ;this is problably junk but i dont want to break it RunWait, C:updater.bat, C: ;runs the updater bat file and waits until it completes Run, C:swdsserver64.exe, C:swds ;the schmeat is told to start sleep, 5000 ;wait 5 seconds Process, Exist, server64.exe ;recheck if the server is running If (ErrorLevel > 0) ;if it started { WebRequest.Send(sucess) break } If (ErrorLevel = 0) ;if it did not start { WebRequest.Send(fail1) failcount += 1 } } } sleep 1000 ;wait 1 second } ExitFunc(ExitReason, ExitCode) ;this function sends messages when the program exits. everything in here is self explanatory { url:=”insert discord webhook URL” WebRequest := ComObjCreate(“WinHttp.WinHttpRequest.5.1”) WebRequest.Open(“POST”, url, false) WebRequest.SetRequestHeader(“Content-Type”, “application/json”) exitunexp= ( { “content”: “<@&801562495122014321> :toolbox: :x: Server 1 management script closed unexpectedly.” } ) exitexp= ( { “content”: “<@&801562495122014321> :toolbox: :tools: Server 1 management script closed by server owner.” } ) exitvm= ( { “content”: “<@&801562495122014321> :window: :x: Server PC going offline.” } ) if ExitReason in Close,Error,Exit,Reload,Single { WebRequest.Send(exitunexp) sleep, 250 return } if ExitReason in Logoff,Shutdown { WebRequest.Send(exitvm) sleep, 250 return } if ExitReason in Menu { WebRequest.Send(exitexp) sleep, 250 return } }

  • Continue this list of instructions
  • Edit lines 11 and 118 with your discord webhook URL
  • Save the file
  • In order to make this script run on startup, continue list.
  • Close the file
  • Hit Win+R
  • Type shell:startup
  • Enter
  • Copy and paste the script file into this folder
  • Right click on the file in the folder, and select “create shortcut”
  • Copy the shortcut to the desktop so it is easier to start the script if it closes.
  • Finished

Now you should be able to restart the computer, and see that the server starts up when the computer starts. It also updates every time that it starts, and if you close the server, or the server crashes, it should come back in a maximum time of around 7 seconds.

Conclusion

Great!

Hopefully this works, and if you followed every part of the guide, you understand alot about stormworks servers, how they function, and how to get your server running at the level of other professional sw servers.

Now enjoy some motorhome racing, or maybe something else IDK

_

Want to see the management script in action, or get in contact with me? Join my discord, SW Automotive Hub[www.discord.gg]
SteamSolo.com