Defines bodygroup_base, the base item for clothing that is worn by setting a bodygroup on the player's model.

Derived items set bodyGroup and bodyGroupVal, and optionally protection (percent of damage absorbed), isCombine (Combine players can only wear items marked with it) and requiredBG (a bodygroup that must already be worn). Wearing goes through Player:SetBodygroupClothes, the item stays in the inventory, and it is taken off when dropped, sold, stored, unequipped or taken from the inventory in any other way.

Originally written for the Global Cooldown community.

Summary

Methods

Takes the item off when it is put into storage while worn.
Takes the item off when it is sold while worn.
Returns whether the player wears this item instance in its bodygroup.
Sets or resets the item's bodygroup and calls the item's OnChangedClothes if it has one.
Takes the item off when it is dropped while worn.
Takes the item off when the player unequips it.
Takes the item off when it is taken from the player's inventory while worn.
Wears the item with Player:SetBodygroupClothes and keeps it in the inventory.
Resets a bodygroup on the player to 0.
Sets a bodygroup on the player, or tells them they cannot wear the item if the model lacks it.

Methods

ITEM:CanGiveStorage(player, storageTable)

shared gamemodes/cwhl2rp/plugins/clothes/plugin/items/sh_bodygroup_base.lua:108

Takes the item off when it is put into storage while worn.

Parameters

  • player
  • storageTable

Takes the item off when it is sold while worn.

Parameters

  • player

ITEM:HasPlayerEquipped(player, bIsValidWeapon)

shared gamemodes/cwhl2rp/plugins/clothes/plugin/items/sh_bodygroup_base.lua:139

Returns whether the player wears this item instance in its bodygroup.

Uses the networked bgClothesData on the client.

Parameters

  • player Player The player to check
  • bIsValidWeapon Boolean Unused

Returns

  • Boolean Whether the item is worn

ITEM:OnChangeClothes(player, bIsWearing)

shared gamemodes/cwhl2rp/plugins/clothes/plugin/items/sh_bodygroup_base.lua:120

Sets or resets the item's bodygroup and calls the item's OnChangedClothes if it has one.

Parameters

  • player Player The wearer
  • bIsWearing Boolean Whether the item is being put on

Takes the item off when it is dropped while worn.

Parameters

  • player
  • position

ITEM:OnPlayerUnequipped(player, extraData)

shared gamemodes/cwhl2rp/plugins/clothes/plugin/items/sh_bodygroup_base.lua:156

Takes the item off when the player unequips it.

Parameters

  • player
  • extraData

Takes the item off when it is taken from the player's inventory while worn.

Parameters

  • player

Wears the item with Player:SetBodygroupClothes and keeps it in the inventory.

Fails when the item's requiredBG bodygroup is not worn or the player is dead or ragdolled, and Combine players can only wear items marked isCombine.

Parameters

  • player
  • itemEntity

Returns

  • Boolean true when worn, false otherwise; either way the item is kept

Resets a bodygroup on the player to 0.

Parameters

  • player Player The wearer
  • bg Number The bodygroup index

Returns

  • Boolean Always true

Sets a bodygroup on the player, or tells them they cannot wear the item if the model lacks it.

Parameters

  • player Player The wearer
  • bg Number The bodygroup index
  • val Number The bodygroup value

Returns

  • Boolean Whether the bodygroup was set

Defined in