Enforce Script Syntax – Arma Reforger

From Bohemia Interactive Community
Revision as of 15:39, 9 December 2025 by Lou Montana (talk | contribs) (Add data types)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Enforce Script is the language that is used by the Enfusion engine first introduced in DayZ Standalone. It is an Object-Oriented scripting language that works with objects and classes and is similar to the C# programming language.



Data Types

There are many types of data, the most common being:

Type Description Example Wikipedia
Native types
a bool, a.k.a true or false (and nothing else!)
bool value = true;
see Bool
an integer, a.k.a a whole number e.g 1, 42, -10, etc.
int value = 42;
see Integer
a floating point value, a.k.a a partial number e.g 1.0, 4.2, -0.1, etc
float value = 0.333;
see Float
a text value, a.k.a a sequence of characters, e.g "Hello there"
string owk = "Hello" + " " + "there";
see String
an array of three float values e.g { 1.0, 42.2, 66.6 }
vector position = { 5, 1.5, 10 };
see Vector
Objects
class
an object able to hold properties and methods. see Object Oriented Programming Basics see Class
enum
a structure having static values "listed" as its properties.
An enum is not an object per se.
SCR_EBloodType myBloodType = SCR_EBloodType.O_POSITIVE;
see Enum
static array a static array of elements (of a type) - it cannot contain a mix of types.
Arrays (dynamic or static) are the only list type that can be initialised in line.
string helloThereWords[] = { "Hello", "there" };
see Array
a dynamic array of elements (of a type) - it cannot contain a mix of types.
Arrays (dynamic or static) are the only list type that can be initialised in line.
array<string> helloThereWords = { "Hello", "there" };
see Array
set<x>
 a set of unique elements, it can only contain one type of elements.
Values are not stored in insertion order.
set<string> helloThereWords = new set<string>(); helloThereWords.Insert("Hello"); helloThereWords.Insert("there"); helloThereWords.Insert("Hello"); // ignored Print(helloThereWords.Count()); // prints '2'
see Set
map<x, y>
a map constituted of key-value pairs, where the key aspect is used to obtain the value.
Values are not stored in insertion order.
map<string, int> wordsAndLength = new map<string, int>(); wordsAndLength.Insert("General", 7); wordsAndLength.Insert("Kenobi", 6); Print(replyWordsAndLength.Get("Kenobi")); // prints '6'
see Map


Object-Oriented Programming

See Object Oriented Programming Basics and Object Oriented Programming Advanced Usage.


Operations

Assignation

Assignation operations convert the value to the expected type; see below:

// adding int and int int result = 1 + 2; // result == 3 // adding float and float float result = 1.25 + 2.75; // result == 4 // adding int and float int result = 1 + 0.9; // result == 1 - int truncates a float result int result = 0.9 + 0.9 + 0.9; // result == 2 - 2.7 truncated to 2 float result = 0.9 + 0.9 + 0.9; // result == 2.7 float result = 1 + 1.9; // result == 2.9 float result = 1.9 + 1; // result == 2.9 bool invalid = new SCR_Ray(); // error: Types 'SCR_Ray' and 'bool' are unrelated SCR_Ray instance = new SCR_Ray(); bool valid = instance; // valid == true bool result = 42; // result == true

Logic

SCR_Ray instance = new SCR_Ray(); if (instance) // identical to "instance != null" Print("Instance exists"); else Print("Instance does not exists"); string text; if (text) // identical to "!text.IsEmpty()" Print("Text is not empty"); else Print("Text is empty"); int val = 42; // same with float if (val) // identical to "val != 0" Print("Val is not zero"); else Print("Val is zero");

if (intValue) and if (stringValue) are not recommended by Scripting: Best Practices.


🏗
This article is a work in progress!