On-Line doc

Fwatch v1.15 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 file with a special name Fwatch takes over. It's able to perform a variety of operations (like reading/writing text files, string manipulation, utilizing WINAPI) and send results back to the game.

It was created by Kegetys in 2005. This project (which started in the late 2010) is a continuation. It features 98 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. Do not start or quit the Fwatch while the game is running or the latter will crash.

-steam - same as -nolaunch but it will additionally start the game via Steam.

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

-reporthost - informs master server when you host a game so it will show up in a browser. Requires -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\.

-removenomap - cancel adding -nomap automatically. For use on Wine on Linux.


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

Fwatch Command Syntax
Data Types
Memory Commands on a Dedicated Server
Source Directory for the FILE Commands
Source Directory for the New Commands
Game Limitations
Error Handling


Fwatch Command Syntax

Fwatch can be called by any command that reads an external file (addAction, exec, loadFile or preprocessFile).

String that you pass to one of these commands begins with a backslash and a colon followed by Fwatch command name. Subsequent phrases are treated as arguments.
\:name1 name2 argument1 argument2 argument3 argument4
for example:
loadFile "\:file write test.db foo 1"
Backslash is not obligatory but recommended because in its absence long arguments will crash the game.

All arguments are required unless stated otherwise. They must be written in the specified order.

If you want to pass string with spaces then 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

30 new commands   (show)   have a different system of passing data. Each argument must start with an identifier followed up by a colon and then by value. \:igse load  end:150  split:true  ""file:name with spaces.txt"" All arguments are optional. They can be written in any order.

Arguments that require boolean are false by default. If you pass empty string, zero or false then the option will remain turned off. For any other text - it will be activated.

Text arguments in the new system do not need quotes. Instead they are separated by "Unit Separator" character. Hold ALT and press 0, 3, 1 on numeric keypad and release ALT. \:string compare text1:hello worldtext2:hi world It's indicated on the command page which arguments require this notation.


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. :string replace) do not require execution of call as it would be redundant. See example code in the command description page.


Memory Commands on a Dedicated Server

Only 10 mem commands will work on a dedicated server: :mem bullets
:mem getdaylight
:mem getdifficulty
:mem getrespawntype
:mem getresside
:mem getweather
:mem getworld
:mem missioninfo
:mem setdifficulty
:mem setweather
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 names are 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 current (unpacked) mission folder. They will return error on PBO missions.

To access game root directory start the path with ..\ \:igse load  file:..\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).

Game Limitations

Command format will crash the game when input text is larger than 2048 characters. Use concatenation operator to work around (it's slower, though).

Commands :file read, :file read2, :file readvars, :file vars, :file wget may output 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. :igse load) work around this restriction by returning code that merges bunch of smaller arrays into a single large one.


Error Handling

33 commands return detailed error description   (show)

Error information is stored in the output array. For 5 FILE commands (show) it is stored in a separate local array _fwatch_error instead (it needs to be declared beforehand).

Array contains following items:
Example: _result = call loadFile "\:IGSE LOAD  file:???"
? !(_result select 0) : hint (_result select 3)

; For FILE commands
_fwatch_error = [true, 0, 0, ""]
_variable = call loadFile "\:FILE READ  test.db  foo"
? !(_fwatch_error select 0) : hint (_fwatch_error select 3)


Input Commands Info

:input getjoystick

This command 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 may take up to 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. In case of error it returns array with error description and last used joystick ID.

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

Pressed buttons are returned as strings in an array. View list of possible values.

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 command reads joystick input from the game memory.
Values are always returned even without a joystick. Center POV is 65535 even if the controller doesn't have a POV switch.

Pressed buttons are returned as strings in an array. View list of possible values.

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 difference between them is in holding a key. In the case of the latter a value will keep popping in and out of array which allows for programming repeated action.

View list of possible values.

When Num Lock is enabled, pressing SHIFT and numpad key will change input (e.g SHIFT+7 returns HOME).

If you hold numpad key and SHIFT simultaneously and then release numpad key then it will be treated as if constantly pressed. Press it again to unblock it.

Numpad enter is not detected.

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 the 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
FormatDate
getAspectRatio
InitFLib
inKeys
MeasureTime
ModifyDate
path
pathDedi

Scripts

InputMulti
MemMulti
onScreenTyping


Recommended Practices




Command list:

CLASS CLIPBOARD EXECUTE FILE IGSE INFO INPUT MEMORY STRING
class list clip copy exe addontest file awrite igse copy info date input agetkey mem bullets string case
class modify clip copyfile exe preprocess file delete igse find info debugout input agetkeys mem error string compare
class modtok clip cutfile exe unpbo file dxdll igse list info errorlog input getjoystick mem getcam string cut
class token clip fromfile exe wget file exists igse load info resolution input getkey mem getcinemaborder string domain
clip get restart client file modlist igse new info starttime input getkeys mem getcursor string find
clip getline restart server file qwrite igse rename info tick input getmouse mem getdate string first
clip pastefile spig exe file read igse write info version input lock mem getdaylight string index
clip size file read2 input multi mem getdifficulty string isempty
clip tofile file readvars input setmouse mem getgraphics string isnumber
file remove mem getjoystick string isvariable
file renamemissions mem getmap string join
file vars mem getnv string last
file wget mem getplayeraim string length
file write mem getplayeranim string range
mem getplayerhatch string replace
mem getplayerladder string replacechar
mem getplayerview string size
mem getradiobox string split
mem getrespawntype string toarray
mem getresside string tokenize
mem getscroll string tolower
mem getspeedkey string toupper
mem getweather string trim
mem getworld string wordpos
mem isdialog
mem masterserver
mem missioninfo
mem modlist
mem multi
mem setcam
mem setcursor
mem setdifficulty
mem setgraphics
mem setmap
mem setplayeraim
mem setplayeranim
mem setplayerhatch
mem setplayerladder
mem setplayerview
mem setradiobox
mem setrespawntype
mem setspeedkey
mem setweather




Command reference

commanddescription

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

Parses given file and returns list of classes. To find nested class use classpath: argument. For large files use offset: in order to reduce searching time.

class modify Modify class
Version:
1.13
Input:
file: - String - file name
classpath: - Array (with strings) - list of parent classes
add: - String - name of the new class
rename: - String - name of the class to be renamed
to: - String - new name
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 number of accessed parent classes
example:
_ok = call loadFile ":class modify ""file:config.cpp"" classpath:[CfgWeapons] ""add:M16 : Riffle"""

Performs one of three possible operations (create new class, rename existing one or delete class and its contents) on the selected file. To find nested class use classpath: argument. If a class you want to rename has inheritance then argument to: should include that inherit name.

class modtok Modify class property
Version:
1.13
Input:
file: - String file name
classpath: - Array (with strings) list of parent classes
add: - String property (with value) to be added
append: - String property (with value) to be appended
rename: - String property to be renamed
to: - String new name
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 number of accessed parent classes
example:
_ok = call loadFile "\:class modtok ""file:config.cpp"" classpath:[CfgWeapons,M16] add:optics=0"

Performs one of four possible operations (create new property, append value, rename property or remove it) on the selected file. To find nested class use classpath: argument.

Pass name=value for arguments add: and append:. If property you want to add already exists then its value will be overwritten. If property you want to append doesn't exist then it will be created. Don't quote text that you want to append to a string. To append array to an array wrap the value in brackets. Array names must end with square brackets.

If parameter index: was specified then the operation is performed on an item inside the array. Accessing sub-arrays is not supported.

class token Class properties
Version:
1.13
Input:
file: - String file name
classpath: - Array (with strings) list of parent classes
offset: - String position of the last class in the classpath (in bytes)
token: - String property to find
wrap: - String put values in quotes ("yes", "no", "nodouble")
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
4 - Integer number of accessed parent classes
5 - String position of the class (in bytes)
6 - Array (with strings) property names
7 - Array (with strings) property values
example:
_ok = call loadFile "\:class token file:mission.sqm classpath:[Mission,Groups,Item0,Vehicles,Item0]"

Parses given file and returns list of properties from the specified class. To find nested class use classpath: argument. For large files use offset: in order to reduce searching time.

If token: was specified then only that property will be returned. All values are wrapped in quotation marks. Use wrap:no to cancel or wrap:nodouble to disable wrapping for values that already have quotation marks. Multi-dimensional arrays are not supported.

clip copy Text to clipboard
Version:
1.12
Input:
text: - String text to copy
append: - Bool add to existing text
escape: - String parse escape sequences
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_result = loadFile Format ["\:clip copy text:%1", "Hello World!"]

Copies given text to the Windows clipboard. Pass letter "n" in argument escape: to replace \n with new lines. Pass letter "t" to replace \t with tabulators. Write number before the letter to limit amount of replacements.

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 Move 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 a "move" instruction. Argument is list of files separated by spaces. If file has a space in its name then wrap it in quotation marks. Path info you'll find here.

clip fromfile File text to clipboard
Version:
1.13
Input:
1: String file name
(optional) 2: String optional mode ("a")
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"""

Copies text from the selected file to the Windows clipboard. Pass "a" to append.

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

Returns text stored in the Windows clipboard.

clip getline Lines from clipboard
Version:
1.13
Input:
start: - Integer range start
end: - Integer range end
cut: - Integer character limit for each line
split: - Bool segment lines
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 of them if not specified) from the text stored in the Windows clipboard. Combine arguments cut: and split: in order to segment lines (parts will be put into additional sub-array).

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 file path
1 - String file name
2 - 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 a successful "move" operation. Pass argument ?list 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 the Windows clipboard.

clip tofile Save clipboard text
Version:
1.13
Input:
1: String file name
(optional) 2: String optional mode ("a", "w")
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"""

Writes text from the Windows clipboard to a text file. Won't overwrite unless "w" was passed. Pass "a" to append 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 (see demo mission)
  • 1 - Integer preprocessor error code (see documentation)
  • 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 Unpack 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 extracting PBO files. Argument is a path to the file starting from the game root directory. Aleternatively 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 from 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. 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:
(optional) String arguments
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. Pass string without a quote. Parameters previously passed to the game are transferred to the new instance (except for -mod and <-connect). Operations are documented in the fwatch\data\gameRestartLog.txt.

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 then create a new one with given arguments. Pass string without a quote. Executable (OFPR_Server.exe or ColdWarAssault_Server.exe) must be in the game directory.

spig exe SPIG save conversion
Version:
1.11
Input:
1: String executable name
2: String file name
Output:
Array:
0 - Integer result code
OR
String error message
example:
loadFile ":spig exe spig2sqm.exe spig_sqm1.txt"

Executes given program from the Set-Pos-In-Game\Exe\ directory. Second argument file name from the fwatch\mdb\ folder. In case of an error it returns error message instead.

file awrite Append variable
Version:
1.0
Input:
1: String file name
2: String variable name
3: Any variable value
Output:
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. String values should be wrapped in quotation marks. Detailed error information is returned in _fwatch_error local array.

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"

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

file exists File presence
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. Detailed error information is stored in _fwatch_error local array.

file qwrite Variable quick save
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]

Writes variable to the given file in fwatch\mdb\ without checking if the same variable is already there. Returns 1 on success and -1 on failure. String values should be wrapped in quotation marks.

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

Returns value from a specified variable in the given file in fwatch\mdb\. Returns -1 on failure. Detailed error information is returned in _fwatch_error local array therefore you must use call with this command.

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

Returns value from a specified variable in the given file. Source folder is game root directory. In case of error it returns -1. Detailed error information is returned in _fwatch_error local array therefore you must use call with this command.

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

Returns code with all variables and their values (in a var=val; format) from the specified file in fwatch\mdb\. Result 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 specified 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 with all variable names stored in the specified 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 to avoid freezing the game. Launches external program which returns data from 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:
Integer status
example:
_status = call loadFile Format [":file write test.db %1 %2", "foo", 1]

Saves variable (overwrites) to the specified file in fwatch\mdb\. Returns 1 on success and -1 on failure. String values should be wrapped in quotation marks. Detailed error information is returned in _fwatch_error local array therefore you must use call with this command.

igse copy Copy file
Version:
1.13
Input:
source: - String path to an existing file
destination: - String new path with name
overwrite: - Bool trash existing file if there's conflict
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_ok = call loadFile "\:igse copy source:mission.sqm destination:mission.backup"

Copies selected file to the the given location with specified new name. Path info you'll find here. You may copy files from the outside to a non-restricted location but cannot copy in the opposite direction.

igse find Find text in file
Version:
1.12
Input:
file: - String file name
text: - String phrase to find
start: - Integer start on line
end: - Integer end on line
offset: - String start line position (in bytes)
limit: - Integer limit number of results
column: - Integer position in the line
ignoreLeadSpace: - Bool ignore leading whitespace when locating by column
replace: - String text to replace with
caseSensitive: - Bool match case
matchWord: - Bool match whole word only
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 (integers) 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 "\:igse find ""file:mission.sqm"" text:soldierwb"

Searches for occurrences of a given text in the selected file. Path info you'll find here.

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

For large files limit range (instead of going through entire text at once) and use offset: to continue search from the last position.

igse list List of files
Version:
1.1
Input:
path: - String directory to list files from
systemtime: - Bool dates in system time
onlyname: - Bool leave attributes array empty
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 "\:igse list path:*"

Returns list of files and their attributes. Path info you'll find here. Path should have a wildcard (*). For date array structure see info date. Use argument systemtime: to return dates in system time instead of local time. File size is divided into three values (full megabytes and kilobytes are subtracted from the amount of bytes).

List of possible attributes:
  • readonly
  • hidden
  • system
  • directory
  • archive
  • device
  • temporary
  • sparse
  • reparse
  • compressed
  • offline
  • notcontentindexed
  • encrypted
  • integritystream
  • virtual
  • noscrubdata


igse load File text lines
Version:
1.1
Input:
file: - String file name
start: - Integer start from line
end: - Integer end on line
offset: - String start line position (in bytes)
cut: - Integer character limit
split: - Bool split line into parts
mode: - String optional mode
delete: - Bool remove file after reading it
wait: - Integer keep trying to open file for a given time (in tens of 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 is last line empty
7 - Bool was end of file reached
8 - String last position in bytes
example:
_text = call loadFile Format ["\:igse load ""file:%1"" end:%2", "init.sqs", 150]

Returns lines from the selected text file. Path info you'll find here. Combine argument cut: with split: to segment lines (parts will be put into additional sub-array).

For large files limit range (instead of going through entire text at once) and use offset: to continue reading from the last position.

Available modes:
  • default - return text in arrays
  • execute - return text as a single string for execution
  • clipcopy - copy text to clipboard
  • clipappend - append text to clipboard


igse new Create file
Version:
1.11
Input:
file: - String file name
mode: - String optional mode
directory: - Bool create directory instead of a file
unique: - Bool return error if file already exists
subdirs: - Bool create parent directories
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_ok = call loadFile Format ["\:igse new ""file:%1""", "new.txt"]

Creates a new file or takes action specified by the mode parameter. Path info you'll find here. Available modes:
  • create - creates a file if it doesn't exists (default)
  • delete - trashes given file
  • recreate - trashes given file and creates a new one
  • check - determines if a file exists


igse rename Rename file
Version:
1.11
Input:
source: - String path to an existing file
destination: - String new path with name
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_ok = call loadFile Format ["\:igse rename ""source:%1"" ""destination:%2""", "old.txt", "new.txt"]

Changes name and location of a given file. Path info you'll find here. Moving files to the \fwatch\tmp\ directory is restricted.

igse write Write text
Version:
1.14
Input:
file: - String file name
line: - Integer line to modify
column: - Integer position in the line
text: - String text to write
mode: - String optional mode
escape: - String parse escape sequences
clip: - Bool use text from clipboard instead
range: - Integer how many lines to delete
Output:
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
_ok = call loadFile Format ["\:igse write ""file:%1"" text:%2", "My File.txt", "Hello World!"]

Writes given text in the new line at the end of the selected file. If line number was specified then instead it will replace contents of that line with given text . Use zero or negative number for a line relative from the end.

Pass "t" in the escape: argument to replace \t with tabulators. Pass "n" to replace \n with new lines. Write number before the letter to limit amount of replacements.

Available modes (when line number was passed):
  • replace - default mode
  • append - appends text to the line (if line number wasn't specified then to the last one)
  • new - create a new line after the selected one and writes text
  • insert - create a new line before the selected one and writes text
  • copy - duplicate selected line
  • delete - remove selected line, use range: to delete multiple lines
  • clear - remove all characters in the selected line
  • moveup - swap selected line with the previous one
  • movedown - swap selected line with the line below


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. Time zone variable is the difference from GMT in minutes. It does not represent current time but Windows time zone setting.

Pass string to return system time instead of local time. Pass an existing array with date in order to correct its day name number (for when you modify date).

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

Output Win32 debug string.

info errorlog Log Fwatch errors
Version:
1.15
Input:
(optional) Bool toggle
Output:
Bool is enabled
example:
_log = call loadFile ":info errorlog true"

Enables saving Fwatch error information to the \fwatch\idb\_errorLog.txt or \fwatch\idb\_errorLogDedi.txt on a dedicated server.

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 date and time indicating when the game process was started.

info tick Time in ms
Version:
1.15
Input:
Nothing
Output:
Integer
example:
_milliseconds = call loadFile ":info tick"

Returns the number of milliseconds that have elapsed since path.sqf was created.

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 extra parameter to get an array with additional information instead.

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"

I recommend to use InputMulti.sqs script instead.

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) pressed 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"

I recommend to use InputMulti.sqs script instead.

Reads joystick input using Windows API. 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"

I recommend to use InputMulti.sqs script instead.

Returns array of all keyboard keys and mouse buttons presses. If argument was passed then 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"

I recommend to use InputMulti.sqs script instead.

Returns position of the Windows mouse cursor and state of the buttons. The latter works 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"

I recommend to use InputMulti.sqs script instead.

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. See also Input Commands Info.

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 shotBullet duration
shell: - Float shotShell duration
rocket: - Float shotMissile and shotRocket duration
bomb: - Float shotMissile and shotRocket with thrustTime=0 duration
smoke: - Float shotSmoke duration
flare: - Float shotIlluminating duration
flareduration: Float shotIlluminating light duration
pipebomb: - Float shotPipeBomb duration
timebomb: - Float shotTimeBomb duration
Output:
Array:
0 - Float gravity acceleration
1 - Float bullet duration
2 - Float shell duration
3 - Float rocket duration
4 - Float bomb duration
5 - Float smoke duration
6 - Float flare duration
7 - Float flare light duration
8 - Float pipe bomb duration
9 - Float time bomb duration
example:
_properties = call loadFile ":mem bullets bullet:6 shell: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. I recommend to execute this command on all machines to avoid issues.

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

mem error Error message
Version:
1.12
Input:
(optional) String optional mode ("clip")
Output:
String
OR
Array:
0 - Bool operation success
1 - Integer error code
2 - Integer system error code
3 - String error description
example:
hint loadFile ":mem error"

Reads from the memory first 512 characters of the currently shown scripting error. Pass clip to copy message to the clipboard (error array will be returned 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 from the sea
3 - Float direction
4 - Float pitch
5 - Float field of view
6 - Bool is a cutscene rolling
7 - Array external camera position
0 - Float axis X
1 - Float axis Y
2 - Float axis Z
example:
_camera = call loadFile ":mem getcam"

I recommend to use MemMulti.sqs script instead.

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 Black bars
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"

I recommend to use InputMulti.sqs script instead.

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 the missionStart command is executed.

mem getdaylight World brightness
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)
14 - Float max distance for drawing landscape
15 - Float max distance for drawing objects
16 - Float vehicle radar range
17 - Float max distance for drawing shadows
18 - Integer max number of objects
19 - Float tracks lasting time
20 - Float tracks disappearing rate
21 - Integer max number of lights
22 - Float horizontal field of view
23 - Float vertical field of view
24 - Float interface left edge position
25 - Float interface top edge position
26 - Float interface right edge position
27 - Float interface bottom edge position
example:
_graphics = call loadFile ":mem getgraphics"

Reads current graphics settings from the memory. Refresh rate value equals zero in windowed mode.

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) pressed buttons and POV
5 - Integer POV angle (0, 45, 90, 135, 180, 225, 270, 315)
example:
_joystick = call loadFile ":mem getjoystick"

I recommend to use InputMulti.sqs script instead.

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

mem getmap Map display
Version:
1.1
Input:
Nothing
Output:
Bool
example:
_map = call loadFile ":mem getmap"

I recommend to use MemMulti.sqs script instead.

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

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

I recommend to use MemMulti.sqs script instead.

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 direction
1 - Float gun offset from soldier's direction
2 - Float crosshair pitch (sine of an angle)
3 - Float gun pitch current (in radians)
4 - Float gun speed horizontal
5 - Float gun speed vertical
6 - Float gun pitch goal (in radians)
example:
_aim = call loadFile ":mem getplayeraim"

Output structure will change in 1.16

I recommend to use MemMulti.sqs script instead.

Reads player's aim angle values from the memory. Use asin to convert crosshair pitch to degrees. Use deg to convert gun pitch to degrees. Value range for gun angles depends on weapon configuration. Gun offset and pitch are equal 0 and 1 respectively when player is inside a vehicle.

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

I recommend to use MemMulti.sqs script instead.

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

mem getplayerhatch 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 them in an array. Pass an extra argument to get a number instead - 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 Camera type
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"

I recommend to use MemMulti.sqs script instead.

Reads player's camera mode from the memory. A view type may be toggled but not displayed (e.g. if a weapon doesn't have optics like hand grenades).

mem getradiobox Radio menu display
Version:
1.13
Input:
Nothing
Output:
Bool
example:
_isRadio = call loadFile ":mem getradiobox"

I recommend to use MemMulti.sqs script instead.

Reads value from the memory value that indicates if the 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"

I recommend to use InputMulti.sqs script instead.

Reads mouse scroll counter from the memory. It increases by 1 every time user rolls wheel forward and decreases by 1 when rolled 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"

I recommend to use InputMulti.sqs script instead.

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

mem getweather Current weather
Version:
1.15
Input:
Nothing
Output:
Array:
0 - Float current overcast
1 - Float target overcast
2 - Float overcast change rate
3 - Float current fog
4 - Float target fog
5 - Float fog change rate
6 - Float weather time
7 - Float time of next change
8 - Integer mission time
9 - Float clouds position
10 - Float clouds transparency
11 - Float clouds brightness
12 - Float clouds speed
13 - Float sky transparency
14 - Float current rain
15 - Float target rain
16 - Float rain change rate
17 - Integer time of next thunderbolt
18 - Array wind velocity
0 - Float X axis
1 - Float Y axis
2 - Float Z axis
19 - Integer time of last wind change
20 - Array gust of wind velocity
0 - Float X axis
1 - Float Y axis
2 - Float Z axis
21 - Integer gust end time
22 - Float sea level
23 - Float sea level with wave
24 - Float wave speed
25 - Float tide height in meters
26 - Float wave height in meters
example:
_current = call loadFile ":mem getweather"

I recommend to use MemMulti.sqs script instead.

Reads weather condition values from the memory. Weather time (float) is different from thunderbolt/wind time (integer). Use mission time (integer) to compare with the latter.

mem getworld Island name
Version:
1.1
Input:
(optional) String ("extended")
Output:
String
OR
Array:
0 - String island name
1 - Integer island size
2 - Float latitude
3 - Float longitude
example:
_island = loadFile ":mem getworld"

Reads island shortcut name from the memory.

Pass extra parameter to get an array with additional information. Island size is a power of 2 up to 1024. Original islands have size 256. Island size won't be read on a dedicated server. Negative latitude indicates northern hemisphere. Negative longitude indicates western hemisphere.

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

I recommend to use MemMulti.sqs script instead.

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")
(optional) 2: String address replacing gamespy
(optional) 3: String address replacing udpsoft
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.

mem missioninfo Mission name
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
5 - String campaign name
example:
_names = call loadFile ":mem missioninfo"

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

mem modlist Chosen 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
7 - Array (float) external camera position
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
6 - Float gun pitch 2
5 - Integer player animation code
6 - Bool number of dialogs
7 - Bool is radio menu shown
8 - Array weather
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 getweather.

mem setcam Change camera
Version:
1.15
Input:
extCameraPosition: - Array (floats) external camera offset (x, y, z)
Output:
Nothing
example:
loadFile ":mem setcam extCameraPosition:[1,1,1]"

Modifies third person camera position in the memory.

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", "sp" or "false")
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 on client in MP last until you enter mission selection screen. Pass value different than bool in order to skip option.


mem setgraphics Change video settings
Version:
1.13
Input:
brightness: - Float brightness
vquality: - Float visual quality
objectshadows: - Bool object shadows
vehicleshadows: - Bool vehicle shadows
viewdistance: - Float visibility
landscapedistance: - Float max distance for drawing landscape
objectsdistance: - Float max distance for drawing objects
radardistance: - Float vehicle radar range
shadowsdistance: - Float max distance for drawing shadows
maxobjects: - Integer max number of objects
tracktime: - Float tracks lasting time
invtracktime: - Float tracks disappearing rate
maxlights: - Integer max number of lights
fovLeft: - Float horizontal field of view
fovTop: - Float vertical field of view
uiTopLeftX: - Float interface left edge position
uiTopLeftY: - Float interface top edge position
uiBottomRightX: - Float interface right edge position
uiBottomRightY: - Float interface bottom edge position
Output:
Nothing
example:
loadFile ":mem setgraphics brightness:1.8 viewdistance:500"

Changes game graphics by modifying values in the memory. View distance modification lasts until mission termination or if user enters video settings menu. Other changes are reverted between missions except for FOV and UI which isn't restored in SP Mission Editor for testing purposes.

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 map during a cutscene.

mem setplayeraim Set aim angle
Version:
1.12
Input:
Array:
0 - Float crosshair direction
1 - Float gun offset from soldier's direction
2 - Float crosshair pitch (sine of an angle)
3 - Float gun pitch current (in radians)
4 - Float gun speed horizontal
5 - Float gun speed vertical
6 - Float gun pitch goal (in radians)
Output:
Nothing
example:
loadFile Format [":mem setplayeraim %1", [0,"-",0,0]]

Input structure will change in 1.16

Modifies player's aim angle values in the memory. Pass - (minus) to skip a value. When you change direction player will turn for a couple degrees. Iterate command with time interval to reach desired orientation.

Final crosshair pitch will be different from wanted pitch. See demo mission on how to apply correction. Gun offset modification has only a temporary effect. Gun pitch cannot be changed while player is in a vehicle (if you try the game will crash).

Crosshair values cannot be changed if the mouse is deactivated (aka when user pressed "turn left/right", looked around with keypad, is using joystick or if dialog is displayed). You can modify gun values instead but it will work only in optics mode.

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 on a current ladder in the building. If given ID is out of range then the game will crash.

mem setplayerview Change camera type
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. Identical to switchCamera.

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

Shows/hide radio menu by modifying value in the memory. Sometimes it doesn't work if menu wasn't invoked manually before.

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. Respawn types you'll find here. Changing respawn after you died in "NONE" or "BIRD" won't have an effect. Changing respawn to "INSTANT" or "BASE" will not work after you died once in "GROUP".

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.

mem setweather Change weather
Version:
1.15
Input:
actualOvercast: - Float current overcast level
wantedOvercast: - Float target overcast level
speedOvercast: - Float overcast change rate
actualFog: - Float current fog level
wantedFog: - Float target fog level
speedFog: - Float fog change rate
weatherTime: - Float weather time
nextWeatherChange: - Float time of next change
cloudsPos: - Float clouds position
cloudsAlpha: - Float clouds transparency
cloudsBrightness: - Float clouds brightness
cloudsSpeed: - Float clouds speed
skyThrough: - Float sky transparency
rainDensity: - Float current rain level
rainDensityWanted: - Float target rain level
rainDensitySpeed: - Float rain change rate
thunderBoltTime: - Integer time of next thunderbolt
windSpeed: - Array (floats) wind velocity
lastWindSpeedChange: - Integer time of last wind change
gust: - Array (floats) gust of wind velocity
gustUntil: - Integer gust end time
seaWaveSpeed: - Float sea wave speed
maxTide: - Float sea level
maxWave: - Float sea wave height
Output:
Nothing
example:
_current = call loadFile ":mem setweather maxtide:-100"

Changes weather values in the memory. Game updates weather condition every couple of seconds. Changes done to tide and wave values are reverted between missions. When changing sea level I recommend to execute this command on all machines to avoid desynchronization.

string case Shift text case
Version:
1.14
Input:
text: - String source
upper: - Bool to upper case
lower: - Bool to lower case
words: - Bool words mode
sentences: - Bool sentences mode
start: - Integer start position
end: - Integer end position
length: - Integer end position relative from start
Output:
String
example:
_text = loadFile Format ["\:string case text:%1upper:1", "Hello World!"]

Transforms letters in a string to lower or uppercase. If words: was enabled then upper: will capitalize letters starting words and lower: will lowercase everything else. If sentences: was enabled then upper: will capitalize letters starting sentences and lower: will lowercase everything else.

string compare Compare text
Version:
1.1
Input:
text1: - String first text
text2: - String second text
caseSensitive: - Bool match case
natural: - Bool natural order comparison
reverseCase: - Bool capital letters return greater result
Output:
Integer
 0 - texts are identical
 1 - first one is greater than the second
-1 - first one is lesser than the second
example:
_value = call loadFile Format ["\:string compare text1:%1text2:%2", "Hello", "World!"]

Compares two strings with each other according to the lexicographical order. Alternatively use natural: to compare in a natural order. Option reverseCase: use in combination with caseSensitive:.

string cut Get text part
Version:
1.12
Input:
text: - String text to split
start: - Integer start position
end: - Integer end position
length: - Integer end position relative from start
exclude: - Bool crop mode
Output:
String
example:
_hello = loadFile Format ["\:string cut text:%1end:5", "Hello World!"]

Returns portion of the given text. Default start: value is zero and for end: it's length of the text. If starting position is larger than end position then the command will return characters backwards. Use exclude: to cut text from the middle.

string domain URL 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 "\:string domain http://ofp-faguss.com/fwatch"

Splits web address into parts. Pass string without quotation marks. Number indicates where the query string begins in the first array.

string find Text search
Version:
1.13
Input:
text: - String source
find: - String search for
matchWord: - Bool match whole words only
caseSensitive: - Bool match case
limit: - Integer max number of results
start: - Integer start position
end: - Integer end position
length: - Integer end position relative from start
Output:
Array (with integers)
example:
_positions = call loadFile Format ["\:string find text:%1find:%2", "Hello World!", "l"]

Returns array with positions of all occurrences in a given text. Default result limit is -1 (no limit).

string first First occurrence
Version:
1.0
Input:
1: String search for
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 in the given text or -1 if not found. I recommend to use string find 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. I recommend to use string cut instead.

string isempty Is text there
Version:
1.11
Input:
String
Output:
Bool
example:
_isEmpty = call loadFile format ["\:string isempty %1", " "]

Determines if given string consists entirely out of whitespace (e.g. spaces, tabs). Pass string without wrapping it in quotation marks.

string isnumber Is text a number
Version:
1.1
Input:
text: - String source
skipmath: - Bool omit math operators
Output:
String ("string", "integer", "float")
example:
_value = loadFile Format ["\:string isnumber text:%1", "50.58"]

Determines if given string consists out of digits.

string isvariable Check var name
Version:
1.11
Input:
text: - String text to check
mode: - String test condition
Output:
Bool
example:
_isVar = call loadFile format ["\:string isvariable text:%1", "_var10"]

Determines if a string can be used as a scripting variable name. Available modes:
  • default - allow global and local var names
  • onlyGlobal - allow only names that start with a letter
  • onlyLocal - allow only names that start with an underscore
  • className - check if text is a valid class name
  • classNameInherit - like above but also allow inherit name
  • classToken - check if text is a valid class property name


string join Merge text
Version:
1.15
Input:
text: - String source
merge: - String text to add
position: - Integer where to insert
Output:
String
example:
_text = loadFile Format ["\:string join text:%1merge:%2position:%3", "one three", "two ", 4]

Returns combination of two strings merged at a given position. If argument position: was not passed then text is added at the end. Pass negative number for a position relative from the end.

string last Last occurrence
Version:
1.0
Input:
1: String search for
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 in the given text or -1 if not found. I recommend to use string find instead.

string length Text size
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 string size instead.

string range Get text part
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) from the given text. I recommend to use string cut instead.

string replace Replace text
Version:
1.1
Input:
text: - String search in
find: - String search for
replace: - String replace with
caseSensitive: - Bool match case
matchWord: - Bool match whole words only
Output:
String
example:
_text = loadFile Format ["\:string replace text:%1find:%2replace:%3", "Hello World!", "Hello", "Hi"]

Replaces all occurrences in a string with given text.

string replacechar Replace characters
Version:
1.14
Input:
text: - String search in
find: - String search for
replace: - String replace with
caseSensitive: - Bool match case
matchWord: - Bool match whole words only
correspond: - Bool replace 1:1
Output:
String
example:
_text = loadFile Format ["\:string replacechar text:%1find:%2replace:%3", "filename???.txt", "?<>:|\/*""", "_"]

Replaces all occurrences of the selected characters in a string with given single character. Use matchWord: to match standalone characters. Use correspond: to replace character with corresponding character from the replace: argument. If there's no replacement match then the character will be removed.

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

Returns the number of characters in the given text. Pass string without quotation marks.

string split Split letters
Version:
1.13
Input:
text: - String source
size: - Integer segment size
limit: - Integer max number of segments
start: - Integer start position
end: - Integer end position
length: - Integer end position relative from start
Output:
Array (with strings)
example:
_array = call loadFile Format ["\:string split text:%1", "hello"]

Splits string into fragments and returns them in an array. Default segment size is 1. Default segment limit is -1 (no limit). Default start position is 0 and end position is last character.

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 items. I recommend to use string split instead.

string tokenize Split text
Version:
1.12
Input:
text: - String source
delimiter: - String split by
wordDelimiter: - Bool split by entire delimiter
caseSensitive: - Bool match case
matchWord: - Bool match whole words only
quoteSkip: - Bool skip occurences in quotes
addEmpty: - String add empty string ("start", "end", "both")
Output:
Array (strings)
example:
_array = call loadFile Format ["\:string tokenize text:%1delimiter:%2", "a1b2c3", "123"]

Splits string using given characters as delimiters and returns fragments in an array. Use wordDelimiter: argument to treat delimiter as a word. With addEmpty:start first item in the array will be empty string if the source begins with a delimiter. With addEmpty:end last item in the array will be empty string if the source ends with a delimiter.

string tolower Lowercase text
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. I recommend to use string case instead.

string toupper Uppercase text
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. I recommend to use string case instead.

string trim Remove spaces
Version:
1.12
Input:
text: - String source
left: - Bool remove leading space
right: - Bool remove trailing space
middle: - Bool remove spaces between words
middleSingle: - Bool reduce to a single space between words
Output:
String
example:
_string = loadFile Format ["\:string trim text:%1left:1 right:1", "  hello  "]

Removes whitespace from the given text according to the selected mode.

string wordpos Word search
Version:
1.15
Input:
text: - String source
Output:
Array (with integers)
example:
_positions = call loadFile Format ["\:string wordpos text:%1", "Hello World!"]

Finds positions of all words and returns them in an array.