I posted about this a long time ago and I don't think its even possible at this point but I'm trying to make a suits base and if i copy the entire clothes base and make an item for it changing the name of the file and the clothes base item breaks everything, anyone know why? The item exists but the inventory model is an error and it has no options.
Code:
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;
local modelDefault = Clockwork.player:GetDefaultModel(player);
for i = 1, 9 do
if ( string.find(string.lower(modelDefault), "male_0"..i ) ) then
local modelName = "male_0"..i;
break
elseif ( string.find(string.lower(modelDefault), "female_0"..i ) ) then
local modelName = "female_0"..i;
break
end;
end;
if (self("group") == "shirt") then
return modelName.."_shirt.mdl";
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, isWearing)
if (isWearing) 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, isWearing);
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, {"CannotDropWhileWearing"});
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, {"FactionCannotWearThis"});
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, {"CannotActionRightNow"});
end;
return false;
end;
if (CLIENT) then
function ITEM:GetClientSideInfo()
if (!self:IsInstance()) then return; end;
if (Clockwork.player:IsWearingAccessory(self)) then
return L("ItemInfoIsWearingYes");
else
return L("ItemInfoIsWearingNo");
end;
end;
end;
Clockwork.item:Register(ITEM);
-------
SHIRT ITEM:
local ITEM = Clockwork.item:New("suits_base");
ITEM.name = "White Shirt";
ITEM.group = "shirt";
ITEM.weight = 3;
ITEM.access = "m";
ITEM.business = true;
ITEM.protection = 0.1;
ITEM.description = "A white shirt, paired with black pants, and black shoes.";
--[[
-- Called when a replacement is needed for a player.
function ITEM:GetReplacement(player)
if (string.lower( player:GetModel() ) == "models/humans/group01/jasona.mdl") then
return "models/humans/group03/male_02.mdl";
end;
end;
]]
ITEM:Register();