{"name":"createVehicle","operator":null,"title":"createVehicle","type":"command","url":"https://community.bistudio.com/wiki/createVehicle","revid":377509,"updated":"2026-01-02T06:50:13Z","groups":["Object Manipulation"],"status":"ok","replaced_by":[],"games":[{"game":"ofp","name":"Operation Flashpoint","version":"1.34"},{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},{"game":"arma1","name":"Armed Assault","version":"1.00"},{"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":"ofp","name":"Operation Flashpoint","version":"1.34"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":"global","server_exec":false},"exec":null,"description":"Creates an empty object of given classname type.\nSee Arma 3: Assets / Arma 3: createVehicle/vehicles, or Category:CfgVehicles for earlier games.\n\n> [!NOTE]\n> - To create objects of type `\"Logic\"`, use createUnit.\n> - To create an editable Eden Editor entity, see create3DENEntity.\n\n> [!NOTE]\n> **Arma 3:** To avoid vehicle randomisation in Arma 3, set the `BIS_enableRandomization` variable immediately after creating the vehicle:\n>\n> ```sqf\n> private \"_vehicle\";\n> isNil { // run unscheduled\n>     _vehicle = \"C_Offroad_01_F\" createVehicle getPosATL player;\n>     _vehicle setVariable [\"BIS_enableRandomization\", false];\n> };\n> // the _vehicle variable is available after that\n> ```\n>\n> See the Arma 3: Vehicle Customisation page for more information and settings.","syntaxes":[{"syntax":"type createVehicle position","since":null,"effect":null,"exec":null,"params":[{"name":"type","type":"String","optional":false,"default":null,"description":"vehicle/object className","types":["String"],"since":null,"text":"type: String - vehicle/object className"},{"name":"position","type":"Position","optional":false,"default":null,"description":"desired placement position. If the exact position is occupied, nearest empty position is used.","types":["Position"],"since":null,"text":"position: Position - desired placement position. If the exact position is occupied, nearest empty position is used."}],"returns":{"type":"Object","types":["Object"],"description":null,"text":"Object"},"form":"binary","operator":null,"left":{"text":"type","types":["String"]},"right":{"text":"position","types":["Position"]}},{"syntax":"createVehicle [type, position, markers, placement, special]","since":null,"effect":null,"exec":null,"params":[{"name":"type","type":"String","optional":false,"default":null,"description":"vehicle/object className","types":["String"],"since":null,"text":"type: String - vehicle/object className"},{"name":"position","type":"Object, Position2D, PositionATL or PositionAGL","optional":false,"default":null,"description":"desired placement position, (PositionAGL if watercraft or amphibious)","types":["Object","Position2D","PositionATL","PositionAGL"],"since":null,"text":"position: Object, Position2D, PositionATL or PositionAGL - desired placement position, (PositionAGL if watercraft or amphibious)"},{"name":"markers","type":"Array of Strings","optional":true,"default":"`[]`","description":"if the markers array contains any markers, the position is randomly picked from array of given markers plus desired placement position.\nIf any of the markers were given z coordinate with setMarkerPos, the vehicle will also be created at given z coordinate.","types":["Array","String"],"since":null,"text":"markers: Array of Strings - (Optional, default `[]`) if the markers array contains any markers, the position is randomly picked from array of given markers plus desired placement position.\nIf any of the markers were given z coordinate with setMarkerPos, the vehicle will also be created at given z coordinate."},{"name":"placement","type":"Number","optional":true,"default":"0","description":"the vehicle is placed inside a circle with given position as center and placement as its radius.","types":["Number"],"since":null,"text":"placement: Number - (Optional, default 0) the vehicle is placed inside a circle with given position as center and placement as its radius."},{"name":"special","type":"String","optional":true,"default":"\"NONE\"","description":"can be one of the following:\n- `\"NONE\"` - will look for suitable empty position near given position (subject to other placement params) before placing vehicle there.\n- `\"CAN_COLLIDE\"` - places vehicle at given position (subject to other placement params), without checking if others objects can cross its 3D model.\n- `\"FLY\"` - if vehicle is capable of flying and has crew, it will be made airborne at default height.\nIf *special* is \"\" or not specified, default `\"NONE\"` is used.","types":["String"],"since":null,"text":"special: String - (Optional, default \"NONE\") can be one of the following:\n- `\"NONE\"` - will look for suitable empty position near given position (subject to other placement params) before placing vehicle there.\n- `\"CAN_COLLIDE\"` - places vehicle at given position (subject to other placement params), without checking if others objects can cross its 3D model.\n- `\"FLY\"` - if vehicle is capable of flying and has crew, it will be made airborne at default height.\nIf *special* is \"\" or not specified, default `\"NONE\"` is used."}],"returns":{"type":"Object","types":["Object"],"description":"created vehicle or objNull if failed","text":"Object - created vehicle or objNull if failed"},"form":"unary","operator":null,"left":null,"right":{"text":"[type, position, markers, placement, special]","types":["Array"]}}],"examples":[{"text":"```sqf\n_jeep = \"Jeep\" createVehicle position player;\n```","code":["_jeep = \"Jeep\" createVehicle position player;"]},{"text":"```sqf\n_heli = \"AH1Z\" createVehicle getMarkerPos \"hspawn\";\n```","code":["_heli = \"AH1Z\" createVehicle getMarkerPos \"hspawn\";"]},{"text":"```sqf\n_veh = createVehicle [\"ah1w\", position player, [], 0, \"FLY\"];\n```","code":["_veh = createVehicle [\"ah1w\", position player, [], 0, \"FLY\"];"]},{"text":"```sqf\n_veh = createVehicle [\"2S6M_Tunguska\", getMarkerPos \"marker1\", [\"marker2\", \"marker3\"], 0, \"NONE\"];\n```","code":["_veh = createVehicle [\"2S6M_Tunguska\", getMarkerPos \"marker1\", [\"marker2\", \"marker3\"], 0, \"NONE\"];"]},{"text":"Objects such as\n- \"test_EmptyObjectForBubbles\"\n- \"test_EmptyObjectForFireBig\"\n- \"test_EmptyObjectForSmoke\"\ncreate additional emitters, which are stored in \"effects\" variable on the object. Since Arma 3 v1.72 these emitters are automatically deleted when object is deleted\n\n```sqf\n0 spawn\n{\n    private _fire = \"test_EmptyObjectForFireBig\" createVehicle position player;\n    sleep 5;\n    deleteVehicle _fire;\n};\n```","code":["0 spawn\n{\n\tprivate _fire = \"test_EmptyObjectForFireBig\" createVehicle position player;\n\tsleep 5;\n\tdeleteVehicle _fire;\n};"]},{"text":"The following explosives (ending with `_Scripted`) can be set off by applying setDamage 1 to them for ease of scripting:\n- \"DemoCharge_Remote_Ammo_Scripted\"\n- \"SatchelCharge_Remote_Ammo_Scripted\"\n- \"ClaymoreDirectionalMine_Remote_Ammo_Scripted\"\n\n```sqf\n_claymore = \"ClaymoreDirectionalMine_Remote_Ammo_Scripted\" createVehicle position player;\n_claymore spawn\n{\n    sleep 5;\n    _this setDamage 1;\n};\n```","code":["_claymore = \"ClaymoreDirectionalMine_Remote_Ammo_Scripted\" createVehicle position player;\n_claymore spawn\n{\n\tsleep 5;\n\t_this setDamage 1;\n};"]},{"text":"Add inventory to objects without inventory:\n\n```sqf\n_boxes = \"Land_Pallet_MilBoxes_F\" createVehicle position player;\n_cargo = \"Supply500\" createVehicle [0,0,0];\n_cargo attachTo [_boxes, [0,0,0.85]];\n\n// optional for objects that can take damage\n_boxes addEventHandler [\"Killed\",\n{\n    {\n        detach _x;\n        deleteVehicle _x;\n    }\n    forEach attachedObjects (_this select 0);\n}];\n```","code":["_boxes = \"Land_Pallet_MilBoxes_F\" createVehicle position player;\n_cargo = \"Supply500\" createVehicle [0,0,0];\n_cargo attachTo [_boxes, [0,0,0.85]];\n\n// optional for objects that can take damage\n_boxes addEventHandler [\"Killed\",\n{\n\t{\n\t\tdetach _x;\n\t\tdeleteVehicle _x;\n\t}\n\tforEach attachedObjects (_this select 0);\n}];"]},{"text":"Drop player's weapon:\n\n```sqf\n_weaponHolder = \"GroundWeaponHolder_Scripted\" createVehicle position player;\nplayer action [\"DropWeapon\", _weaponHolder, currentWeapon player];\n```","code":["_weaponHolder = \"GroundWeaponHolder_Scripted\" createVehicle position player;\nplayer action [\"DropWeapon\", _weaponHolder, currentWeapon player];"]},{"text":"The following weapon holders (ending with *_Scripted*) do **not** auto-delete when empty. It is up to the mission maker to take care of these:\n- \"GroundWeaponHolder_Scripted\"\n- \"WeaponHolderSimulated_Scripted\"\n- \"Weapon_Empty\" (a special weaponholder that displays only a single weapon, even if it contains magazines for this weapon)\n\n```sqf\n0 spawn \n{\n    private _weaponHolder = createVehicle [\"Weapon_Empty\", getPosATL player, [], 0, \"CAN_COLLIDE\"];\n    _weaponHolder addWeaponCargo [\"arifle_Katiba_F\", 1];\n    hint \"You have 5 seconds to grab this weapon\";\n    sleep 5;\n    deleteVehicle _weaponHolder;\n};\n```","code":["0 spawn \n{\n\tprivate _weaponHolder = createVehicle [\"Weapon_Empty\", getPosATL player, [], 0, \"CAN_COLLIDE\"];\n\t_weaponHolder addWeaponCargo [\"arifle_Katiba_F\", 1];\n\thint \"You have 5 seconds to grab this weapon\";\n\tsleep 5;\n\tdeleteVehicle _weaponHolder;\n};"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["createVehicleLocal","create3DENEntity","createVehicleCrew","createAgent","createTrigger","createUnit","createMine","deleteVehicle","createGroup","createCenter","setVehiclePosition"],"notes":[{"user":"MrSanchez","date":"2015-08-22T13:04:00Z","text":"GroundWeaponHolder class is automatically deleted when empty after 0.5 to 1 seconds in A3 1.48. The exact delay is random but never lower than 0.50 secs after creation.\nYou can stop deletion by adding something (cargo) to it within 0.5 seconds."},{"user":"AgentRev","date":"2017-05-16T09:05:00Z","text":"For the alternative syntax, if the vehicle has `canFloat = 1;` in its config class (e.g. boats and wheeled APCs) the command expects PositionAGL,\notherwise always PositionATL."},{"user":"demellion","date":"2018-11-02T12:16:00Z","text":"**WARNING:** Do not instigate createVehicle or createVehicleLocal within a server function executed with preInit flag.\n\nThis will cause *\"You cannot play/edit this mission\"* for a vehicles compiled from a -mod and make server skip/loop that mission init."},{"user":"R3vo","date":"2019-08-10T09:10:00Z","text":"The main syntax creates vehicles at ground level ignoring the Z in *pos* and is also faster than the alternative syntax.\n\n```sqf\n\"vehclass\" createVehicle pos;\n```\n\nThis is equivalent to \n\n```sqf\ncreateVehicle [\"vehclass\", [pos select 0, pos select 1, 0], [], 0, \"NONE\"];\n```"},{"user":"DreadedEntity","date":"2022-03-13T17:22:36Z","text":"Objects are created with a vectorUp of terrain surface normal. If you are creating new buildings to add to the map, you will probably want to call setVectorUp on the newly-spawned object.\n\n```sqf\n_veh = createVehicle [/*etc...*/];\n_veh setVectorUp [0,0,1];\n```"}],"categories":["ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Object Manipulation","Introduced with Operation Flashpoint version 1.34","Operation Flashpoint: Elite: Scripting Commands","Operation Flashpoint: New Scripting Commands","Operation Flashpoint: Scripting Commands","Scripting Commands","Scripting Commands: Global Effect","Take On Helicopters: Scripting Commands"]}