On-Line doc

Fwatch v1.14 scripting documentation

What is Fwatch?

Fwatch is a program extending Operation Flashpoint's scripting functionality.

It creates a hook on file operations. When the game attempts to open a file with a special name, Fwatch takes over. It's able to perform a variety of operations (like reading/writing text, processing strings, utilizing WINAPI) and send new data back to the game.

It was created by Kegetys in 2005. This project (which started in the late 2010) is a continuation. It features 95 new commands, compatibility with 1.99 and has several old issues fixed.


Startup

For quick start simply double click on Fwatch.exe or FwatchCWA.exe (for Cold War Assault).

Make exception in your Antivirus/Firewall software.



All parameters passed to the Fwatch.exe are transferred to the game. Use shortcut (target field) or command line to type in arguments. -nomap is added automatically when you start the game through the Fwatch executable.

Fwatch custom parameters:

-nolaunch - installs hook without starting the game. Then you can manually launch Flashpoint and/or dedicated server with OFPR_Server.exe / ColdWarAssault_Server.exe.

-gamespy=<ip> - changes master server address for the in-game server browser.

-reporthost - informs master server about your player-hosted game so it will show up in a browser. Address is determined by the -gamespy parameter. Port is set by the -port= parameter.

-sortmissions - moves missions from the active modfolders to the mission folders and back when you quit the game. First place files in <mod>\Missions\ and <mod>\MPMissions\.


If you have Russian localization of the game ...


Presence Check

To determine whether Fwatch is running use this condition in scripting: localize "STR_USRACT_CHEAT_1" == "FWATCH" This string comes from the stringtable.csv and the Fwatch process replaces its value in the game memory. This modification will not take place if the STR_USRACT_CHEAT_1 is not in the stringtable.csv or if its value in the file has been changed (that is to say it's different from Cheat 1).


If the presence check does not work for you then:




New Fwatch is still compatible with the original presence check method (function fwatch_check.sqf) but I do not recommend using it as it doesn't work with addons and compressed multiplayer missions.


Using Commands

OFP Command
Fwatch Command Syntax
Data Types
Staying Within The Character Limitation
Memory Commands on a Dedicated Server
Source Directory for the FILE Commands
Source Directory for the New Commands
Allocation Limit
Error Handling

OFP Command

Fwatch can be called by any command that reads an external file (addAction, exec, loadFile or preprocessFile). These commands have limitation to 131 characters. However, Fwatch can't handle names longer than 127 characters. Crossing the limit will crash the game.

Additionally packed campaigns have limitation of 130 characters in which campaign name, mission name, island name and command must fit. Function ExecCommand works around this limitation.


Fwatch Command Syntax

Call to Fwatch starts with a colon and a command name (they consists of one or two parts). Following phrases are treated as arguments.
:name1 name2 parameter1 parameter2 parameter3 parameter4
for example:
loadFile ":file write test.db foo 1"
All command parameters are required unless stated otherwise. They must be written in the specified order.

If you want to pass a string with spaces put it into additional quotation marks. Otherwise every word is going to count as a separate parameter.
loadFile Format [":file read ""%1"" %2", "My File.txt", "foo"] - correct
loadFile Format [{:file read "%1" %2}, "My File.txt", "foo"] - correct
loadFile Format [":file read %1 %2", "My File.txt", "foo"] - incorrect
New commands that use only one, string-type parameter do not require this (it's indicated in the description).

Nine new commands (:io, :if, :clip getline, :mem bullets, :mem setgraphics and all CLASS-type) have a different system of passing arguments. Each parameter must start with an identifier (it can be a word or the first letter) followed up by a colon and then by value. :class list file:config.cpp c:CfgVehicles All arguments are optional unless stated otherwise. They can be written in any order.

Some new commands (like :sr) feature optional modes. To enable them capitalize letters in the command name.
:sr   default
:Sr   mode 1
:sR   mode 2
:SR   mode 1 and 2

Data Types

All input and output data are de facto strings. However, in command reference they are treated for what they represent.

For example: :info lock returns string containing an array. _lock = loadFile ":info lock"
_lock = "[true,false,false]"
To assign that array to a variable use call command: _lock = call loadFile ":info lock"
_lock = [true,false,false]
New commands that only return a string (e.g. :mem getworld) do not require execution of call as it would be redundant. See example code in the command description page.


Staying Within The Character Limitation

How to count used space: Example code:
loadFile Format [":sc ""%1"" ""%2""", "Hello World!", "Hi World!"]

Game formats it to:
loadFile ":sc ""Hello World!"" ""Hi World!"""

Fwatch receives:
:sc "Hello World!" "Hi World!"
which is 30 characters long
To work around the limitation use ExecCommand function.

Memory Commands on a Dedicated Server

Seven mem commands work on a dedicated server: :mem getworld
:mem getrespawntype
:mem getresside
:mem getdaylight
:mem getdifficulty
:mem setdifficulty
:mem bullets
Fwatch automatically recognises whether they are executed on a client or a server.

Source Directory for the FILE Commands

FILE type commands (e.g. :file write) save to and read from fwatch\mdb\ directory. File argument is converted to lowercase and all slashes and other invalid characters in it will be replaced with an underscore.

Source Directory for the New Commands

Default working directory for the CLASS, IGSE and CLIP type commands is: Users\<name>\(MP)missions\<current mission>\It's only valid for SP or MP Mission Editor.

To access game root directory start the path with ..\ :io f:..\res\bin\config.cpp Commands that modify files are restricted from operating outside except for these locations:
..\fwatch\idb
..\fwatch\tmp

..\in-game-script-editor
..\flashpointcutscenemaker
..\missioneditor3d
..\@addontest

fwatch\idb is a new common storage folder for save data.
fwatch\tmp is meant for temporary files and also stores data downloaded with :exe wget.

Commands that remove files actually move them to the recycle bin instead (unless the file is stored in fwatch\tmp - then it's deleted).

Allocation Limit

Commands :file read, :file read2, :file readvars, :file vars, :file wget may return indefinitely large arrays crossing the game's limit for a single allocation. Monitor size of the data you're working with. New commands (e.g. :io) work around the restriction.

As for string values the game does not seem to have a hard-coded limit for the text allocated from an external file.

Error Handling

34 commands return detailed error description   (show)

Error information is stored in two arrays:
The first one can be used to check if a particular command failed and the second - if recently there has been an error.

For keeping compatibility commands :file read, :file read2, :file write, :file awrite only utilize the second method (_fwatch_error).

The structure of the arrays is as follows: _fwatch_error also contains additional item - error description split into parts for logging purposes.

Examples: _ok = call loadFile ":io file:???"
? !(_ok select 0) : hint "error"
? (_ok select 1) in [5,6] : hint "system error"
player globalChat (_ok select 3)
_fwatch_error = [true,0,0,""]
_ok = call loadFile ":il ???"
_ok = call loadFile ":io f:mission.sqm e:2"
? !(_fwatch_error select 0) : hint "error"
? (_fwatch_error select 1) in [5,6] : hint "system error"
player globalChat (_fwatch_error select 3)


Input Commands Info

:input getjoystick

This commands reads joystick input using Windows API.
When you connect a controller system assigns an ID number to the device (from 0 to 15). If you reconnect device you'll still find it under the same ID number.

If you connect joystick in the middle of the game it takes about 10 seconds before it's detected by the command.

If you won't pass any arguments then the command automatically searches for a device starting from ID 0 to 15. Empty array is returned if no device was found.

Axis center position is 32767 for joysticks and 32511 for joypads.

According to the MSDN: POV values range 0 through 35,900. These values represent the angle, in degrees, of each view multiplied by 100.

For digital POV the values are:
3150004500
27000655359000
225001800013500

If the controller doesn't have POV then the value is zero

I've noticed that two devices from the same manufacturer do not necessarily share the same MID (manufacturer identification) number.


:mem getjoystick

This commands reads joystick input from the game memory.
Values are always returned, even if there is no joystick present (they will equal zero) unlike :input getjoystick which returns empty array.

Controller must be connected before launching the game otherwise it won't work.

Game uses device with the lowest ID number.


:input getkeys, :input agetkeys

These commands return array with pressed keyboard keys and mouse buttons. The former displays raw input while latter - a formatted input.

View source how values are displayed.

Pause Break key cannot be held (only single press).

Holding Right Alt is treated as if CTRL + ALT (LCTRL + RALT) were pressed. This is related to Windows regional keyboard settings. On some layouts Right Alt key is defined as Alt Graph which is equivalent to holding down the Ctrl and Alt keys together.

I've tested a couple of keyboard settings:
RALT + LCTRLRALT
US InternationalUS
CzechRussian
Finnish
French
German
Spanish
Polish
UK
Italian


More on AltGr you'll find on Wikipedia.


Animation Codes

Animation codes are enumerated animation classes from the configuration files.

Game process:
class X --> Class States --> all subclasses Where X is selected by moves property in the unit class. Default is CFGMovesMC.


Example:

class SoldierWB : Soldier
{
	moves = "CfgMovesMC";
};

class CfgMovesMC
{
	class States
	{
		class DeadState : Default 	//code 0
		class Stand : StandBase 	//code 1
		class StandVar2 : Stand 	//code 2
	};
};

Other configs may add new codes to the pool.
class CfgMovesMC
{
	class States
	{
		class DeadState : Default 	//was already defined
		class DeadState2 : DeadState 	//code 3
	};
};

Game loads configuration files starting from:
1. Main config (\bin\config.cpp)
2. Self-dependent addons (in alphabetical order).
3. Addons requiring other addons (in alphabetical order).
Animation codes may be different if you'll use addons which add new animations.

Code list for Operation Flashpoint: Resistance 1.96 including all original addons: view.
Use Animation Viewer script to preview them in the game.


Script & Function Library

Directory fwatch\data\ stores over a dozen of extra scripts and functions that take advantage of the Fwatch features. They are listed below, each with brief description. More information you'll find inside the files.

Functions

ConvertKeyString
CurrentLanguage
DateDifference
DateDifferenceInDays
ExecCommand
FormatDate
getAspectRatio
InitFLib
inKeys
MeasureTime
ModifyDate
path

Scripts

ErrorLog
InputMulti
MemMulti
onScreenTyping


Recommended Practices




Command list:

CLASS CLIPBOARD EXECUTE FILE IGSE INFO INPUT MEMORY STRING
class list c exe addontest file awrite i info date input agetkey mem bullets s
class modify clip copyfile exe preprocess file delete ic info debugout input agetkeys mem error sc
class modtok clip cutfile exe unpbo file dxdll if info resolution input getjoystick mem getcam sdom
class token clip execute exe wget file execute il info starttime input getkey mem getcinemaborder se
clip fromfile restart client file exists in info version input getkeys mem getcursor so
clip get restart server file modlist io input getmouse mem getdate sr
clip getline spig exe file qwrite ip input lock mem getdaylight src
clip pastefile file read ir input multi mem getdifficulty srng
clip size file read2 iw input setmouse mem getgraphics st
clip tofile file readvars mem getjoystick stok
file remove mem getmap string first
file renamemissions mem getnv string index
file vars mem getplayeraim string last
file wget mem getplayeranim string length
file write mem getplayerhatch string range
mem getplayerladder string toarray
mem getplayerview string tolower
mem getradiobox string toupper
mem getrespawntype stw
mem getresside sv
mem getscroll swul
mem getspeedkey s[
mem getworld
mem isdialog
mem masterserver
mem missioninfo
mem modlist
mem multi
mem setcursor
mem setdifficulty
mem setgraphics
mem setmap
mem setplayeraim
mem setplayeranim
mem setplayerhatch
mem setplayerladder
mem setplayerview
mem setradiobox
mem setrespawntype
mem setspeedkey




Command reference

commanddescription

class list Class names
Version:
1.13
Input:
file: - String - file name (required)
classpath: - Array (with strings) - list of outer classes
offset: - Integer - position of the class in the file in bytes
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
4 - Integer position in the classpath
5 - Array (with strings) - class names
6 - Array (with strings) - parent class names
7 - Array (with strings) - offsets
example:
_ok = call loadFile ":class list ""f:mission.sqm"" c:[Mission,Vehicles]"

Parses given file that contains classes and returns:
  • number of accessed outer classes
  • list of classes
  • list of inherited classes by those from the previous array
  • position of each class in the file (in bytes)
To get inside a nested class use "classpath" argument. If the offset was given then parser will jump to the given position in the text (in order to cut searching time).

class modify Modify class
Version:
1.13
Input:
file: - String - file name (required)
classpath: - Array (with strings) - list of outer classes
add: - String - name of the new class
rename: - String - rename source
to: - String - rename destination
delete: - String - name of the class to be removed
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
4 - Integer position in the class path
example:
_ok = call loadFile ":class modify ""f:config.cpp"" c:[CfgWeapons] ""a:M16 : Riffle"""

Performs selected operation on a given file with classes. It can be one of three: create new class, rename existing one or delete entire class.

class modtok Modify class property
Version:
1.13
Input:
file: - String - file name (required)
classpath: - Array (with strings) - list of outer classes
add: - String - property with value to be added
Append: - String - property with value to be appended
rename: - String - rename source
to: - String - rename destination
delete: - String - name of the property to be removed
index: - Integer - position of item in the array
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
4 - Integer position in the class path
example:
_ok = call loadFile ":class modtok ""f:config.cpp"" c:[CfgWeapons,M16] a:optics=0"

Performs selected operation on a given file with classes. It can be one of four: create new property, append value, rename or remove. If property you want to add already exists then its value will be overwritten. If parameter index was specified then the operation is performed on an item in the property value array.

class token Class properties
Version:
1.13
Input:
file: - String - file name (required)
classpath: - Array (with strings) - list of outer classes
offset: - Integer - position of the class in the file in bytes
token: - String - search subject
nowrap: - Nothing - disable wrapping
nodoublewrap: (nd) - Nothing enable selective wrapping
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
4 - Integer position in the class path
5 - String - class offset
6 - Array (with strings) - properties names
7 - Array (with strings) - properties values
8 - Array (with strings) - properties values lengths
9 - Array (with arrays with strings) - properties values segmented
example:
_ok = call loadFile ":class token ""f:mission.sqm"" c:[Mission,Groups,Item0,Vehicles,Item0]"

Returns list of properties from the specified class in the given file. If offset was passed then the parser will jump to the given position in the text (in order to cut searching time). If parameter :token was specified then only that property is returned. All values are wrapped in quotation marks. Use nowrap: to disable it or nodoublewrap: to disable wrapping for values that already have quotation marks. Multi-dimensional arrays are not supported. Values longer than 100 characters are split and stored in a separate array.

c Clipboard copy
Version:
1.12
Input:
String
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_status = loadFile ":c Hello World!"

Copies given text to the Windows clipboard. Use :C to append. Passed \t are replaced with tabulators and \n with new lines. It's not required to pass string inside a quote. Input text mustn't exceed 124 characters.

clip copyfile Copy files to clibpoard
Version:
1.14
Input:
String filenames
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_ok = call loadFile ":clip copyfile mission.sqm"

Copy file names to the Windows clipboard. Argument is list of files separated by spaces. If file has space in its name then wrap it in quotation marks. Path info you'll find here.

clip cutfile Cut files to clibpoard
Version:
1.14
Input:
String filenames
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_ok = call loadFile ":clip cutfile mission.sqm"

Copy file names to the Windows clipboard with "move" instruction. Argument is list of files separated by spaces. If file has space in its name then wrap it in quotation marks. Path info you'll find here.

clip execute Command from clipboard
Version:
1.13
Input:
String to append (optional)
Output:
Any
example:
_return = call loadFile ":clip execute"

Parses Fwatch command stored in the Windows clipboard. Passed argument will be appended to the text from clipboard. Output is the same as in the target command. :clip execute itself does not return any errors.

clip fromfile Load file to clipboard
Version:
1.13
Input:
1: String file name
2: String mode ("a") (optional)
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_ok = call loadFile ":clip fromfile ""Clipboard Text.txt"""

Reads text from selected file and copies it to the Windows clipboard. Use mode "a" to append.

clip get Clipboard text
Version:
1.12
Input:
Integer initial position (optional)
Integer number of characters to return (optional)
Output:
String
example:
_text = loadFile ":clipboard get"

Returns text stored in the Windows clipboard.

clip getline Clipboard lines
Version:
1.13
Input:
:start - Integer - range start (optional)
:end - Integer - range end (optional)
:limit - Integer - character limit for each line (optional)
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
4 - Array (with strings) text
example:
_ok = call loadFile ":clip getline"

Returns given range of lines (all if not specified) from the text stored in the Windows clipboard. If parameter:Limit starts with a capital letter then the command returns full lines (instead of just cutting them) segmented based on given character limit and put into additional arrays.

clip pastefile Paste files from clipboard
Version:
1.14
Input:
(optional) String destination path
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
4 - String operation type ("copy", "move", "link", "scroll", "none")
5 - Array files (with sub-arrays):
0 - String path to file
1 - Array error information
example:
_ok = call loadFile ":clip pastefile"

Copies or moves files that were stored in the Windows clipboard. Path info you'll find here. Clipboard is emptied after successful "move" operation. Pass argument ?file to get list of files without performing any file operation.

clip size Clipboard text length
Version:
1.12
Input:
Nothing
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
4 - Integer size of the text in the clipboard
5 - Integer number of lines
example:
_ok = call loadFile ":clip size"

Returns number of characters and number of lines stored in Windows clipboard.

clip tofile Save clipboard text
Version:
1.13
Input:
1: String file name
2: String mode ("a", "w") (optional)
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_ok = call loadFile ":clip tofile ""Clipboard Text.txt"""

Creates a file and writes text from clipboard into it. Won't overwrite file unless "w" was passed. Use mode "a" to append text if the file already exists.

exe addontest Addon Tester mod
Version:
1.13
Input:
1: String arguments ("check", "close" or "-unpbo=") (optional)
2: Integer process ID (optional)
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
4 - Integer process ID
example:
_ok = call loadFile ":exe addontest"

Launches external program meant to supplement @addontest mod. Pass check with process ID to see if the program is still running. Use close with process ID to terminate the program. Argument -unpbo= along with file name will make the program extract pbo archive from the \@addontest\addons directory.

exe preprocess Preprocess file
Version:
1.14
Input:
String files
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
4 - Integer process ID
example:
_ok = call loadFile ":exe preprocess config.cpp config2.cpp"

Launches external program which preprocesses selected file. First parameter is input file and second is output file. Path info you'll find here. If you pass only one filename then program will preprocess without writing (syntax check). Add parameter -merge to add contents to an existing file.

When the program is finished it writes array with results to the fwatch\tmp\<num>.pid where <num> is process id. Contents are as follows:
  • 0 - Integer program error code
  • 1 - Integer preprocess error code
  • 2 - Integer errno code
  • 3 - String error description
  • 4 - String last processed line number
  • 5 - String last processed text
  • 6 - String data size in bytes


Pass check with process ID to see if the program is still running. Use close with process ID to terminate the program.

exe unpbo Extract pbo file
Version:
1.14
Input:
String file name
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
4 - Integer process ID
example:
_ok = call loadFile ":exe unpbo Missions\01takethecar.abel.pbo"

Launches external program for unpacking PBO files. Argument is a path to the file starting from the game root directory. Additionally you can pass -F <filename1,...> <pboname> to get only specific files (will be faster). Archives are extracted to the fwatch\tmp\ directory. When the program is finished, its result number (0 - success, 1 - failure) is written to the fwatch\tmp\<num>.pid where <num> is process id.

Pass check with process ID to see if the program is still running. Use close with process ID to terminate the program.

exe wget Download data
Version:
1.13
Input:
String arguments
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
4 - Integer process ID
example:
_ok = call loadFile ":exe wget http://www.site.domain/something.sqs"

Launches external program which downloads data under the specified web address. File is saved to the fwatch\tmp\ directory. Pass check with process ID to check if the program is still running. Use close with process ID to terminate the program. Other arguments are passed along to the program. When the program is finished result number is saved to the fwatch\tmp\<num>.pid where <num> is process id. Wget manual you'll find here.

restart client Relaunch game
Version:
1.11
Input:
String arguments (optional)
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
call loadFile ":restart client"

Launches external program which terminates current game process and then creates a new one with given arguments. Parameters previously passed to the game are transferred to the new instance (except -mod and -connect). It's not required to pass string inside a quote. Input text mustn't exceed 109 characters. Operations are documented in a log file in the fwatch\data\ directory.

restart server Relaunch dedicated server
Version:
1.11
Input:
(optional) String arguments
Output:
Nothing
example:
loadFile ":restart server"

Signals to the Fwatch process to terminate current server instance and create a new one with given arguments. Executable (OFPR_Server.exe, ColdWarAssault_Server.exe) must be in the game directory. Command should be executed only on the server side. It's not required to pass string inside a quote. Input text mustn't exceed 109 characters.

spig exe Launch SPIG program
Version:
1.11
Input:
1: String executable name
2: String file name
Output:
Array:
0 - Integer result code
example:
loadFile ":spig exe spig2sqm.exe spig_sqm1.txt"

Command dedicated for the SPIG script. Executes given program from the Set-Pos-In-Game\Exe\. Second argument is a file to be processed from fwatch\mdb\ folder. In case of an error it returns a string - error message.

file awrite Append variable
Version:
1.0
Input:
1: String file name
2: String variable name
3: Any variable value
Output:
_fwatch_error
Integer status
example:
_status = call loadFile Format [":file awrite test.db %1 %2", "foo", [3,4]]

Appends value to the specified variable in the given file in fwatch\mdb\. If variable doesn't exist then it will be created. Returns 1 on success and -1 on failure.

file delete Remove file
Version:
1.0
Input:
String file name
Output:
Integer status
example:
_status = call loadFile Format [":file delete test.db"]

Removes given file from fwatch\mdb\. Returns 1 on success and -1 on failure.

file dxdll DxDLL presence
Version:
1.1
Input:
Nothing
Output:
Bool
example:
_dxdll = call loadFile ":file dxdll"

Check if d3d8.dll file is in the game directory.

file execute Command from file
Version:
1.13
Input:
String file
Output:
Any
example:
_return = call loadFile ":file execute temp.txt"

Parses Fwatch command from the selected text file. Use capital:F to remove the file afterwards. Output is the same as in the target command. :file execute itself does not return any errors. Use this command via ExecCommand.sqf function.

file exists File existence
Version:
1.0
Input:
String
Output:
Integer
example:
_file = call loadFile ":file exists test.db"

Checks if specified file is in the fwatch\mdb\ directory. Returns 1 if there is and -1 if not.

file modlist List of modfolders
Version:
1.11
Input:
Nothing
Output:
Array (strings) folder names
example:
_mods = call loadFile ":file modlist"

Returns list of modfolders in the game directory.

file qwrite Write variable quickly
Version:
1.0
Input:
1: String file name
2: String variable name
3: Any variable value
Output:
Integer status
example:
_success = call loadFile Format [":file qwrite test.db %1 %2", "foo", 1]

Saves variable to the given file in fwatch\mdb\ without checking if same variable is already there. Returns 1 on success and -1 on failure.

file read Read variable
Version:
1.0
Input:
1: String file name
2: String variable name
Output:
_fwatch_error
Any
example:
_x = call loadFile Format [":file read test.db %1", "foo"]

Returns value from the specified variable in the given file in fwatch\mdb\. Returns -1 on failure.

file read2 Read variable from any source
Version:
1.1
Input:
1: String file
2: String variable name
Output:
_fwatch_error
Any
example:
_var = call loadFile ":file read2 flashpoint.cfg language"

It works similar to :file read with the difference that the source folder is not /fwatch/mdb/ but the game root directory. In case of error it returns -1. Changes _fwatch_error variable (more info here).

file readvars Read all variables
Version:
1.0
Input:
String file name
Output:
Integer status
example:
_result = call loadFile ":file readvars test.db"

Returns code with all variables and their values (in a var=val; format) from the given file in fwatch\mdb\. Status variable is 1 on success and -1 on failure.

file remove Remove variable
Version:
1.0
Input:
1: String file name
2: String variable name
Output:
Integer
example:
_status = call loadFile Format [":file remove test.db foo"]

Removes specified variable from the given file in fwatch\mdb\. Returns 1 on success and -1 on failure.

file renamemissions Replace MP missions
Version:
1.11
Input:
String name1
String name2
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_ok = call loadFile ":file renamemissions MPMissions@bis MPMissions@fdf"

Renames MPMissions directory to name1 and name2 directory to MPMissions. Do not pack mission (PBO) which uses this command, otherwise it won't work.

file vars Variable names
Version:
1.0
Input:
String file name
Output:
Array (strings)
example:
_array = call loadFile Format [":file vars test.db"]

Returns array of all variable names stored in the given file in fwatch\mdb\. Returns -1 on failure.

file wget Download data
Version:
1.0
Input:
String URL
Output:
Any
example:
_data = loadFile ":file wget http://www.site.domain/something.sqs"

I recommend to use :exe wget instead. Launches external program which returns data under the specified web address. You must wait at least one second between calls or the command returns -1.

file write Write variable
Version:
1.0
Input:
1: String file name
2: String variable name
3: Any variable value
Output:
_fwatch_error
Integer status
example:
_status = call loadFile Format [":file write test.db %1 %2", "foo", 1]

Saves variable (overwrites) to the given file in fwatch\mdb\. Returns 1 on success and -1 on failure.

i IGSE write
Version:
1.1
Input:
String text
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_ok = call loadFile ":i Hello World!"

I recommend to use :iw instead.

Overwrites line in a file pointed by the :ip. Use :I to append. Path info you'll find here. It's not required to pass string inside a quote. Input text mustn't exceed 124 characters. Passed \t are replaced with tabulators. Use negative line number or zero to edit line relative from the end.

To access special functions pass one of the arguments listed below:
  • =newline= - creates new line after the selected one
  • =precedenewline= - creates new line before the selected one
  • =copyline= - duplicates selected line
  • =deleteline= - removes selected line
  • =clearline= - removes all characters in the selected line
  • =moveup= - swaps selected line with the previous one
  • =movedown - swaps selected line with the line below
  • =clipboard - copies text from the clipboard to the selected line
  • =precedeclipboard= - creates a new line (before the selected one) and copies clipboard content there
  • =followclipboard= - creates a new line (after the selected one) and copies clipboard content there


ic IGSE Copy
Version:
1.13
Input:
1: String source file (optional)
2: String destination file (optional)
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_ok = call loadFile ":ic mission.sqm mission.backup"

Copies selected file to the the given location with specified new name. If arguments were not passed then they are read from the pointer file (if only one was passed then it's treated as destination). Use :iC to allow overwriting. You may copy files from outside to a non-restricted location but cannot copy in the opposite direction.

if IGSE find
Version:
1.12
Input:
file: - String - file name
start: - Integer - line range start
end: - Integer - line range end
offset: - String - initial position in bytes
limit: - Integer - limit number of results
target: - String - text to search for
column: - Integer - position in the line
replace: - String - text to replace to
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
4 - Integer number of occurrences
5 - Array line numbers
6 - Array (with sub-arrays with integers) positions in the lines
7 - String last position in bytes
8 - Integer last line number
example:
_ok = call loadFile ":if ""f:mission.sqm"" ""t:soldierwb"""

Searches for occurences of a given text in the selected file. Use :If to match whole words and :iF for case sensitivity. Path info you'll find here. If the file name argument was not specified then the command will read it from the pointer file.

Use parameter column: to find only occurrences that start at the given position in a line. With parameter replace: command will rewrite the file replacing all occurrences to a given text.

If you're using range instead of searching entire file at once then the position argument can be used to speed up loading (aka start reading from the last position) - range start number must be also passed to make it work.

il IGSE list
Version:
1.1
Input:
(optional) String additional path
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
4 - Array (strings) file names
5 - Array file attributes:
0 - String name without extension
1 - String extension
2 - Array (strings) attributes
3 - Array (mixed) file creation time
4 - Array (mixed) file last access time
5 - Array (mixed) file last write time
6 - Array size:
0 - Integer bytes
1 - Integer kilobytes
2 - Integer megabytes
example:
_files = call loadFile ":il *"

Returns list of files and attributes. Path info you'll find here. Optional parameter may contain a wildcard (*). It's not required to pass string inside a quote. Input text mustn't exceed 123 characters. If nothing was passed then command reads path from the pointer file. Use :Il to return attributes in system time instead of local. File size is divided intro three values (full megabytes and kilobytes are subtracted from the total size). Command will not include files with names over 122 characters.

in IGSE new file
Version:
1.11
Input:
1: String file name
2: (optional) String mode
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_ok = call loadFile Format [":in ""%1""", "new.txt"]

Creates a new file with given mode (default is "a"). Path info you'll find here. Input text mustn't exceed 121 characters (in case of one param). Use :In to read first argument from the pointer file. List of modes:
  • "a" - creates file if it doesn't exists
  • "a-" - creates file if it doesn't exists; otherwise returns error message
  • "w" - trashes existing file and creates a new one
  • "d" - trashes given file
  • "r" - determines if a file exists
  • "rd" - determines if a directory exists
  • "md" - creates a new directory
  • "md-" - creates a new directory; returns error if it already exists


io IGSE load
Version:
1.1
Input:
file: - String file name
start: - Integer line range start
end: - Integer line range end
offset: - Integer initial position in bytes
limit: - Integer character limit
clipboard: - Nothing clipboard mode
execute: - Nothing return raw text
delete: - Nothing remove file after reading
wait: - Integer keep trying to open file for given time (in ms)
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
4 - Array lines (with sub-arrays):
0 - String text line
1 - String position in bytes
2 - Integer length
5 - Integer number of lines that were read
6 - Bool if last line ended with \n
7 - Bool if end of file was reached
8 - String last position in bytes
example:
_ok = call loadFile Format [":io ""f:%1"" e:%2", "init.sqs", 150]

Returns lines from the selected text file. Path info you'll find here. If the file name was not specified then command will read it from the pointer file.

Use argument Limit: (capital first letter) in order to segment lines (will be put into additional sub-array). If argument clipboard: was passed then instead of returning lines it will copy them to the Windows clipboard. Use clipboard:n to add new line at the end of each line. Use Clipboard: (capital) to append to the clipboard.

I recommend not to read an entire file at once (use range arguments). Position in the file (in bytes) can be used to speed up loading (aka start reading from the last position) - range start number must be also passed to make it work.

ip IGSE point
Version:
1.1
Input:
String arguments
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_ok = call loadFile Format [":ip %1?%2", "init.sqs", 1]

I recommend to use ExecCommand.sqf for working around character limitation instead of :ip because the latter does not stack.

Saves two arguments to a pointer file which is used by other IGSE commands. Total length of the input mustn't exceed 123 characters. It's not required to pass string inside a quote. Parameters are separated by '?' (question mark). By default command replaces values. Use :Ip to append to/keep first argument and :iP - append to/keep second argument.

First argument is meant to be a path. If you pass "<" (less than) you will remove characters from the end until last slash. If "<<" - until second last slash and so on.

ir IGSE rename
Version:
1.11
Input:
1: String source file (optional)
2: String destination file (optional)
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_ok = call loadFile Format [":ir ""%1"" ""%2""", old.txt, new.txt]

Changes name of a given file. Path info you'll find here. If arguments were not passed then they are read from the pointer file (if only one was passed then it's treated as destination).

iw IGSE Write
Version:
1.14
Input:
1: String file name
2: String text to write
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_ok = call loadFile ":iw ""My File.txt"" Hello World!"

Writes given text at the end (creates a new line) of the selected file. Second argument must not be wrapped in quotation marks. Use mode :Iw to append to the last line. Use mode :iW to cancel replacing \t with tabulators and \n with new lines.

To overwrite/append to a specific line add angle bracket and a number (e.g. >1) at the end of the first argument. Use negative line number or zero to edit line relative from the end. Special functions (see :i) are available after specifying line number. Alternatively use asterisk instead of bracket to cancel them.

info date Date and time
Version:
1.1
Input:
(optional) String switch to system time ("systime")
OR
Array date
Output:
Array:
0 - Integer year
1 - Integer month
2 - Integer day
3 - Integer day name (0 to 6)
4 - Integer hour
5 - Integer minutes
6 - Integer seconds
7 - Integer milliseconds
8 - Integer time zone
9 - Bool is system time
example:
_date = call loadFile ":info date"

Gets current date, time and time zone information from Windows. Pass string to return system time instead of local time. Pass an existing array with date in order to reconvert it (day name will be corrected if the date was modified) Time zone variable is the difference from GMT in minutes. It does not represent current time but Windows time zone setting.

info debugout Debug
Version:
1.0
Input:
String
Output:
Integer (1)
example:
loadFile ":info debugout testing"

Output Win32 debug string.

info resolution Screen resolution
Version:
1.13
Input:
Nothing
Output:
Array:
0 - Integer width
1 - Integer height
2 - Array window:
0 - Integer X-axis coordinate
1 - Integer Y-axis coordinate
2 - Integer width
3 - Integer height
3 - Array game:
0 - Integer X-axis coordinate
1 - Integer Y-axis coordinate
2 - Integer width
3 - Integer height
example:
_array = call loadFile ":info resolution"

Returns Windows desktop resolution, game window position and size, rendering area position and size.

info starttime Game start date
Version:
1.13
Input:
(optional) String system time ("systime")
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
4 - Array date
0 - Integer year
1 - Integer month
2 - Integer day
3 - Integer day name (0 to 6)
4 - Integer hour
5 - Integer minutes
6 - Integer seconds
7 - Integer milliseconds
8 - Integer time zone
9 - Bool is system time
example:
_ok = call loadFile ":info starttime"

Returns information when the game process started.

info version Fwatch version
Version:
1.0
Input:
(optional) String ("extended")
Output:
Float
OR
Array:
0 - Float version
1 - Bool is Cold War Assault
2 - Bool is dedicated server
3 - Bool (reserved for future use)
4 - Float game executable version
example:
_version = call loadFile ":info version"

Returns Fwatch version number. Pass an extra parameter so the command will return an array with additional information.

input agetkey Is key pressed
Version:
1.0
Input:
String
Output:
Integer
example:
_x = call loadFile ":input agetkey X"

Asynchronous version of :input getkey. Does not work with all the keys (use :input agetkeys instead).

input agetkeys Keyboard input
Version:
1.0
Input:
(optional) String side recognition ("side")
Output:
Array (strings)
example:
_keys = call loadFile ":input agetkeys"

This is an asynchronous version of the :input getkeys.

input getjoystick Joystick input
Version:
1.1
Input:
(optional) Integer - joystick ID.
Output:
Array:
0 - Array (strings) axes names (X, Y, Z, R, U, V)
1 - Array (integers) axes values (from 0 to 65535)
2 - Integer number of buttons
3 - Array (strings) buttons and POV
4 - Array POV
0 - String type (nopov, digital, analog)
1 - Integer value (from 0 to 65535)
5 - Array identification numbers
0 - Integer assigned system ID
1 - Integer manufacturer ID
2 - Integer product ID
example:
_joystick = call loadFile ":input getjoystick"

Reads joystick input using Windows API. In case of error it returns empty array. More information you'll find in the Input Commands Info section. This command may not be entirely reliable.

input getkey Is key pressed
Version:
1.0
Input:
String
Output:
Integer
example:
_x = call loadFile ":input getkey X"

Checks if given keyboard key is currently pressed. Returns 1 if so and -1 otherwise. Does not work with all the keys (use :input getkeys instead).

input getkeys Keyboard input
Version:
1.0
Input:
(optional) String side recognition ("side")
Output:
Array (strings)
example:
_keys = call loadFile ":input getkeys"

Returns array of all keyboard keys and mouse buttons presses. If argument was passed it will return which (left or right) SHIFT, ALT, CTRL were pressed. More information you'll find in the Input Command Info section.

input getmouse Mouse input
Version:
1.0
Input:
Nothing
Output:
Array:
0 - Integer X-axis coordinate
1 - Integer Y-axis coordinate
2 - Bool is LMB pressed
3 - Bool is RMB pressed
4 - Bool is MMB pressed
example:
_mouse = call loadFile ":input getmouse"

Returns position of the Windows mouse cursor and state of the buttons. The latter work asynchronously, so if you query the state every 5 seconds and the button was clicked during this time the state will be true even if the button is not down at the moment.

input lock Num, Caps, Scroll lock
Version:
1.1
Input:
Nothing
Output:
Array
0 - Bool Num Lock
1 - Bool Caps Lock
2 - Bool Scroll Lock
example:
_lock = call loadFile ":input lock"

Command returns state (on / off) of the numeric keypad lock, capital letters lock and scrolling lock.

input multi Multiple input sources
Version:
1.12
Input:
(optional) Integer joy ID
Output:
Array:
0 - Array (strings) keyboard keys
1 - Array (strings) keyboard keys (asynchronous)
2 - Array (bools) lock keys
3 - Array mouse:
0 - Integer Windows cursor X-axis coordinate
1 - Integer Windows cursor Y-axis coordinate
2 - Float dialog cursor X-axis coordinate
3 - Float dialog cursor Y-axis coordinate
4 - Integer mouse scroll counter
4 - Array joystick:
0 - Float axis X (from -1 to 1)
1 - Float axis Y (from -1 to 1)
2 - Float rudder (from -1 to 1)
3 - Float thrust (from -1 to 1)
4 - Array (strings) buttons and POV
5 - Integer POV angle (0, 45, 90, 135, 180, 225, 270, 315)
5 - Array WINAPI joystick:
0 - Array (strings) axes names (X, Y, Z, R, U, V)
1 - Array (integers) axes values (from 0 to 65535)
2 - Integer number of buttons
3 - Array (strings) buttons and POV
4 - Array POV
0 - String type (nopov, digital, analog)
1 - Integer value (from 0 to 65535)
5 - Array identification numbers
0 - Integer assigned system ID
1 - Integer manufacturer ID
2 - Integer product ID
6 - Array speed key:
0 - String movement type
1 - Integer raw value "fast"
2 - Integer raw value "forward"
3 - Integer raw value "slow"
4 - Integer raw value "reverse"
example:
_input = call loadFile ":input multi"

Use this command ONLY via InputMulti.sqs script.

Combination of :input getkeys, :input agetkeys, :input lock, :input getmouse, :mem getcursor, :mem getscroll, :mem getjoystick, :input getjoystick and :mem getspeedkey. Side keys (e.g. LSHIFT, RSHIFT) are returned. WINAPI joystick input is disabled by default. Pass number from 0 to 15 to access specific device or -1 for search mode.

input setmouse Set cursor position
Version:
1.0
Input:
1: Float - X-axis coordinate
2: Float - Y-axis coordinate
Output:
Nothing
example:
loadFile ":input setmouse 500 300"

Sets Windows mouse cursor position to the given coordinates.

mem bullets Projectiles properties
Version:
1.14
Input:
gravacc: - Float - gravity acceleration
bullet: - Float - shotBulet lifetime
shell: - Float - shotShell lifetime
rocket: - Float - shotMissile, shotRocket lifetime
bomb: (o) - Float - shotMissile, shotRocket with thrustTime=0 lifetime
smoke: (m) - Float - shotSmoke lifetime
flare: - Float - shotIlluminating lifetime
flareduration: (fd) - Float - shotIlluminating light duration
pipebomb: - Float - shotPipeBomb lifetime
timebomb: - Float - shotTimeBomb lifetime
Output:
Array:
0 - Float gravity acceleration
1 - Float bullet lifetime
2 - Float shell lifetime
3 - Float rocket lifetime
4 - Float bomb lifetime
5 - Float smoke lifetime
6 - Float flare lifetime
7 - Float flare light duration
8 - Float pipe bomb lifetime
9 - Float time bomb lifetime
example:
_properties = call loadFile ":mem bullets b:6 s:30"

Changes projectiles properties by modifying values in the memory and returns current numbers. Acceleration is in m/s. Lifetime values are in seconds. Changes do not affect existing bullets. In multiplayer each machine creates projectile according to local settings but effects are synchronized to the computer on which the projectile was fired. Changes are carried between missions.

Subtracting flare duration from its lifetime gives you delay before the flare is lit. Flares immediately lose momentum when lit.

mem error Error message
Version:
1.12
Input:
(optional) String special mode ("clip", "array")
Output:
String
example:
hint loadFile ":mem error"

Reads first 512 characters of the OFP scripting error text from the memory. Command has to be executed when the message is visible.

Use parameter clip to copy error to the clipboard (command will return error array instead). Use parameter array with additional number (default 100) to segment message (command will return array with strings instead).

mem getcam Camera position
Version:
1.11
Input:
Nothing
Output:
Array:
0 - Float X-axis coordinate
1 - Float Y-axis coordinate
2 - Float Z-axis coordinate absolute
3 - Float direction
4 - Float pitch
5 - Float field of view
6 - Bool is a cutscene rolling
example:
_camera = call loadFile ":mem getcam"

Reads current camera values from the memory. When the camera sticks to the ground (<0.1m) then there's 0.05m disparity in height compared to the numbers returned by getPosASL and getPos2.sqf measurements.

mem getcinemaborder Is cutscene border on
Version:
1.11
Input:
Nothing
Output:
Bool
example:
_border = call loadFile ":mem getcinemaborder"

Reads value from the memory indicating whether cutscene borders are enabled.

mem getcursor Cursor position
Version:
1.1
Input:
Nothing
Output:
Array:
0 - Float X-axis coordinate
1 - Float Y-axis coordinate
example:
_cursor = call loadFile ":mem getcursor"

Reads dialog cursor position from the memory. X:0.5 Y:0.5 is the center of the screen.

mem getdate Mission date
Version:
1.11
Input:
Nothing
Output:
Array:
0 - Integer year
1 - Integer month (1 to 12)
2 - Integer day
3 - Integer day name (0 to 6)
4 - Integer day of the year (1 to 365)
example:
_date = call loadFile ":mem getdate"

Reads date from the buffer. Values are written to the buffer when user looks at the watch (directly or through map screen) or when missionStart command is executed.

mem getdaylight Amount of light
Version:
1.11
Input:
Nothing
Output:
Array:
0 - Float time of day (0 to 0.75)
1 - Float brightness (0.05 to 1)
example:
_light = call loadFile ":mem getdaylight"

Reads values from memory regarding current amount of light. First value reaches peak at noon and goes to zero when it's fully dark. Second value is the general amount of brightness - it's month dependent. Vehicle lights are enabled around [0.33, 0.05].

mem getdifficulty Difficulty options
Version:
1.13
Input:
1: String or Bool source ("sp" or "false", "mp" or "true")
2: String or Bool difficulty mode ("cadet" or "true", "veteran" or "false")
Output:
Array:
0 - Bool Extended armor
1 - Bool Friendly TAG
2 - Bool Enemy TAG
3 - Bool Extended HUD info
4 - Bool Auto report
5 - Bool Extended map info
6 - Bool Weapon crosshair
7 - Bool Auto guide AT
8 - Bool Clock indicator
9 - Bool 3rd person view
10 - Bool Rifle bullet tracers
11 - Bool Super AI
example:
_difficulty = call loadFile Format [":mem getdifficulty sp %1", cadetMode]

Reads game difficulty settings from the memory. First parameter does not make a difference on a dedicated server. Second parameter does not make a difference in multiplayer on client (current settings are always returned). In case of an error command returns empty array.

mem getgraphics Video settings
Version:
1.1
Input:
Nothing
Output:
Array:
0 - Integer resolution X
1 - Integer resolution Y
2 - Integer refresh rate
3 - Bool multitexturing
4 - Bool object shadows
5 - Bool vehicle shadows
6 - Bool cloudlets
7 - Bool blood
8 - Float brightness (0.4 to 1.8)
9 - Float gamma correction (0.5 to 2.3)
10 - Float framerate (10 to 30)
11 - Float visual quality (0.05 to 0.5)
12 - Float visibility (500 to 5000)
13 - Float terrain detail (3.125, 6.25, 12.5, 25, 50)
example:
_graphics = call loadFile ":mem getgraphics"

Reads users' graphics settings from the memory. Refresh rate value equals zero in windowed mode. Multitexturing value isn't read properly in a CWA version (to fix in the next version).

mem getjoystick Joystick input
Version:
1.1
Input:
Nothing
Output:
Array:
0 - Float axis X (from -1 to 1)
1 - Float axis Y (from -1 to 1)
2 - Float rudder (from -1 to 1)
3 - Float thrust (from -1 to 1)
4 - Array (strings) buttons and POV
5 - Integer POV angle (0, 45, 90, 135, 180, 225, 270, 315)
example:
_joystick = call loadFile ":mem getjoystick"

Reads joystick input from the memory. More information you'll find in the Input Commands Info section.

mem getmap Is map displayed
Version:
1.1
Input:
Nothing
Output:
Bool
example:
_map = call loadFile ":mem getmap"

Reads value from the memory indicating whether 2D island map is displayed.

mem getnv Is NV displayed
Version:
1.11
Input:
Nothing
Output:
Bool
example:
_isNV = call loadFile ":mem getnv"

Reads value from the memory indicating whether player is using nightvision goggles.

mem getplayeraim Aim angle
Version:
1.12
Input:
Nothing
Output:
Array:
0 - Float crosshair target direction
1 - Float gun horizontal offset
2 - Float crosshair target pitch (-0.96 to 0.96)
3 - Float gun pitch
4 - Float gun velocity horizontal
5 - Float gun velocity vertical
example:
_aim = call loadFile ":mem getplayeraim"

Reads player's aim angle values from the memory. Horizontal offset is the difference from player's direction in degrees. Value range for gun angles depends on weapon configuration. Pitch values are raw (not in degrees). See demo mission for convertion method. Gun offset and pitch are equal 0 and 1 respectively when player is in a vehicle.

mem getplayeranim Player animation
Version:
1.1
Input:
Nothing
Output:
Integer
example:
_anim = call loadFile ":mem getplayeranim"

Read player's soldier current animation code from the memory. More information you'll find in the Animation Codes section.

mem getplayerhatch Player's vehicle hatch
Version:
1.13
Input:
(optional) String seat ("driver", "gunner", "commander")
Output:
Array:
0 - Integer driver hatch
1 - Integer gunner hatch
2 - Integer commander hatch
OR
Integer hatch status
0 - player not in vehicle
1 - closed hatch
2 - opened hatch
example:
_state = call loadFile ":mem getplayerhatch driver"

Reads values from the memory that determine if a hatch is opened or closed in player's vehicle and returns array. If extra argument was passed then command will instead return a number - status of the specified seat.

mem getplayerladder Position on a ladder
Version:
1.13
Input:
Nothing
Output:
Array:
0 - Float position (from 0 to 1)
1 - Integer ladder ID
example:
_ladder = call loadFile ":mem getplayerladder"

Reads from the memory player's position on a ladder that he's currently climbing and ladder identification within the building (0 - first ladder, 1 - second etc.).

mem getplayerview Player's camera view
Version:
1.11
Input:
Nothing
Output:
Array
0 - String current view ("internal", "gunner", "external", "group")
1 - String toggled view ("internal", "gunner", "external", "group")
example:
_view = call loadFile ":mem getplayerview"

Reads player's camera mode value from the memory. A view type may be toggled but not displayed.

mem getradiobox Is radio menu shown
Version:
1.13
Input:
Nothing
Output:
Bool
example:
_isRadio = call loadFile ":mem getradiobox"

Reads from the memory value indicating if radio menu is displayed.

mem getrespawntype Respawn type
Version:
1.11
Input:
Nothing
Output:
Integer type (0 to 4)
example:
_respawn = call loadFile ":mem getrespawntype"

Reads value from the memory indicating player's respawn mode in a multiplayer mission. Details you'll find here.

mem getresside Resistance side
Version:
1.11
Input:
Nothing
Output:
String side ("west", "east", "everybody", "nobody")
example:
_resistance =  loadFile ":mem getresside"

Reads value from the memory indicating with whom resistance units are friendly.

mem getscroll Mouse scroll
Version:
1.1
Input:
Nothing
Output:
Integer
example:
_scroll = call loadFile ":mem getscroll"

Reads mouse scroll counter from the memory. It increases by 1 every time user rolls wheel forward and decreases when rolls backward.

mem getspeedkey Vehicle acceleration
Version:
1.13
Input:
optional String raw mode ("raw")
Output:
String movement type ("reverse", "stop", "slow", "forward", "fast")
OR
Array:
0 - Integer raw value "fast"
1 - Integer raw value "forward"
2 - Integer raw value "slow"
3 - Integer raw value "reverse"
example:
_type = loadFile ":mem getspeedkey"

Reads from the memory values related to forward/backward keyboard presses and estimates player's vehicle movement type. Values are zero if dialogs is displayed. If an extra parameter was passed the command returns array with raw values instead.

mem getworld Island name
Version:
1.1
Input:
Nothing
Output:
String
example:
_island = loadFile ":mem getworld"

Reads island shortcut name from the memory.

mem isdialog Are dialogs displayed
Version:
1.13
Input:
Nothing
Output:
Integer number of dialogs
example:
_dialogNum = call loadFile ":mem isdialog"

Returns number of currently displayed dialogs from the memory. Escape menu, chat input, player list and custom dialogs increment this number by one. Multiple custom dialogs still count as one.

mem masterserver Get/set master server
Version:
1.13
Input:
1: String operation ("get" or "set")
2: String address replacing gamespy(optional)
3: String address replacing udpsoft (optional)
Output:
Array:
0 - String gamespy address
1 - String udpsoft address
OR
Bool operation success
example:
_array = call loadFile ":mem masterserver get"

Reads or modifies master server address in the memory. Command only works in the main menu. Returns array for "get" operation and bool for "set". Maximum length for the second argument is 63 characters and for third - 18 characters. I haven't noticed any functionality regarding udpsoft but I've decided to keep it just in case.

mem missioninfo Mission names
Version:
1.14
Input:
Nothing
Output:
Array:
0 - String mission name
1 - String island name
2 - String mission folder name
3 - String briefing title
4 - String briefing description
example:
_names = call loadFile ":mem missioninfo"

Reads information from the memory which identifies the current mission. Strings are limited to 123 characters. Mission name equals __cur_sp or __cur_mp if it's packed (PBO).

mem modlist Selected modfolders
Version:
1.13
Input:
Nothing
Output:
Array (strings)
example:
_array = call loadFile :mem modlist"

Reads from the memory arguments that user passed to the game and returns list of selected modfolders.

mem multi Multiple memory values
Version:
1.13
Input:
Bool is custom dialog present
Output:
Array:
0 - Array camera
0 - Float X-axis coordinate
1 - Float Y-axis coordinate
2 - Float Z-axis coordinate absolute
3 - Float direction
4 - Float pitch
5 - Float field of view
6 - Bool is a cutscene rolling
1 - Bool is map displayed
2 - Bool is NV displayed
3 - Array player view
0 - String view ("internal", "gunner", "external", "group")
1 - String toggle ("internal", "gunner", "external", "group")
4 - Array player aim
0 - Float mouse target direction
1 - Float gun horizontal offset
2 - Float mouse target pitch (-0.96 to 0.96)
3 - Float gun pitch
4 - Float gun velocity horizontal
5 - Float gun velocity vertical
5 - Integer player animation code
6 - Bool dialog number
7 - Bool is radio menu shown
example:
_array = call loadFile Format [":mem multi %1", dialog]

Use this command ONLY via MemMulti.sqs script.

Combination of :mem getcam, :mem getmap, :mem getnv, :mem getplayerview, :mem getplayeraim, :mem getplayeranim, :mem isdialog, :mem getradiobox.

mem setcursor Set cursor position
Version:
1.1
Input:
1: Float - X-axis coordinate
2: Float - Y-axis coordinate
Output:
Nothing
example:
loadFile ":mem setcursor 0.5 0.5"

Changes dialog cursor position by writing values to the memory.

mem setdifficulty Change difficulty
Version:
1.13
Input:
1: String or Bool source ("mp" or "true")
2: String or Bool difficulty mode ("cadet" or "true", "veteran" or "false")
3: Array:
0 - Bool Extended armor
1 - Bool Friendly TAG
2 - Bool Enemy TAG
3 - Bool Extended HUD info
4 - Bool Auto report
5 - Bool Extended map info
6 - Bool Weapon crosshair
7 - Bool Auto guide AT
8 - Bool Clock indicator
9 - Bool 3rd person view
10 - Bool Rifle bullet tracers
11 - Bool Super AI
Output:
Nothing
example:
loadFile Format [":mem setdifficulty mp - %1", [true,true,false,false,-,-,-,false,false,true,false,-]]

Modifies game difficulty settings in the memory. Second parameter does not make difference on client in multiplayer . Changes in SP and on dedicated server are carried between missions. Changes on client in MP last until you enter mission selection screen. Pass value different than bool in order to skip value.


mem setgraphics Alter video options
Version:
1.13
Input:
brightness: - Float - brightness
vquality: (vq) - Float - visual quality
objectshadows: (os) - Bool - object shadows
vehicleshadows: (vs) - Bool - vehicle shadows
viewdistance: (vd) - Float - visibility
Output:
Nothing
example:
loadFile ":mem setgraphics b:1.8 vd:500"

Changes game graphics by modifying values in the memory. Changes done to brightness, shadows and cloudlets are permanent. View distance modification lasts until mission termination or if user enters video settings menu. Objects are not rendered above 5km.

mem setmap Turn map on/off
Version:
1.1
Input:
Integer (0 or 1) OR Bool
Output:
Nothing
example:
loadFile ":mem setmap 1"

Switches 2D island map on / off by changing value in the memory. Game does not allow showing a map during a cutscene.

mem setplayeraim Set aim angle
Version:
1.12
Input:
Array:
0 - Float crosshair target direction
1 - Float gun horizontal offset
2 - Float crosshair target pitch
3 - Float gun pitch
4 - Float gun velocity horizontal
5 - Float gun velocity vertical
Output:
Nothing
example:
loadFile Format [":mem setplayeraim %1", [0,"-",0,0,"-","-"]]

This command is currently bugged (to fix in the next version). Modifying gun offset may crash on CWA.

Modifies player's aim angle values in the memory. Pass raw pitch values (not degrees). See demo mission for conversion method. Pass - (minus) to avoid changing value. Gun offset modification has only a temporary effect. If you change mouse values then the player will turn for a couple degrees. Iterate command with time interval to reach desired orientation. Crosshair values cannot be changed if the mouse is deactivated (aka when user pressed "turn left/right", looked around with keypad, is using joy or if dialog is displayed). Switch to optics for a temporary solution. Gun pitch cannot be changed while player is in a vehicle (if you try the game will crash).

mem setplayeranim Set player animation
Version:
1.1
Input:
Integer animation code
Output:
Nothing
example:
loadFile ":mem setplayeranim 101"

Changes player's unit current animation by modifying value in the memory. It works immediately and there's no transition state. Game broadcasts this change in multiplayer. Sometimes animation may stop in the middle or be played infinitely (e.g. moving forward) - it depends on previous unit state (before modification). Using code out of range will crash the game.

mem setplayerhatch Turn in/out
Version:
1.13
Input:
1: String position ("driver", "gunner", "commander")
2: Bool look outside (optional)
Output:
Nothing
example:
loadFile ":mem setplayerhatch driver"

Causes player to open or close hatch in his vehicle by modifying value in the memory. If second parameter was not specified then it will change to the opposite value.

mem setplayerladder Move player on a ladder
Version:
1.13
Input:
1: Float position (from 0 to 1)
2: Integer ladder ID (optional)
Output:
Nothing
example:
loadFile ":mem setplayerladder 0.5"

Changes player's position on a ladder and/or current ladder in the building. If given ID is out of range then the game will crash.

mem setplayerview Change player's view
Version:
1.11
Input:
String view ("internal", "gunner", "external", "group")
Output:
Nothing
example:
loadFile ":mem setplayerview internal"

Changes player's camera mode by modifying "toggle" value in the memory. Works similarly to switchCamera.

mem setradiobox Radio menu on/off
Version:
1.13
Input:
Bool
Output:
Nothing
example:
loadFile ":mem setradiobox true"

This command is currently bugged (to fix in the next version). It doesn't work on CWA.
Shows/hide radio menu by modifying value in the memory.

mem setrespawntype Change respawn
Version:
1.11
Input:
Integer type (from 0 to 4)
Output:
Nothing
example:
loadFile ":mem setrespawntype 0"

Changes player's respawn mode by modifying value in the memory. Details you'll find here.

mem setspeedkey Set vehicle acceleration
Version:
1.13
Input:
String movement type ("reverse", "stop", "slow", "forward", "fast")
Output:
Nothing
example:
loadFile ":mem setspeedkey forward"

Changes player's vehicle speed by modyfing value in the memory. To take effect command must be iterated in short cycles. It won't work during a cutscene.

s String length
Version:
1.1
Input:
String
Output:
Integer
example:
_length = call loadFile Format [":s %1", "foo bar"]

Similar to :string length. It's not required to pass string inside a quote. Input text mustn't exceed 124 characters.

sc String compare
Version:
1.1
Input:
1: String text1
2: String text2
Output:
Integer
0 - text1 and text2 are identical
1 - text1 is greater than text2
-1 - text1 is less than text2
example:
_value = call loadFile Format [{:sc "%1" "%2"}, "Hello", "World!"]

Compares two strings with each other according to the lexicographical order. Case insensitive. Use :sC for case sensitive check. Total length of the arguments mustn't exceed 118 characters.

sdom String domain
Version:
1.13
Input:
String
Output:
Array:
0 - Array (with strings) segmented address
1 - Integer query string index
2 - Array (with strings) segmented domain
3 - String domain name
example:
_split = call loadFile ":sdom http://ofp-faguss.com/fwatch"

Splits web address into parts. Number indicates where the query string begins in the first array. It's not required to pass string inside a quote. Input text mustn't exceed 121 characters.

se String empty
Version:
1.11
Input:
String
Output:
Bool
example:
_isEmpty = call loadFile format [":se %1", " "]

Determines if string consists entirely out of whitespace (e.g. spaces, tabs). It's not required to pass string inside a quote. Input text mustn't exceed 123 characters.

so String occurrences
Version:
1.13
Input:
1: String search in
2: String search for
Output:
Array (with integers)
example:
_positions = call loadFile Format [":so ""%1"" ""%2""", "Hello World!", "l"]

Finds all occurrences in a given text and returns positions in an array. Use :So to match whole words and :sO for case sensitivity.

sr String replace
Version:
1.1
Input:
1: String text
2: String occurrence
3: String replacement
Output:
String
example:
_text = loadFile Format [{:sr "%1" "%2" "%3"}, "Hello World!", "Hello", "Hi"]

Replaces all occurrences in a string with given pattern. Use :Sr to match whole words and :sR for case sensitivity. Total length of the arguments mustn't exceed 115 characters.

src String replace characters
Version:
1.14
Input:
1: String text
2: String occurrences
3: String replacement
Output:
String
example:
_text = loadFile Format [{:src "%1" %2 %3}, "filename???.txt", "?<>:|\/*", "_"]

Replaces all occurrences of the selected characters in a string with a single character. Use :Src to match outside of words and :sRc for case sensitivity. Use mode :srC to replace character (from the second argument) with corresponding character from the third argument. If there's nothing to replace with then the character will be removed. Total length of the arguments mustn't exceed 114 characters.

srng String range
Version:
1.12
Input:
1: String text
2: Integer start position
3: (optional) Integer end position
Output:
String
example:
_hello = loadFile Format [":srng ""%1"" 0 5", "Hello World!"]

Similar to :string range. Default value for end position is length of the string. Negative number determines relative position from the end. Total length of the arguments must not exceed 117 characters (in case of three params). Use :srnG to turn second parameter into an end position (start will be zero). If you use :Srng then third argument will be treated as length instead of end position. Use :sRNg to cut text from the middle (both arguments must be given). If start argument is larger than end position then the command will return characters backwards.

st String type
Version:
1.1
Input:
String
Output:
String ("string", "integer", "float")
example:
_value = loadFile Format [":st %1", "50.58"]

Determines if string consists out of digits. Use :sT to omit mathematical operators. It's not required to pass string inside a quote. Input text mustn't exceed 123 characters.

stok String tokenize
Version:
1.12
Input:
1: String text
2: String delimiters
Output:
Array (strings)
example:
_array = call loadFile Format [":stok ""%1"" ""%2""", "a1b2c3", "123"]

Splits string using given characters as delimiters and returns fragments in an array. Total length of the arguments mustn't exceed 117 characters. Optional modes:
  • :Stok - second argument is treated as a word
  • :sTok - command will skip occurences inside quotation marks
  • :stOk - matches whole words
  • :stoK - case sensitivity


string first First occurrence
Version:
1.0
Input:
1: String occurrence
2: String text
Output:
Integer position
example:
_x = call loadFile Format [{:string first "%1" "%2"}, "foo", "xx foo yy foo"]

Returns position of the first occurrence of a given string in the given text or -1 if not found. I recommend to use :so instead.

string index Single character
Version:
1.0
Input:
1: String text
2: Integer position
Output:
String
example:
_letter = call loadFile Format [{:string index "%1" 1}, "hello"]

Returns a character (wrapped in quotation marks) from the given text at the specified position.

string last Last occurrence
Version:
1.0
Input:
1: String occurrence
2: String text
Output:
Integer position
example:
_x = call loadFile Format [{:string first "%1" "%2"}, "foo", "xx foo yy foo"] 

Returns position of the last occurrence of a given string in the given text or -1 if not found. I recommend to use :so instead.

string length String length
Version:
1.0
Input:
String
Output:
Integer
example:
_length = call loadFile Format [{:string length "%1"}, "hello"]

Returns the number of characters in the given text. I recommend to use :s instead.

string range Portion of a string
Version:
1.0
Input:
1: String text
2: Integer start position
3: Integer end position
Output:
String
example:
_cut = call loadFile Format [{:string range "%1" 1 4}, "hello"]

Returns the range of characters (wrapped in quotation marks) in the given text from the specified start to end position. I recommend to use :srng instead.

string toarray Split letters
Version:
1.0
Input:
String
Output:
Array (strings)
example:
_array = call loadFile Format [{:string toarray "%1"}, "hello"]

Returns all characters from the given string as array elements. I recommend to use :s[ instead.

string tolower Convert to lower case
Version:
1.0
Input:
String
Output:
String
example:
_text = call loadFile Format [{:string tolower "%1"}, "HELLO"]

Returns string (wrapped in quotation marks) in lower case.

string toupper Convert to upper case
Version:
1.0
Input:
String
Output:
String
example:
_text = call loadFile Format [{:string toupper "%1"}, "hello"]

Returns string (wrapped in quotation marks) in upper case.

stw String trim whitespace
Version:
1.12
Input:
String
Output:
String
example:
_string = loadFile Format [":StW %1", "  hello  "]

Removes whitespace from the given string according to the selected mode. It's not required to pass string inside a quote. Input text mustn't exceed 122 characters. Modes:
  • :Stw - removes leading spaces
  • :stW - removes trailing spaces
  • :sTw - removes spaces between words


sv String variable
Version:
1.11
Input:
String
Output:
Bool
example:
_isVar = call loadFile format [":sv %1", "_var10"]

Determines if a string can be used as a scripting variable name. It's not required to pass string inside a quote. Input text mustn't exceed 123 characters. Use :Sv to check if variable is local and :sV - global. Use :SV mode to allow number as first character and square brackets at the end (this is meant for validating class properties). To restrict brackets in :SV mode start argument with "class" keyword (this is meant for validating class names). Keyword itself is ignored.

swul String upper/lower case
Version:
1.14
Input:
String
Output:
String
example:
_text = loadFile Format [":swuL %1", "Hello World!"]

Transforms letters in a string to lower or uppercase depending on the selected mode:
  • :swUl - all letters to uppercase
  • :swuL - all letters to lowercase

  • :SwUl - characters starting sentences to uppercase
  • :SwuL - characters not starting sentences to lowercase
  • :SwUL - characters starting sentences to uppercase and all other to lowercase

  • :sWUl - first characters in all words to uppercase
  • :sWuL - all characters except those starting words to lowercase
  • :sWUL - first characters in all words to uppercase and all other to lowercase
It's not required to pass string inside a quote. Input text mustn't exceed 121 characters.

s[ Split letters
Version:
1.13
Input:
String text
Output:
Array (with strings)
example:
_array = call loadFile Format [":s[ %1", "hello"]

Similar to :string toarray. It's not required to pass string inside a quote. Input text mustn't exceed 124 characters.