Trying to do something similar to:
-snip, replaced example-
Code:
local ITEM = Clockwork.item:New();
ITEM.name = "Backpack";
ITEM.model = "models/eltaco/backpack.mdl";
ITEM.weight = 1;
ITEM.uniqueID = "backpack";
ITEM.useText = "Wear";
ITEM.category = "Storage";
ITEM.description = "A black, military styled MOLLE backpack.";
ITEM.isAttachment = true;
ITEM.attachmentBone = "ValveBiped.Bip01_Spine";
ITEM.attachmentOffsetAngles = Angle(0, 0, 0);
ITEM.attachmentOffsetVector = Vector(-3.96, 4.95, -2.97);
-- A function to get the maximum amount of weight the local player can carry.
function Clockwork.player:GetMaxWeight()
local addInvSpace = v("addInvSpace");
local weight = Clockwork.Client:GetSharedVar(
"InvWeight", Clockwork.config:Get("default_inv_weight"):Get()
);
if (Clockwork.Client:GetSharedVar("backPack")) then
player.addInvSpace = 4;
for k, v in pairs(itemsList) do
local addInvSpace = v("addInvSpace");
if (addInvSpace) then
weight = weight + addInvSpace;
end;
end;
end;
end;
-- Called when the attachment offset info should be adjusted.
function ITEM:AdjustAttachmentOffsetInfo(player, entity, info)
if (string.find(player:GetModel(), "female")) then
info.offsetVector = Vector(0, 3, 1.75);
end;
end;
-- A function to get whether the attachment is visible.
function ITEM:GetAttachmentVisible(player, entity)
if (player:GetSharedVar("backPack")) then
return true;
end;
end;
-- Called when the item's local amount is needed.
function ITEM:GetLocalAmount(amount)
if (Clockwork.Client:GetSharedVar("backPack")) then
return amount - 1;
else
return amount;
end;
end;
-- Called to get whether a player has the item equipped.
function ITEM:HasPlayerEquipped(player, arguments)
return player:GetSharedVar("backPack");
end;
-- Called when a player has unequipped the item.
function ITEM:OnPlayerUnequipped(player, arguments)
local skullMaskGear = Clockwork.player:GetGear(player, "BackPack");
if (player:GetSharedVar("backPack") and IsValid(skullMaskGear)) then
player:SetCharacterData("backpack", nil);
player:SetSharedVar("backPack", false);
if (IsValid(skullMaskGear)) then
skullMaskGear:Remove();
end;
end;
player:GiveItem(Clockwork.item:CreateInstance(self.uniqueID));
end;
-- Called when a player drops the item.
function ITEM:OnDrop(player, position)
if (player:GetSharedVar("backPack") and #player:GetItemsByID(self.uniqueID) == 1) 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 (player:Alive() and !player:IsRagdolled()) then
Clockwork.player:CreateGear(player, "BackPack", self);
player:SetCharacterData("backpack", true);
player:SetSharedVar("backPack", true);
player:GiveItem(Clockwork.item:CreateInstance(self.uniqueID));
if (itemEntity) then
return true;
end;
else
Clockwork.player:Notify(player, "You don't have permission to do this right now!");
end;
return false;
end;
ITEM:Register();
Trying to get it to call if a backpack is being worn in the equipment tab, to add additional inventory weight.
Any suggestions on how to do it?