{"name":"disableSerialization","operator":null,"title":"disableSerialization","type":"command","url":"https://community.bistudio.com/wiki/disableSerialization","revid":369064,"updated":"2024-09-02T20:24:56Z","groups":["Namespaces","GUI Control"],"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":"Disable saving of script containing this command. After this, the script can work with data types which do not support serialization (UI types).\n\n> [!NOTE]\n> See Namespace serialization for more information.\n\n> [!IMPORTANT]\n> **In Arma 2** and up to a certain version of Arma 3, giving a Display or Control to spawned code would raise an error due to the usage of the then non-serializable `_this` variable. Using disableSerialization or uiNamespace wouldn't help; the trick here is to pass the argument inside an array:\n>\n> ```sqf\n> _display = findDisplay 46;\n>  _display  spawn { hint str _this; };                // would raise a serialization error\n> [_display] spawn { hint str (_this select 0); };    // OK\n> ```","syntaxes":[{"syntax":"disableSerialization","since":null,"effect":null,"exec":null,"params":[],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"nullary","operator":null,"left":null,"right":null}],"examples":[{"text":"```sqf\ndisableSerialization;\nprivate _display = findDisplay 46;\n```","code":["disableSerialization;\nprivate _display = findDisplay 46;"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["Display","displayAddEventHandler","displayRemoveAllEventHandlers","displayRemoveEventHandler","uiSleep"],"notes":[{"user":"Str","date":"2010-06-19T10:26:00Z","text":"Can be used to detecting load. Scope with disabled serialization is discontinued after load, even if there's endless loop inside.\n\n```sqf\n0 spawn { disableSerialization; waitUntil { false }; hint \"Game was loaded!\";};\n```\n\nWorks for all possible load types - loading user save, loading autosave and resuming mission from main menu.\n\nUse with caution, as it creates an infinite loop, having impact at overall scripting time."},{"user":"Killzone_Kid","date":"2013-10-23T02:57:00Z","text":"If you do not store UI elements (Display, Control) in variables, you do not need disableSerialization; UI elements are usually returned by scripting commands such as findDisplay or passed as params in UI event handler scripts (displayAddEventHandler, ctrlAddEventHandler).\n\nThis code will require disableSerialization:\n\n```sqf\ndisableSerialization;\n_display = findDisplay 123;\n_ctrl = _display displayCtrl -1;\n_ctrl ctrlSetText \"LOL\";\n```\n\nThis code will not:\n\n```sqf\nfindDisplay 123 displayCtrl -1 ctrlSetText \"LOL\";\n```"},{"user":"Nelis75733126","date":"2017-06-25T18:15:00Z","text":"In Arma 3 1.74, a scripted FSM is somehow incompatible with `disableSerialization`.\n\nAs a workaround, store a display inside an array. Example:\n\n```sqf\n_display = [findDisplay idd];\n```"}],"categories":["Arma 2: New Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: GUI Control","Command Group: Namespaces","Introduced with Arma 2 version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}