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
OnChangedClothes if it has one.Player:SetBodygroupClothes and keeps it in the inventory.Methods
ITEM:CanGiveStorage(player, storageTable)
shared gamemodes/cwhl2rp/plugins/clothes/plugin/items/sh_bodygroup_base.lua:108Takes 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:139Returns 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:120Sets 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
ITEM:OnDrop(player, position)
shared gamemodes/cwhl2rp/plugins/clothes/plugin/items/sh_bodygroup_base.lua:90Takes 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:156Takes the item off when the player unequips it.
Parameters
- player
- extraData
ITEM:OnTakeFromPlayer(player)
shared gamemodes/cwhl2rp/plugins/clothes/plugin/items/sh_bodygroup_base.lua:161Takes the item off when it is taken from the player's inventory while worn.
Parameters
- player
ITEM:OnUse(player, itemEntity)
shared gamemodes/cwhl2rp/plugins/clothes/plugin/items/sh_bodygroup_base.lua:59Wears 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
truewhen worn,falseotherwise; either way the item is kept
ITEM:ResetBodygroup(player, bg)
shared gamemodes/cwhl2rp/plugins/clothes/plugin/items/sh_bodygroup_base.lua:47Resets a bodygroup on the player to 0.
Parameters
- player Player The wearer
- bg Number The bodygroup index
Returns
- Boolean Always
true
ITEM:SetBodygroup(player, bg, val)
shared gamemodes/cwhl2rp/plugins/clothes/plugin/items/sh_bodygroup_base.lua:30Sets 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