csk222 23 Posted December 21, 2015 Hello. How do I remove a players Primary Weapon ammo/magazine? I used to replace all gear, items, and weapons but now I am experimenting with only replacing the primary weapon so players can still keep their custom uniforms. The following code works as planned but it still leaves the old primary weapons magazines in the players inventory. How do I get rid of them? Note: There is no way of telling what weapon a player may be using at any given time so its not like I can remove a specific ammo type. private ["_soldier"]; _soldier = _this select 0; if(local _soldier) then { // Remove Primary Weapon _soldier removeWeapon (primaryWeapon _soldier); // Add Primary Weapon _soldier addMagazines ["10Rnd_338_Mag",4]; _soldier addweapon "srifle_DMR_02_F"; _soldier addPrimaryWeaponItem "optic_Nightstalker"; _soldier addPrimaryWeaponItem "muzzle_snds_338_black"; _soldier addPrimaryWeaponItem "bipod_01_F_blk"; _soldier addPrimaryWeaponItem "acc_pointer_IR"; }; Share this post Link to post Share on other sites
Joe98 92 Posted December 21, 2015 removeallweapons this: Then add the specific weapon. You must add the magazines before the rifle. Other wise the mission starts and the weapon is not loaded. . Share this post Link to post Share on other sites
csk222 23 Posted December 21, 2015 removeallweapons this; removes all weapons including sidearm, explosives, and launchers. I'm looking for a way to just remove primary weapon ammo/magazines. This is the original code: Where I remove and reassign everything. I want to just replace the primary weapon and remove any "old" primary weapon ammo /* Author: Cobra [BOMSF] 1949-2014 cobra@bomsf.com - www.bomsf.com You may re-use any of this work as long as you provide credit back to me. Contact bomsfARMA3@gmail.com Edit By CSK222 Soldier Loadouts Class: Sniper Weapons: Mar10 .338 */ private ["_soldier"]; _soldier = _this select 0; if(local _soldier) then { // Remove original equipment removeAllWeapons _soldier; removeAllAssignedItems _soldier; removeAllContainers _soldier; // Add clothing _soldier adduniform "U_B_CombatUniform_mcam"; _soldier addvest "V_PlateCarrier1_blk"; _soldier addheadgear "H_HelmetB_light_black"; _soldier addGoggles "G_Tactical_Black"; _soldier addbackpack "B_Kitbag_rgr"; // Add to Backpack (unitBackpack _soldier) additemCargo ["FirstAidKit",2]; (unitBackpack _soldier) additemCargo ["SmokeShell",2]; (unitBackpack _soldier) addmagazineCargo ["handgrenade",2]; (unitBackpack _soldier) addmagazineCargo ["SatchelCharge_Remote_Mag",1]; // Add to Vest _soldier addItemToVest "optic_Hamr"; _soldier addItemToVest "optic_AMS"; _soldier addItemToVest "optic_KHS_blk"; _soldier addItemToVest "optic_SOS"; _soldier addItemToVest "optic_LRPS"; _soldier addItemToVest "optic_Arco"; _soldier addItemToVest "optic_MRCO"; _soldier addItemToVest "optic_DMS"; // Primary Weapon _soldier addMagazines ["10Rnd_338_Mag",4]; _soldier addweapon "srifle_DMR_02_F"; _soldier addPrimaryWeaponItem "optic_Nightstalker"; _soldier addPrimaryWeaponItem "muzzle_snds_338_black"; _soldier addPrimaryWeaponItem "bipod_01_F_blk"; _soldier addPrimaryWeaponItem "acc_pointer_IR"; // Pistol _soldier addMagazines ["11Rnd_45ACP_Mag", 3]; _soldier addweapon "hgun_Pistol_heavy_01_F"; _soldier addHandgunItem "muzzle_snds_acp"; _soldier addHandgunItem "optic_MRD"; // Grenades _soldier addMagazines ["HandGrenade",8]; // Laser Designator _soldier addMagazines ["Laserbatteries",1]; _soldier addweapon "Laserdesignator"; // Add & Assign Items _soldier additem "NVGoggles"; _soldier additem "ItemCompass"; _soldier additem "itemmap"; _soldier additem "itemradio"; _soldier additem "itemwatch"; _soldier assignitem "NVGoggles"; _soldier assignitem "itemcompass"; _soldier assignitem "itemmap"; _soldier assignitem "itemradio"; _soldier assignitem "itemwatch"; // UAV Terminal _soldier linkItem "B_UavTerminal"; // Insignia [_soldier,"BOMSF"] call bis_fnc_setUnitInsignia; }; Share this post Link to post Share on other sites
Larrow 2822 Posted December 22, 2015 { if ( _x in primaryWeaponMagazine _soldier ) then { _soldier removeMagazine _x } } forEach magazines _soldier; _soldier removeWeapon primaryWeapon _soldier; Share this post Link to post Share on other sites
777eza 10 Posted December 22, 2015 When you say custom uniforms, are they getting them via virtual arsenal. If so you could always just whitelist items in the virtual arsenal you want them to use. Share this post Link to post Share on other sites
csk222 23 Posted December 22, 2015 Thanks for the response but larrow had the answer I was looking for. It works so far in the editor but I haven't uploaded/tested the mission on the dedicated server yet. I'm sure it will work though. Share this post Link to post Share on other sites
cthulhu616 3 Posted December 22, 2015 { if ( _x in primaryWeaponMagazine _soldier ) then { _soldier removeMagazine _x } } forEach magazines _soldier; _soldier removeWeapon primaryWeapon _soldier; This is one way, but if the player has other magazines (One weapon can load multiple types of magazines) or has no magazines loaded, it won't work. so get all attachable magazines from the config and delete them. grz Share this post Link to post Share on other sites
Larrow 2822 Posted December 22, 2015 but if the player has other magazines (One weapon can load multiple types of magazines) or has no magazines loaded, it won't work.This is true, primaryWeaponMagazines will only return all currently loaded magazines of each muzzle of the weapon. _compatibleMags = []; { _mags = []; if ( _x != "this" ) then { _mags = getArray( configFile >> "CfgWeapons" >> primaryWeapon _soldier >> _x >> "magazines" ); }else{ _mags = getArray( configFile >> "CfgWeapons" >> primaryWeapon _soldier >> "magazines" ); }; _compatibleMags = _compatibleMags + _mags; }forEach getArray( configFile >> "CfgWeapons" >> primaryWeapon _soldier >> "muzzles" ); { if ( _x in _compatibleMags ) then { _soldier removeMagazine _x; } } forEach magazines _soldier; _soldier removeWeapon primaryWeapon _soldier; 1 Share this post Link to post Share on other sites
csk222 23 Posted December 22, 2015 cthulhu616 thanks for bringing that up. I tested the previous code with the MK20 and it left the other tracer magazines in the inventory. larrow thank you for the latest update - it works. Share this post Link to post Share on other sites
killzone_kid 1332 Posted December 22, 2015 If you use "DropWeapon" action, the all relevant magazines are removed automatically. However there are 2 disadvantages with this method:1. you need weaponholder or container to put the weapon to 2. it plays animation Share this post Link to post Share on other sites
flymaker 15 Posted November 26, 2016 Hello everyone. Sorry for revive this topic.I'm making use of Larrow code and need some adjustments. I cant know how do thatWhat i need for now is count every ammo amount. Something like that:Ammo_MxGL = 5 MagazinesAmmo_MxGL Tracer Red = 2 MagazinesAmmo_MxGL Launcher = 3 MagazinesI'm trying to replace the weapon with the exactly counter part ammo. Share this post Link to post Share on other sites
warbirdguy1 14 Posted March 9, 2017 Placed this in the units init player setAmmo [currentWeapon player, 0]; player addMagazine "rhs_magazine_rhs_mag_556x45_30Rnd_M200_Stanag"; So far my attempt to remove the magazine from the primary weapon and add a magazine to the vest of the player that I want instead. I can drain the players ammo via the player setAmmo [currentWeapon player, 0]; in the unit init but can not load a magazine into their vest or weapon. Any ideas how to do so? I am at a bit of a loss. Share this post Link to post Share on other sites
serena 151 Posted March 9, 2017 warbirdguy1, look: // how-to add number of magazines to player vest: vestContainer player addMagazineCargo ["HandGrenade", 100]; // how-to load magazine directly to player primary weapon: player addPrimaryWeaponItem "30Rnd_65x39_caseless_mag"; // replace with your weapon compatible magazine type Share this post Link to post Share on other sites
Asmodeuz 54 Posted January 21, 2018 Hello, my issue is almost in the same vein as the OP so I hope it is ok that I bring this one to life. The version below that Larrow provided already some time ago removes all the magazines that are in the players inventory but still leaves a magazine attached to the players weapon On 22/12/2015 at 2:21 AM, Larrow said: { if ( _x in primaryWeaponMagazine _soldier ) then { _soldier removeMagazine _x } } forEach magazines _soldier; I found another version (also by Larrow :) ) where primaryWeaponMagazine is used, see https://forums.bohemia.net/forums/topic/157990-primaryweaponmagazine/?tab=comments#comment-2481601 priMag = primaryWeaponMagazine player; player removeMagazine (priMag select 0); This version removes one magazine from the player though I'm not sure if it's the magazine that's attached to the current primary weapon or a magazine that's in the player inventory. Either way that script does not leave the player's weapon unloaded (as in: without an attached magazine). Is there any actual way to remove the currently attached magazine/clip from a player's weapon thus leaving it unloaded? Should be possible with primaryWeaponMagazine ? Share this post Link to post Share on other sites