{"name":"setObjectTextureGlobal","operator":null,"title":"setObjectTextureGlobal","type":"command","url":"https://community.bistudio.com/wiki/setObjectTextureGlobal","revid":370029,"updated":"2024-10-27T23:21:01Z","groups":["Object Manipulation"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.06"}],"since":{"game":"arma3","name":"Arma 3","version":"1.06"},"arma3_since":"1.06","branch":null,"locality":{"argument":"global","effect":"global","server_exec":false},"exec":null,"description":"Set the texture of the given selection on all computers in a network session.\n\n> [!NOTE]\n> - Not all objects can be textured this way. To find out, run getObjectTextures command on an object. Empty array `[]` usually indicates it cannot be textured.\n> - All textures must have a resolution of 2a × 2b (e.g. 16×16, 16×32, 64×256, 512×512, ...). The largest texture size supported by the RV engine is 4096×4096.\n> - Supported formats: .pac, .paa, .jpg, .jpeg, .ogg, .ogv","syntaxes":[{"syntax":"object setObjectTextureGlobal [selection, texture]","since":null,"effect":null,"exec":null,"params":[{"name":"object","type":"Object","optional":false,"default":null,"description":null,"types":["Object"],"since":null,"text":"object: Object"},{"name":"selection","type":"Number or Arma 3 v2.10 String","optional":false,"default":null,"description":"index of the selection. It is defined in the hiddenSelections array in the vehicle's config (starting with 0). If a string is given, it referes to a hiddenSelection name or clan selection instead of an index.","types":["Number","String"],"since":null,"text":"selection: Number or Arma 3 v2.10 String - index of the selection. It is defined in the hiddenSelections array in the vehicle's config (starting with 0). If a string is given, it referes to a hiddenSelection name or clan selection instead of an index."},{"name":"texture","type":"String","optional":false,"default":null,"description":"path to texture. Since Arma 3 v2.20 using **\"#reset\"** would reset to default texture.","types":["String"],"since":null,"text":"texture: String - path to texture. Since Arma 3 v2.20 using **\"#reset\"** would reset to default texture."}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"object","types":["Object"]},"right":{"text":"[selection, texture]","types":["Array"]}}],"examples":[{"text":"```sqf\nplayer setObjectTextureGlobal [0, \"\\MyAddon\\blue.paa\"];\n```","code":["player setObjectTextureGlobal [0, \"\\MyAddon\\blue.paa\"];"]},{"text":"```sqf\n// Set up a persistent texture keeper\nplayer addEventHandler [\"Take\", {\n    (getObjectTextures player + [uniformContainer player getVariable \"texture\"])\n    params [\"_texUniform\", \"_texInsignia\", \"_texCustom\"];\n    if (isNil \"_texCustom\") exitWith {};\n    if (_texUniform == _texCustom) exitWith {};\n    player setObjectTextureGlobal [0, _texCustom];\n    false\n}];\n\n// Example: make current uniform persistently blue\n\nprivate _texture = \"#(rgb,8,8,3)color(0,0,1,1)\"; // blue texture\nplayer setObjectTextureGlobal [0, _texture]; // set it on player\nuniformContainer player setVariable [\"texture\", _texture, true]; // store it on uniform\n```","code":["// Set up a persistent texture keeper\nplayer addEventHandler [\"Take\", {\n\t(getObjectTextures player + [uniformContainer player getVariable \"texture\"])\n\tparams [\"_texUniform\", \"_texInsignia\", \"_texCustom\"];\n\tif (isNil \"_texCustom\") exitWith {};\n\tif (_texUniform == _texCustom) exitWith {};\n\tplayer setObjectTextureGlobal [0, _texCustom];\n\tfalse\n}];\n\n// Example: make current uniform persistently blue\n\nprivate _texture = \"#(rgb,8,8,3)color(0,0,1,1)\"; // blue texture\nplayer setObjectTextureGlobal [0, _texture]; // set it on player\nuniformContainer player setVariable [\"texture\", _texture, true]; // store it on uniform"]}],"multiplayer":"The effect is JIP compatible.","problems":"If executed from an object's init field (which should not be done anyway for Global Effect commands), execution may happen too early and fail to broadcast over the network and to be JIP compatible.","aliases":[],"see_also":["setObjectTexture","getObjectTextures","setObjectMaterial","forceFlagTexture"],"notes":[{"user":"Killzone_Kid","date":"2016-10-24T12:13:00Z","text":"Sometimes it could be necessary to set default material on an object for the texture to take effect:\n\n```sqf\nprivate _block = createVehicle [\"Land_VR_Block_02_F\", player getPos [20, getDir player], [], 0, \"CAN_COLLIDE\"];\n_block setObjectMaterialGlobal [0, \"\\a3\\data_f\\default.rvmat\"];\n_block setObjectTextureGlobal [0, \"#(rgb,8,8,3)color(1,0,0,1)\"];\n```\n\nCourtesy of **Larrow**"},{"user":"whiztler","date":"2022-09-13T21:04:01Z","text":"Following Killzone_Kid's note, a sleep after the  setObjectMaterialGlobal and before the setObjectTextureGlobal command is sometimes needed to ensure the texture effect is  carried out correctly.\n\n```sqf\nprivate _block = createVehicle [\"Land_VR_Block_02_F\", player getPos [20, getDir player], [], 0, \"CAN_COLLIDE\"];\n_block setObjectMaterialGlobal [0, \"\\a3\\data_f\\default.rvmat\"];\nsleep 0.01;\n_block setObjectTextureGlobal [0, \"#(rgb,8,8,3)color(1,0,0,1)\"];\n```\n\nNote that you need to run above code in a scheduled environment."}],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Object Manipulation","Introduced with Arma 3 version 1.06","Scripting Commands","Scripting Commands: Global Effect"]}