Hi, referring to http://forums.cloudsixteen.com/thre...groups-on-my-clothing-item.37894/#post-281836;
Code:
local ITEM = Clockwork.item:New("equipable_item_base");
ITEM.name = "Metrocop Vest";
ITEM.uniqueID = "metrocop_vest";
ITEM.model = "models/tnb/items/shirt_metrocop.mdl";
ITEM.cost = 10;
ITEM.weight = 2;
ITEM.business = true;
ITEM.category = "Clothing";
ITEM.access = "z";
ITEM.description = "A Metrocop vest with light armor.";
-- Called when a player uses the item.
function ITEM:OnUse(player, itemEntity)
findTorso = player:FindBodygroupByName("Torso");
player:SetBodygroup(findTorso, 6);
if (player:Alive() and !player:IsRagdolled()) then
if (self:GetData("equipped") != true) then
if (self:CanPlayerWear(player, itemEntity) != false) then
self:SetData("equipped", true);
self:OnWearItem(player, true);
player:RebuildInventory();
return true;
end;
else
Clockwork.player:Notify(player, "You are already wearing this item!");
end;
else
Clockwork.player:Notify(player, "You cannot do this action at the moment!");
end;
return false;
end;
function ITEM:OnPlayerUnequipped(player, extraData)
findTorso = player:FindBodygroupByName("Torso");
player:SetBodygroup(findTorso, 0);
self:OnWearItem(player, false);
player:RebuildInventory();
end;
function ITEM:OnStorageGive(player, storageTable)
if (self:GetData("equipped") == true) then
self:OnWearItem(player, false);
end;
end;
function ITEM:OnDrop(player, position)
findTorso = player:FindBodygroupByName("Torso");
player:SetBodygroup(findTorso, 0);
if (self:GetData("equipped") == true) then
self:OnWearItem(player, false);
end;
end;
-- Called when a player's character has loaded.
function Clockwork:PlayerCharacterLoaded(player)
findTorso = player:FindBodygroupByName("Torso");
player:SetBodygroup(findTorso, 0);
end;
ITEM:Register();
How do you ensure equipped items are shown when a character loads in? As it is, this code does not show equipped items on spawn. And once equipped, the next character I load in has their bodygroups manipulated as well, depsite not having this item equipped.
Thank you!