Explainer

DayZ init.c explained

init.c is the script that runs when your mission starts. In vanilla it does three jobs: starts the loot economy, keeps the in-game date in a fixed window, and gives fresh spawns their bandage, chemlight and piece of fruit. Because it's code rather than settings, it's powerful and easy to break. This guide explains what's in the vanilla file, what owners commonly change, and when a settings file is the safer choice.

  • 4 min read
  • Updated
  • PlayStation, Xbox and PC
init.cExample
void main(){    Hive ce = CreateHive();    if ( ce )        ce.InitOffline();    int reset_month = 9, reset_day = 20;    // keeps the date in early autumn}

Where it is

init.c sits in the root of your mission folder, next to cfggameplay.json and the db folder. Each map has its own. On Nitrado you'll find it in the File Browser under mpmissions and your map's mission folder. See where DayZ server files live.

Starting the economy

The main function first creates the Hive and starts the Central Economy. This line is what makes loot, cars and infected exist. Never remove it, or you'll have an empty map.

The date reset (why it's always autumn)

The vanilla script then checks the date. If it falls outside a window starting on 20 September, it sets the date back to 20 September. That keeps official-style servers in early autumn, with the weather and daylight that suits.

If you've wondered why your server never reaches winter, this is why. Change reset_month and reset_day to move the window, or remove the date block to let the date run, combined with serverTime and serverTimePersistent in serverDZ.cfg. Monthly temperatures are set in cfggameplay.json.

Starting gear in StartingEquipSetup

The CustomMission class holds StartingEquipSetup, which runs for every fresh spawn. Vanilla gives a bandage, a random coloured chemlight and an apple, pear or plum, sets them on the quickbar, and gives clothing and items a random condition between 45% and 65% with SetRandomHealth.

Owners often add items here with CreateInInventory and the item's class name. It works, but every line is code, so a typo or missing semicolon can stop the server from starting.

Use spawn gear presets instead

DayZ now supports spawn gear presets: JSON files listed in cfggameplay.json that set what new players wear and carry, with random picks. They're settings, not code, they work the same on PlayStation, Xbox and PC, and a mistake is far less likely to take the server down. For most starter kits, that's the better choice. See starter kits.

Other things init.c can do

Because it's a script, init.c can do far more on PC with mods, from custom loadouts by player to spawning objects. On vanilla console servers, stick to small, well-tested changes. For buildings and objects, object spawner files are the safer route.

Changing the season properly

To run a winter server, three things need to agree. In init.c, change or remove the date reset so the date can sit in winter. In serverDZ.cfg, set serverTime to a winter date and turn on serverTimePersistent so it doesn't jump back. In cfggameplay.json, check environmentMinTemps and environmentMaxTemps for the winter months, which set how cold it actually feels.

Weather such as snow and fog lives in cfgweather.xml. See how to change the weather and use the Weather Editor to set it up.

Vanilla starting condition

SetRandomHealth is why fresh spawns' clothes and items always look worn. It picks a value between 0.45 and 0.65 of full health for each item. Raise both numbers for nicer starting clothes, or remove the calls so items spawn in full condition. It's a small change that new players notice straight away, but keep it modest: a fresh spawn with pristine gear changes the feel of the early game.

Edit it safely

Treat every init.c change like code:

  • Download the original before you change anything
  • Make one change at a time and restart to test
  • Check every line ends with a semicolon and every bracket closes
  • Use exact class names: a misspelt item silently doesn't appear
  • If the server won't start, put the original back first, then find the error

Tools for this

Common questions

Why is my DayZ server always in autumn?

Vanilla init.c resets the date to a window starting on 20 September. Change or remove that block to let the season move.

How do I give players starting gear?

Use spawn gear presets in cfggameplay.json, which is safer than editing init.c. The Starter Kits tool builds them for you.

Can I edit init.c on PS5 or Xbox?

It's in the mission folder on console servers too, but because it's code, small mistakes stop the server. Spawn gear presets are the safer option on console.

Do I need to restart after changing init.c?

Yes. init.c only runs when the mission starts, so changes apply after the next restart.

Can I give different players different starting gear?

Spawn gear presets pick randomly between kits. Giving specific players specific gear needs script changes or mods on PC.

My server won't start after editing init.c. What now?

Put the original file back to get the server running, then check your change for a missing semicolon, bracket or a misspelt class name.

Run your DayZ server from one place

Free editors for every config file, plus a live dashboard and Discord feeds when you're ready.