{"name":"createVehicle","title":"createVehicle","type":"command","url":"https://community.bistudio.com/wiki/createVehicle","revid":377509,"updated":"2026-01-02T06:50:13Z","groups":["Object Manipulation"],"status":"ok","games":{"ofp":"1.34","ofpe":"1.00","arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"ofp 1.34","arma3_since":"0.50","locality":{"effect":"global"},"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","params":[{"name":"type","type":"String","description":"vehicle/object className","type_expr":"String"},{"name":"position","type":"Position","description":"desired placement position. If the exact position is occupied, nearest empty position is used.","type_expr":"Position"}],"returns":{"type":"Object","type_expr":"Object"},"form":"binary","left":{"text":"type"},"right":{"text":"position"}},{"syntax":"createVehicle [type, position, markers, placement, special]","params":[{"name":"type","type":"String","description":"vehicle/object className","type_expr":"String"},{"name":"position","type":"Object, Position2D, PositionATL or PositionAGL","description":"desired placement position, (PositionAGL if watercraft or amphibious)","type_expr":"Object | Position2D | PositionATL | PositionAGL"},{"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.","type_expr":"Array<String>","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.","type_expr":"Number","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\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.\n\nIf *special* is \"\" or not specified, default `\"NONE\"` is used.","type_expr":"String","text":"special: String - (Optional, default \"NONE\") can be one of the following:\n\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.\n\nIf *special* is \"\" or not specified, default `\"NONE\"` is used."}],"returns":{"type":"Object","type_expr":"Object","description":"created vehicle or objNull if failed"},"form":"unary","right":{"text":"[type, position, markers, placement, special]"}}],"examples":[{"code":["_jeep = \"Jeep\" createVehicle position player;"]},{"code":["_heli = \"AH1Z\" createVehicle getMarkerPos \"hspawn\";"]},{"code":["_veh = createVehicle [\"ah1w\", position player, [], 0, \"FLY\"];"]},{"code":["_veh = createVehicle [\"2S6M_Tunguska\", getMarkerPos \"marker1\", [\"marker2\", \"marker3\"], 0, \"NONE\"];"]},{"text":"Objects such as\n\n- \"test_EmptyObjectForBubbles\"\n- \"test_EmptyObjectForFireBig\"\n- \"test_EmptyObjectForSmoke\"\n\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\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\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};"]}],"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.\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```"}]}