{"name":"playScriptedMission","operator":null,"title":"playScriptedMission","type":"command","url":"https://community.bistudio.com/wiki/playScriptedMission","revid":369272,"updated":"2024-09-03T18:42:43Z","groups":["System"],"status":"ok","replaced_by":[],"games":[{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma2","name":"Arma 2","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Load the given world, launch an empty mission, and execute the given expression.\nIf provided, *config* can reference to the config entry, replacing Description.ext for this mission.","syntaxes":[{"syntax":"playScriptedMission [world, expression, config, ignoreChildWindow]","since":null,"effect":null,"exec":null,"params":[{"name":"world","type":"String","optional":false,"default":null,"description":null,"types":["String"],"since":null,"text":"world: String"},{"name":"expression","type":"Code","optional":false,"default":null,"description":null,"types":["Code"],"since":null,"text":"expression: Code"},{"name":"config","type":"Config","optional":true,"default":null,"description":null,"types":["Config"],"since":null,"text":"config: Config - (Optional)"},{"name":"ignoreChildWindow","type":"Boolean","optional":true,"default":null,"description":null,"types":["Boolean"],"since":null,"text":"ignoreChildWindow: Boolean - (Optional)"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"unary","operator":null,"left":null,"right":{"text":"[world, expression, config, ignoreChildWindow]","types":["Array"]}}],"examples":[{"text":"```sqf\nplayScriptedMission\n[\n    \"desert_e\",\n    {\n        execVM \"\\ca\\missions_e\\data\\scenes\\credits1\\init.sqf\";\n    },\n    configFile / \"CfgMissions\" / \"Cutscenes\" / \"Credits\"\n];\n```","code":["playScriptedMission\n[\n\t\"desert_e\",\n\t{\n\t\texecVM \"\\ca\\missions_e\\data\\scenes\\credits1\\init.sqf\";\n\t},\n\tconfigFile / \"CfgMissions\" / \"Cutscenes\" / \"Credits\"\n];"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["hostMission","playMission","createMissionDisplay","createMPCampaignDisplay"],"notes":[{"user":"SkaceKachna","date":"2015-12-31T17:55:00Z","text":"For this command to work, you will need to:\n1. call command with ignoreChildWindow param set to true (in VBS docs its called fromMission)\n1. close any opened display (not sure about this part, but closing every display (but #0) seems to work):\n  - if mission is run from 2D editor, you can just close RscDisplayArcadeMap display (idd 26) (because this was done from 2D editor, so RscDisplayArcadeMap is still active in background -- benargee)\n  - if mission is run from single mission browser, you can just close RscDisplaySingleMission (idd 2)\n1. end mission\n\nDebriefing will show and player will be moved to new mission after clicking on Continue.\n\nCommand is a bit bugged:\n- third (config) param doesn't seem to work\n- if you run this command in mission loaded from pbo, said pbo won't be writable until you close the game (you can't update it)\n\nFollowing code will change change island to Stratis and spawns player as basic soldier at [0,0,0] coordinates.\n\n```sqf\ndisableSerialization;\nplayScriptedMission ['Stratis', {\n    private _grp = createGroup west;\n    private _player = _grp createUnit [\"B_Soldier_F\", [0,0,0], [], 0, \"NONE\"];\n    selectPlayer _player;\n}, missionConfigFile, true];\n\n// Close all displays that could be the background display ... this is essentially forceEnd command\n// Closing #0 will cause game to fail\n_zero = findDisplay 0;\n{\n    if (_x != _zero) then {\n        _x closeDisplay 1;\n    };\n} foreach allDisplays;\nfailMission \"END1\";\n```\n\n(tested in Arma 3 1.54.133741)"}],"categories":["Arma 2: New Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: System","Introduced with Arma 2 version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}