Fwatch hooks file accesses made by OFP which allows you to make calls to Fwatch from OFP scripts. All commands for fwatch start with character ':', followed by a script command and possible parameters for it.
You can use both exec and loadFile commands from OFP to call Fwatch, for example:
Display fwatch version:hint loadFile ":info version"
Execute script from http://www.site.domain/something.sqs:[] exec ":file wget http://www.site.domain/something.sqs"
Conver _string to lower case:_string = call loadFile format[{:string tolower "%1"}, _string]Fwatch installation comes with an OFP addon pbo that adds a game logic to your mission editor. If you place it in your mission then the mission will not start at all for people who do not have fwatch installed. If the player has fwatch addon installed, but the fwatch hooks itself are not working then an error message will be displayed for him/her at the mission start.
The game logic also sets some global variables at init of the mission: KEG_Fwatch is true if Fwatch is active and working, KEG_Fwatch_version will include active fwatch version.
If you wish that your mission works without having fwatch installed, you can also do a check for fwatch's presence manually:
Place a file named "fwatch_check.sqf" containing the word "false" (without quotes) into your mission directory. When you try to access this file, fwatch will override it with a file containing "true". Therefore you can check Fwatch's presence with a script such as this:
_present = call loadFile "fwatch_check.sqf" ? !_present : exit ; Do things that require Fwatch here
Strings should always be in quotation marks, ie:
good:_x = call loadFile format[{:string tolower "%1"}, "HELLO"] _x = call loadFile format[{:string tolower "%1"}, _mystring] _x = call loadFile format[{:string tolower "HELLO"}] _x = call loadFile format[":string tolower ""HELLO"""]bad:_x = call loadFile format[":string tolower HELLO"] _x = call loadFile format[{:string tolower %1}, "HELLO"] _x = call loadFile format[":string tolower %1", "HELLO"]
Files can only be saved in the fwatch/mdb/ directory, all slashes and other invalid characters will be replaced with an underscore in file operations, ie:
call loadFile format[":file write /etc/passwd foo 1"]would save foo=1 to fwatch/mdb/_etc_passwd
all filenames will be automatically converted to lower case.You should always use unique filenames in file operations for you missions as missions can read, write and delete files from each other, ie:
good:call loadFile format[":file write KEG_losthope_savegame.db foo 1"] call loadFile format[":file write Kegetys_0001_savegame.db foo 1"] call loadFile format[{:file write "KEG_%1_savegame.db" %2 %3}, missionName, "foo", foo]bad:call loadFile format[":file write savegame.db foo 1"]
OFP will crash if you try to use loadfile or exec with a filename longer than 132 characters.
Be careful with the usage of file 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.
The asynchronous input commands do not know what script called them, so having multiple scripts running at the same time using them can cause keystrokes to be missed.
info version
info debugout
string first
string last
string index
string length
string range
string tolower
string toupper
string toarray
file exists
file write
file awrite
file qwrite
file read
file vars
file readvars
file remove
file delete
file wget
input getkeys
input getkey
input agetkeys
input agetkey
input getmouse
input setmouse
db set
db get
db clear