I have a multitude of suits with many bodygroups that I want to integrate into Clockwork. So basically I'm going to make separate items as follows: a shirt, jacket, and tie. Each will have to have their bodygroups match for them to pair together on the models. The player will have to wear the shirt first, then choose either the tie or the jacket, or both to have different combinations of clothing with the same items. However, when I duplicate the clothes base, change the file name, then change the item.name, create a clothing item with the suit_base filename in the Clockwork.item:New the item exists. Essentially I can /chargiveitem myself a shirt, however it doesn't actually show up in my inventory. No errors in the client or server, any ideas?
Spoiler
local Clockwork = Clockwork;
local ITEM = Clockwork.item:New(nil, true);
ITEM.name = "Suits Base";
ITEM.model = "models/props_c17/suitcase_passenger_physics.mdl";
ITEM.weight = 2;
ITEM.useText = "Wear";
ITEM.category = "Clothing";
ITEM.description = "A suitcase full of clothes.";
-- A function to get the model name.
function ITEM:GetModelName(player, group)
local modelName = nil;
if (!player) then
player = Clockwork.Client;
end;
if (group) then
modelName = string.gsub(string.lower(Clockwork.player:GetDefaultModel(player)), "^.-/.-/", "");
else
modelName = string.gsub(string.lower(Clockwork.player:GetDefaultModel(player)), "^.-/.-/.-/", "");
end;
if (!string.find(modelName, "male") and !string.find(modelName, "female")) then
if (group) then
group = "group05/";
else
group = "";
end;
if (SERVER) then
if (player:GetGender() == GENDER_FEMALE) then
return group.."female_04.mdl";
else
return group.."male_05.mdl";
end;
elseif (player:GetGender() == GENDER_FEMALE) then
return group.."female_04.mdl";
else
return group.."male_05.mdl";
end;
else
return modelName;
end;
end;
-- Called when the item's client side model is needed.
function ITEM:GetClientSideModel()
local replacement = nil;
if (self.GetReplacement) then
replacement = self:GetReplacement(Clockwork.Client);
end;
if (type(replacement) == "string") then
return replacement;
elseif (self("replacement")) then
return self("replacement");
elseif (self("group")) then
return "models/humans/"..self("group").."/"..self:GetModelName();
end;
end;
-- Called when a player changes clothes.
function ITEM:OnChangeClothes(player, bIsWearing)
if (bIsWearing) then
local replacement = nil;
if (self.GetReplacement) then
replacement = self:GetReplacement(player);
end;
if (type(replacement) == "string") then
player:SetModel(replacement);
elseif (self("replacement")) then
player:SetModel(self("replacement"));
elseif (self("group")) then
player:SetModel("models/humans/"..self("group").."/"..self:GetModelName(player));
end;
else
Clockwork.player:SetDefaultModel(player);
Clockwork.player:SetDefaultSkin(player);
end;
if (self.OnChangedClothes) then
self:OnChangedClothes(player, bIsWearing);
end;
end;
-- Called to get whether a player has the item equipped.
function ITEM:HasPlayerEquipped(player, bIsValidWeapon)
if (CLIENT) then
return Clockwork.player:IsWearingItem(self);
else
return player:IsWearingItem(self);
end;
end;
-- Called when a player has unequipped the item.
function ITEM:OnPlayerUnequipped(player, extraData)
player:RemoveClothes();
end;
-- Called when a player drops the item.
function ITEM:OnDrop(player, position)
if (player:IsWearingItem(self)) then
Clockwork.player:Notify(player, "You cannot drop this while you are wearing it!");
return false;
end;
end;
-- Called when a player uses the item.
function ITEM:OnUse(player, itemEntity)
if (self("whitelist") and !table.HasValue(self("whitelist"), player:GetFaction())) then
Clockwork.player:Notify(player, "Your faction cannot wear this clothing!");
return false;
end;
if (player:Alive() and !player:IsRagdolled()) then
if (!self.CanPlayerWear or self:CanPlayerWear(player, itemEntity) != false) then
player:SetClothesData(self);
return true;
end;
else
Clockwork.player:Notify(player, "You cannot do this action at the moment!");
end;
return false;
end;
if (CLIENT) then
function ITEM:GetClientSideInfo()
if (!self:IsInstance()) then return; end;
if (Clockwork.player:IsWearingItem(self)) then
return "Is Wearing: Yes";
else
return "Is Wearing: No";
end;
end;
end;
Clockwork.item:Register(ITEM);
----------
local ITEM = Clockwork.item:New("suits_base");
ITEM.name = "Shirt";
ITEM.group = "shirt";
ITEM.weight = 3;
ITEM.business = true;
ITEM.protection = 0.1;
ITEM.description = "A resistance uniform with a yellow symbol on the sleeve.";
ITEM:Register();