Thursday 27 June 2013

Remove Clothing, Gear and Weapons From Your Character

Often when editing loadouts for ArmA 3, just adding the new item on top of an old one may cause the old item to just sit on the floor. This can get annoying, especially when rearming an entire platoon or squad. The simple way to prevent this is to write a single line of code to remove the item before adding a new one. If the item doesn't exist, it can't create litter. The line in question is this:

removeHeadgear unit;

The first component, removeHeadgear, is the actual command that describes what is to be removed from the following component. The following component, unit, details which solider the command will affect, in this case, to remove any headgear he may be wearing.

This line is placed in the INIT line (shown below):
There are a few options for the unit component that will allow for tweaking of who is affected by the command. Perhaps the easiest one to learn and use is this. It will run the command on whoever the INIT line belongs too, in this case, s_marksman.

A sample of the code that may be used would :

removeHeadgear this;
removeHeadgear s_marksman;

Both commands will remove the headgear, but the second line will always affect the s_marksman soldier regardless of whose INIT line the code is written in. This can be useful when rearming an entire squad as only one soldier will need to have all the code inside of their INIT line.

What about altering weapons or items? This is done in a very similar fashion, the difference comes between the use of all and allassigned. Here is some sample code to remove the items from a unit:
removeallitems this;
removeallassigneditems this;

This can get a little confusing. The first line will not remove any items that are currently being used or are assigned to the player. For example, a map or GPS device. The second line will remove every item on the character, including assigned items such as the map. Only removing stored items can come in handy for clearing a unit but not having to re-add all the base items like a map or compass.

Weapons can also be removed using this command:
removeAllWeapons this;

This will, as the command shows, remove all weapons and attached items from the soldier. This is useful for rearming the soldier with the weapons that you want them to have.

It is also possible to completely clear the soldier of everything, using a combination of all these commands:

removeHeadgear this:
removeGoggles this;
removeVest this;
removeBackpack this;
removeUniform this;
removeAllWeapons this:
removeAllAssignedItems this;

This will remove absolutely everything from the soldier, weapons, clothing, maps, ammo etc. Here is what the character will look like after using this code:


Now a blank slate has been created to allow for full customisation with no possibility of leftover items or conflicting items. Here is a summary of all the code:
_________________________________________________________________________________

The base command:
removeHeadgear unit;

Remove all Clothing:
removeHeadgear this:
removeGoggles this;
removeVest this;
removeBackpack this;
removeUniform this;

Remove all Weapons:
removeAllWeapons;

Remove all items and only stored ones;
removeAllAssignedItems;
removeAllItems 

Remove Everything and make blank slate:
removeHeadgear this:
removeGoggles this;
removeVest this;
removeBackpack this;
removeUniform this;
removeAllWeapons this:
removeAllAssignedItems this;

That is how to remove items of different types and create a blank slate for customisation. The next post will detail how to add Weapons and Ammo as well as adding and removing attachments.



10 comments:

  1. remove Uniform this - doesnt work dude!

    ReplyDelete
    Replies
    1. Many thanks for that, I have since amended the post.

      Nice spot!

      Delete
  2. How does one make this work on multiplayer respawn?

    ReplyDelete
    Replies
    1. Hey thanks for your comment. I had a few issues and haven't been posting lately. That'll be this weeks topic, so just hang tight until Friday and there should be a post up.
      Sorry for the delay.

      Delete
  3. Aloha, what is the line I put in the init of a unit to remove his pistol.

    ReplyDelete
  4. how to remove handgun form a guy,???

    ReplyDelete
    Replies
    1. removeallweapons this;

      Delete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. Is it possible to enter a line, or a few lines of code to the init.sqf (for example), that will remove all the 'Map' items from a side (BLUFOR/OPFOR/INDEPENDENT)?

    ReplyDelete
  7. AnonymousMay 19, 2020

    In your block of code to remove entire inventory, two lines end with a colon instead of semicolon.

    ReplyDelete