DayZ
Not enough ratings
VS Code for Mission Configuration Quick Start Guide
By Baltic 9
Quick guide to using VS Code for better server configuration experience and thorough validation.
   
Award
Favorite
Favorited
Unfavorite
Intro
Almost all guides on DayZ server configuration feature Notepad++ as the editor of choice, and some touch on the topic of online validators. Sure Notepad++ is much better than Windows Notepad for XML editing, but it's far from optimal in my opinion. VS Code with extensions provides extensive validation that will save you time when troubleshooting server economy problems. You can't get this level of error checking with online validators. In this guide I'll show you how to use VS Code to edit DayZ server mission configuration.

In the text I'll refer to the editor as VS Code because it's more recognizable, but I'm actually using VSCodium[vscodium.com] which is FLOSS and telemetry free. You can pick any VSCode-based editor and the workflow will be the same.
Installation
  1. First you need the editor, if you don't already have it, you can download VS Code from the site[code.visualstudio.com] or get VSCodium from the link above.
  2. Next, we encounter a minor inconvenience: the extension we want to install requires Java[www.java.com] 17 or newer to work. You can check wether you meet requirements by typing
    java --version
    in command line. If you have an older version or don't have Java at all, you can download it from the link above or with one command if you use Windows 11:
    winget install Microsoft.OpenJDK.21
  3. Now we can install the extension. Open the editor, go to the Extensions and try to search for "dayz". You will find DayZ CE Schema which we'll install:

    After the installation your editor is ready for DayZ missions!
    Opening a mission
    To get the most out of the DayZ CE Schema extension you have to open exactly mission folder (folder where cfgeconomycore.xml is located). If you open mpmissions or the root server folder, the extension won't work properly and you'll miss out on many of the features described below. Some people may find this annoying but IMO the benefits outweigh this inconvenience, even without full DayZ CE Schema features, VS Code offers more pleasant editing experience than other editors. If you want to work on multiple missions at the same time, I suggest opening them in separate folders.

    Use File -> Open Folder (or Ctrl+K Ctrl+O) and select mission folder, alternatively you can just drag the mission folder into the editor window:
    Expansion setup
    The extension provides commands that come in handy when you adding mods to your mission. Let's see how it works with the Expansion mod.

    1. Expansion comes with its own events, types and spawnable types so we copy the whole expansion_ce folder from template[github.com] into our mission and open expansion_types.xml:

      At the top of the file you will see a warning and if you press Ctrl+. a menu with available fixes will pop up. We get the warning because expansion_types.xml is in the mission folder but hasn't (yet) been added to cfgeconmycore.xml so will have no impact on server economy.
    2. Pick "Add file to the mission" quick fix and expansion_types.xml will be added to cfgeconmycore.xml. Unfortunately applied changes aren't saved automatically, so press Ctrl+K S to save them. The warning will disappear and expansion types are now part of the mission. You can repeat similar process for events and spawnabletypes or copy lines from the cfgeconmycore.xml provided in the template.
    3. Now go back to the expansion_types.xml. You will see a huge list of category "vehicleparts" doesn't exist errors. This happens because Expansion mission template is slightly outdated ¯\_(ツ)_/¯. vehicleparts category was removed from cfglimitsdefinition.xml in 1.23 patch. Thanks to extensive validation we found this problem without even running a server and examining logs! If you place cursor at the beginning of the name and press Ctrl+Space to trigger autocompletion you can see all available categories. We need to change vehicleparts to lootdispatch.

      There is no way to fix this error automatically, but we can use Search&Replace (Ctrl+F) to replace all categories at once.

    4. Let's take a look at problems in expansion_events.xml. NOTE: VS Code can validate only opened files, you won't get errors for a file without opening (or previewing it) it!

      At the top of the list we get the warning Type with classname "Truck_01_Covered_Grey" does not exist because ... well, there really is no grey variant of V3S ¯\_(ツ)_/¯. Sometimes you will see false positive errors of this type because casing doesn't match what's in the types files so extension can't find the classname, but this time it appears to be a legit warning. You can remove this child line or just ignore it. Next we can see a bunch of Event ... is not referenced in cfgeventspawns.xml these notifications are a friendly reminder that we have not yet copied contents of the cfgeventspawns.xml provided with the template into our mission.
    5. Drag the cfgeventspawns.xml provided with the template into your editor. At the top of the file you will see a message that file is not part of the mission, but you can copy its contents. To do this open code actions popup and pick suggested action. You are copying new events, so it doesn't matter in which order we add them to the file. I prefer top for visibility. After saving changes to the mission cfgeventspawns.xml, diagnostic messages for events disappear. Now you can close the file from the template.

    6. Copy expansion folder from the template to the mission in order to finish minimal Expansion setup.
    Weapon mod setup
    Let's see how VS Code comes in handy when we add simple weapon mod that consist of types and spawnabletypes files.

    1. Assuming you're lucky and a mod author provides a types file with the mod, you can drag the file into the editor and the familiar reminder will pop up. The file is not part of the mission but you can copy it with a single click. Note that custom files are copied to the db folder and VS Code automatically switches to the copied file.

      In my case, fortunately, the file doesn't contain any errors, but it does have ♥♥♥♥♥♥ formatting. You can easily fix the formatting by pressing Alt+Shift+F, but make sure you format the file from the mission, not the external one.
    2. You can add spawnabletypes in a similar way. Note that there is autocompletion for classnames in spawnabletypes files (use Ctrl+Space to trigger it):
    Other features
    Here is couple of other features that I occasionally find useful:

    • Navigation. DayZ mission is a set of interconnected files and features like Find References and Go to Declaration help you move between them more quickly. You can access these features from the context menu by right-clicking on symbols:

      "Peek ..." interface also allows you to quickly edit another file next to the reference without switching document tabs (I use Alt+F12 to peek preset definition):

    • Linked editing. VS Code helps you maintain integrity of references in your mission files. For example, you can rename a truck spawn event in events.xml and its name in expansion_events.xnl and cfgeventspawns.xml will change accordingly. You can preview changes without applying them.

      Note that renaming (F2) an event leaves the "Vehicle" part intact, because events can have arbitrary names but must start with specific prefixes to work properly.
    3 Comments
    Mr.JMods Jan 28 @ 8:43am 
    Thank you!
    Baltic 9  [author] Jan 21 @ 11:55am 
    Which build of the editor are you using? Here is the link [marketplace.visualstudio.com] to the extension on VS Code Marketplace.
    Mr.JMods Jan 10 @ 9:08pm 
    I did not find DayZ CE Schema in my extensions search