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.
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 ...
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:
- make sure you're starting the game with the fwatch.exe or fwatchCWA.exe
- if the string is missing from your stringtable.csv then add it
- use original stringtable.csv (e.g. remove it from the modfolders that you're running)
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.
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
All command parameters are required unless stated otherwise. They must be written in the specified order.
for example:
loadFile ":file write test.db foo 1"
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
New commands that use only one, string-type parameter do not require this (it's indicated in the description).
loadFile Format [{:file read "%1" %2}, "My File.txt", "foo"] - correct
loadFile Format [":file read %1 %2", "My File.txt", "foo"] - incorrect
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"
To assign that array to a variable use call command:
_lock = "[true,false,false]"_lock = call loadFile ":info lock"
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.
_lock = [true,false,false]
Staying Within The Character Limitation
How to count used space:Example code:
To work around the limitation use ExecCommand function.
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
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.
- in the output array (see "Output" section in the command description)
- in the _fwatch_error local variable (is only set when an error has occured; must be declared prior to using commands). Global variable FWATCH_ERROR is assigned to point to this array.
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.
- 0 - bool indicating if the operation was completed
- 1 - Fwatch error code number. See list
- 2 - WINAPI, SHFileOperation or errno error code number
- 3 - error description
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 getjoystick
This commands reads joystick input using Windows API.
- Can select which joystick to read (one from max 16 connected)
- Supports up to 6 axes, 32 buttons, digital/analog POV
- Displays numbers for joystick identification
- Queries axes names
- Axes value range is from 0 to 65535
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:
31500 0 4500 27000 65535 9000 22500 18000 13500
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.
- Supports one joystick
- Supports up to 4 axes, 8 buttons, digital POV
- Axes values range from -1 to 1. Step is 0.01
- Has a deadzone
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 + LCTRL RALT US International US Czech Russian Finnish French German Spanish Polish UK Italian
More on AltGr you'll find on Wikipedia.
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)Animation codes may be different if you'll use addons which add new animations.
2. Self-dependent addons (in alphabetical order).
3. Addons requiring other addons (in alphabetical order).
Code list for Operation Flashpoint: Resistance 1.96 including all original addons: view.
Use Animation Viewer script to preview them in the game.
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
pathScripts
ErrorLog
InputMulti
MemMulti
onScreenTyping
- In OFP calling functions and reading files halts the game. Everytime you call Fwatch the game is frozen until the operation is completed. If there are many Fwatch commands executed at once the game will slow down. Avoid redundant calls.
- For the same reason (avoiding redundancy) use scripts InputMulti.sqs and MemMulti.sqs when you require input and game information.
- When saving to fwatch\mdb\: if possible store your variables in a single file. To load them all use :file readvars instead of using :file read for each one.
- Use unique filenames in file operations for your missions as they can read, write and delete files from each other.
- If you're storing multiple files in the fwatch\idb\ directory create a sub-folder and move them there to keep things tidy.
- Be careful with the usage of wget, especially in multiplayer missions as it can easily cause large amounts of requests to the web server. For example if you do a request at the start of a MP mission, running the script on all players in a 20 player multiplayer game there will instantly be 21 requests made to the web server once the mission starts.
- Pay special attention to where you need to run the scripts in a multiplayer game, for example if you are saving a variable to a file it maybe isn't necessary to save it anywhere else than in the server machine.
- Even if your multiplayer mission requires Fwatch still provide some functionality for the users who doesn't have it (e.g. spectator mode).
- When you use commands that make permanent changes (like :mem setgraphics or :mem bullets) bring back original settings before the end of the mission.
command | description |
class list |
Class names
example:
_ok = call loadFile ":class list ""f:mission.sqm"" c:[Mission,Vehicles]" Parses given file that contains classes and returns:
|
class modify |
Modify class
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
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
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
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
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
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
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
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
example:
_text = loadFile ":clipboard get" Returns text stored in the Windows clipboard. |
clip getline |
Clipboard lines
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
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
example:
_ok = call loadFile ":clip size" Returns number of characters and number of lines stored in Windows clipboard. |
clip tofile |
Save clipboard text
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
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
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:
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
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
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
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
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
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
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
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
example:
_dxdll = call loadFile ":file dxdll" Check if d3d8.dll file is in the game directory. |
file execute |
Command from file
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
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
example:
_mods = call loadFile ":file modlist" Returns list of modfolders in the game directory. |
file qwrite |
Write variable quickly
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
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
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
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
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
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
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
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
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
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:
|
ic |
IGSE Copy
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
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
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
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:
|
io |
IGSE load
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
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
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
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
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
example:
loadFile ":info debugout testing"
Output Win32 debug string. |
info resolution |
Screen resolution
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
example:
_ok = call loadFile ":info starttime" Returns information when the game process started. |
info version |
Fwatch 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
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
example:
_keys = call loadFile ":input agetkeys" This is an asynchronous version of the :input getkeys. |
input getjoystick |
Joystick input
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
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
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
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
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
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
example:
loadFile ":input setmouse 500 300" Sets Windows mouse cursor position to the given coordinates. |
mem bullets |
Projectiles properties
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
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
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
example:
_border = call loadFile ":mem getcinemaborder" Reads value from the memory indicating whether cutscene borders are enabled. |
mem getcursor |
Cursor position
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
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
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
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
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
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
example:
_map = call loadFile ":mem getmap" Reads value from the memory indicating whether 2D island map is displayed. |
mem getnv |
Is NV displayed
example:
_isNV = call loadFile ":mem getnv" Reads value from the memory indicating whether player is using nightvision goggles. |
mem getplayeraim |
Aim angle
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
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
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
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
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
example:
_isRadio = call loadFile ":mem getradiobox" Reads from the memory value indicating if radio menu is displayed. |
mem getrespawntype |
Respawn type
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
example:
_resistance = loadFile ":mem getresside" Reads value from the memory indicating with whom resistance units are friendly. |
mem getscroll |
Mouse scroll
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
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
example:
_island = loadFile ":mem getworld" Reads island shortcut name from the memory. |
mem isdialog |
Are dialogs displayed
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
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
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
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
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
example:
loadFile ":mem setcursor 0.5 0.5" Changes dialog cursor position by writing values to the memory. |
mem setdifficulty |
Change difficulty
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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:
|
string first |
First occurrence
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
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
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
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
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
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
example:
_text = call loadFile Format [{:string tolower "%1"}, "HELLO"] Returns string (wrapped in quotation marks) in lower case. |
string toupper |
Convert to upper case
example:
_text = call loadFile Format [{:string toupper "%1"}, "hello"] Returns string (wrapped in quotation marks) in upper case. |
stw |
String trim whitespace
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:
|
sv |
String variable
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
example:
_text = loadFile Format [":swuL %1", "Hello World!"] Transforms letters in a string to lower or uppercase depending on the selected mode:
|
s[ |
Split letters
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. |