{"name":"hasWeapon","operator":null,"title":"hasWeapon","type":"command","url":"https://community.bistudio.com/wiki/hasWeapon","revid":318541,"updated":"2022-05-13T09:14:18Z","groups":["Weapons","Unit Inventory"],"status":"ok","replaced_by":[],"games":[{"game":"ofp","name":"Operation Flashpoint","version":"1.00"},{"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.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":"global","effect":null,"server_exec":false},"exec":null,"description":"Checks if a unit has the given weapon in hands or on back/in holster. Weapons inside unit containers such as vest and backpack are not counted.","syntaxes":[{"syntax":"unitName hasWeapon weaponName","since":null,"effect":null,"exec":null,"params":[{"name":"unitName","type":"Object","optional":false,"default":null,"description":null,"types":["Object"],"since":null,"text":"unitName: Object"},{"name":"weaponName","type":"String","optional":false,"default":null,"description":"the name of the weapon to check for.","types":["String"],"since":null,"text":"weaponName: String - the name of the weapon to check for."}],"returns":{"type":"Boolean","types":["Boolean"],"description":"returns true if the unit has the weapon, false if not.","text":"Boolean - returns true if the unit has the weapon, false if not."},"form":"binary","operator":null,"left":{"text":"unitName","types":["Object"]},"right":{"text":"weaponName","types":["String"]}}],"examples":[{"text":"```sqf\nif !(player hasWeapon \"arifle_MX_ACO_pointer_F\") then { player addWeapon \"arifle_MX_ACO_pointer_F\" };\n```","code":["if !(player hasWeapon \"arifle_MX_ACO_pointer_F\") then { player addWeapon \"arifle_MX_ACO_pointer_F\" };"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["weapons"],"notes":[{"user":"Benargee","date":"2014-09-11T10:49:00Z","text":"This command doesn't work for Items in Arma 3, use this instead (e.g ItemGPS).\n\n```sqf\n\"ItemGPS\" in (items player + assignedItems player)\n```\n\nReturns true if unit has gps in inventory, assigned or not."}],"categories":["ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Unit Inventory","Command Group: Weapons","Introduced with Operation Flashpoint version 1.00","Operation Flashpoint: Elite: Scripting Commands","Operation Flashpoint: New Scripting Commands","Operation Flashpoint: Scripting Commands","Scripting Commands","Take On Helicopters: Scripting Commands"]}