M1ke_SK 230 Posted February 28, 2016 Hi, I am searching for way to check if script exist in mission, and if does, execute it. Example: params ["_faction", "_mission"]; _path = format ["scripts\missions\%1\%2.sqf", _faction, _mission]; _condition = ""; //here put condition to check if file exist if(_condition) then { //script exist [] call compile preProcessFileLineNumbers _path; } else { //script does not exist }; Share this post Link to post Share on other sites
cuel 25 Posted February 28, 2016 This is not really possible in a good way. I think there's one way, and that's to use try-catch with loadFile Result should be empty string if not exists, and also notice that you can't use backslash comments Share this post Link to post Share on other sites
M1ke_SK 230 Posted February 28, 2016 possible to run use it with preProcessFileLineNumbers ? Share this post Link to post Share on other sites
killzone_kid 1330 Posted February 28, 2016 Far from perfect but http://killzonekid.com/arma-scripting-tutorials-kk_fnc_fileexists/ But I think now it may also be subject to whether or not filePatching is allowed. 2 Share this post Link to post Share on other sites
TheDusty01 3 Posted August 26, 2018 I know very late answer but maybe useful for future readers. Code: _pth = "pathToFile.sqf"; // Works with images (.paa) aswell if ((loadFile _pth) isEqualTo "") exitWith {}; // File does not exist Hope I was able to help someone :) 2 Share this post Link to post Share on other sites
M1ke_SK 230 Posted August 26, 2018 1 minute ago, TheDusty01 said: I know very late answer but maybe useful for future readers. Code: _pth = "pathToFile.sqf"; // Works with images (.paa) aswell if ((loadFile _pth) isEqualTo "") exitWith {}; // File does not exist Hope I was able to help someone :) 1.90 yay ! 1 Share this post Link to post Share on other sites
HazJ 1289 Posted September 27, 2018 This works with external files too run on server but sadly requires -allowFilePatching to find them. // initServer.sqf authenticatedDevs = []; publicVariable "authenticatedDevs"; _filePath = "\Authority\authenticatedDevs.sqf"; if !(loadFile _filePath isEqualTo "") then { call compile preprocessFileLineNumbers _filePath; } else { diag_log format ["#### %1 WAS NOT FOUND ###", _filePath]; }; Not really a big deal as popup file not found only appears on server. 2 Share this post Link to post Share on other sites
M1ke_SK 230 Posted December 18, 2018 No more usable for me as it throws error :/ when no file found Share this post Link to post Share on other sites
sarogahtyp 1108 Posted August 5, 2021 On 8/26/2018 at 1:40 PM, TheDusty01 said: I know very late answer but maybe useful for future readers. Code: _pth = "pathToFile.sqf"; // Works with images (.paa) aswell if ((loadFile _pth) isEqualTo "") exitWith {}; // File does not exist Hope I was able to help someone 🙂 since 2.02 use: fileExists 2 Share this post Link to post Share on other sites