{"name":"startLoadingScreen","title":"startLoadingScreen","type":"command","url":"https://community.bistudio.com/wiki/startLoadingScreen","revid":369458,"updated":"2024-09-06T08:44:54Z","groups":["System"],"status":"ok","games":{"arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"arma2 1.00","arma3_since":"0.50","description":"Shows loading screen with the given text, using the given resource.\nWhile loading screen is shown, simulation and scene drawing is disabled, user control is disabled, mouse cursor is hidden, scripts run at full speed (50ms per frame instead of 3ms per frame for Scheduled Scripts).\n\n> [!NOTE]\n> By default, startLoadingScreen will use \"RscDisplayNotFreeze\" resource.\n>\n> A custom resource can be defined in Description.ext, and a full black background will be used by default - the following controls are supported by the engine:\n>\n> - idc = 101 - text (type = 0) or picture (type = 48). The text will be set to the value provided by the command argument.\n> - idc = 103 - progress (type = 8) or animated texture (type = 45). This control indicates global hardcoded mission loading progress and is useless after the mission is loaded.\n> - idc = 104 - progress (type = 8). This control's progress is initially set to 0 and can be manipulated with progressLoadingScreen command.\n>\n> Resource can be defined in Description.ext; it must NOT be defined as `RscTitles`!\n>\n> ```cpp\n> // basic defines - pre \"import\" keyword in v2.02\n> class RscText\n> {\n>     type = 0;\n>     idc = -1;\n>     x = 0;\n>     y = 0;\n>     h = 0.037;\n>     w = 0.3;\n>     style = 0x100;\n>     font = Zeppelin32;\n>     SizeEx = 0.03921;\n>     colorText[] = { 1, 1, 1, 1 };\n>     colorBackground[] = { 0, 0, 0, 0 };\n>     linespacing = 1;\n> };\n>\n> class RscPicture\n> {\n>     access = 0;\n>     type = 0;\n>     idc = -1;\n>     style = 48;\n>     colorBackground[] = { 0, 0, 0, 0 };\n>     colorText[] = { 1, 1, 1, 1 };\n>     font = \"TahomaB\";\n>     sizeEx = 0;\n>     lineSpacing = 0;\n>     text = \"\";\n> };\n>\n> class RscLoadingText : RscText\n> {\n>     style = 2;\n>     x = 0.323532;\n>     y = 0.666672;\n>     w = 0.352944;\n>     h = 0.039216;\n>     sizeEx = 0.03921;\n>     colorText[] = { 0.543, 0.5742, 0.4102, 1.0 };\n> };\n>\n> class RscProgress\n> {\n>     x = 0.344;\n>     y = 0.619;\n>     w = 0.313726;\n>     h = 0.0261438;\n>     texture = \"\\ca\\ui\\data\\loadscreen_progressbar_ca.paa\";\n>     colorFrame[] = { 0, 0, 0, 0 };\n>     colorBar[] = { 1, 1, 1, 1 };\n> };\n>\n> class RscProgressNotFreeze\n> {\n>     idc = -1;\n>     type = 45;\n>     style = 0;\n>     x = 0.022059;\n>     y = 0.911772;\n>     w = 0.029412;\n>     h = 0.039216;\n>     texture = \"#(argb,8,8,3)color(0,0,0,0)\";\n> };\n>\n> // end of basic defines\n>\n> class WIKI_loadingScreen\n> {\n>     idd = -1;\n>     duration = 10e10;\n>     fadein = 0;\n>     fadeout = 0;\n>     name = \"loading screen\";\n>     class controlsBackground\n>     {\n>         class blueBackground : RscText // covers the black screen\n>         {\n>             x = safezoneXAbs;\n>             y = safezoneY;\n>             w = safezoneWAbs;\n>             h = safezoneH;\n>             text = \"\";\n>             colorText[] = { 0, 0, 0, 0 };\n>             colorBackground[] = { 0, 0, 1, 1 };\n>         };\n>\n>         class nicePic : RscPicture\n>         {\n>             style = 48 + 0x800; // ST_PICTURE + ST_KEEP_ASPECT_RATIO\n>             x = safezoneX + safezoneW/2 - 0.25;\n>             y = safezoneY + safezoneH/2 - 0.2;\n>             w = 0.5;\n>             h = 0.4;\n>             text = \"img\\nicePic.paa\";\n>         };\n>     };\n>\n>     class controls\n>     {\n>         class Title1 : RscLoadingText\n>         {\n>             text = \"$STR_LOADING\"; // \"Loading\" text in the middle of the screen\n>         };\n>\n>         class CA_Progress : RscProgress // progress bar, has to have idc 104\n>         {\n>             idc = 104;\n>             type = 8; // CT_PROGRESS\n>             style = 0; // ST_SINGLE\n>             texture = \"\\ca\\ui\\data\\loadscreen_progressbar_ca.paa\";\n>         };\n>\n>         class CA_Progress2 : RscProgressNotFreeze // progress bar that will go reverse\n>         {\n>             idc = 103;\n>         };\n>\n>         class Name2 : RscText // the text on the top-left\n>         {\n>             idc = 101;\n>             x = 0.05;\n>             y = 0.029412;\n>             w = 0.9;\n>             h = 0.04902;\n>             text = \"\";\n>             sizeEx = 0.05;\n>             colorText[] = { 0.543, 0.5742, 0.4102, 1.0 };\n>         };\n>     };\n> };\n> ```\n\n> [!WARNING]\n> - The loading screen does **not** end by itself and absolutely needs a call to endLoadingScreen command\n> - Game simulation is disabled during Loading Screen operation (at least in single player):\n>   - do **not** use the sleep command between startLoadingScreen and endLoadingScreen as **it may freeze the game** - use uiSleep instead\n>   - waitUntil *can* be used to wait for variable initialisation or script loading\n\n> [!NOTE]\n> **Arma 3:**\n>\n> - Use BIS_fnc_startLoadingScreen to prevent potential usage conflicts.\n> - The loading screen can be force-ended with the ENDLOAD cheat code.","syntaxes":[{"syntax":"startLoadingScreen [text, resource]","params":[{"name":"text","type":"String","type_expr":"String"},{"name":"resource","type":"String","optional":true,"type_expr":"String","text":"resource: String - (Optional)"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"unary","right":{"text":"[text, resource]"}}],"examples":[{"code":["startLoadingScreen [\"Loading My Mission, please wait...\"];"]},{"code":["startLoadingScreen [\"Can't skip loading time...\", \"MyLoadingRsc\"];"]},{"code":["startLoadingScreen [\"Loading My Mission\"];\n// code\nprogressLoadingScreen 0.5;\n// code\nendLoadingScreen;"]},{"text":"```sqf\n// this structure prevents error-prone or lengthy code to miss endLoadingScreen.\nprivate _maxTime = diag_tickTime + 30; // max 30s of loading\n\nstartLoadingScreen [\"Loading\"];\nprivate _handle = 0 spawn {\n    // code that may crash or take too long\n};\n\nwaitUntil { uiSleep .1; scriptDone _handle || diag_tickTime > _maxTime };\nendLoadingScreen;\n```","code":["// this structure prevents error-prone or lengthy code to miss endLoadingScreen.\nprivate _maxTime = diag_tickTime + 30; // max 30s of loading\n\nstartLoadingScreen [\"Loading\"];\nprivate _handle = 0 spawn {\n\t// code that may crash or take too long\n};\n\nwaitUntil { uiSleep .1; scriptDone _handle || diag_tickTime > _maxTime };\nendLoadingScreen;"]}],"see_also":["endLoadingScreen","progressLoadingScreen","BIS_fnc_startLoadingScreen","import (Config)"],"notes":[{"user":"Killzone_Kid","date":"2015-11-21T18:38:00Z","text":"The default Arma 3 loading screen has no control to display text."}]}