local ITEM = Clockwork.item:New();
ITEM.name = "CWU рубашка";
ITEM.model = "models/tnb/items/shirt_citizen1.mdl";
ITEM.skin = 2;
ITEM.weight = 0.5;
ITEM.useText = "Wear Shirt";
ITEM.category = "Clothing";
ITEM.description = "Рубашка, предоставленная Союзу гражданских трудящихся, вполне удобна.";
ITEM.customFunctions = {"Remove"};
ITEM.access = "1";
ITEM.business = true;
ITEM.addInvSpace = 1;
local bodyGroup = 1;
function ITEM:OnDrop(player, position)
local target = player
local targetBodyGroups = target:GetCharacterData("BodyGroups") or {};
local bodyGroupState = 0;
local model = target:GetModel();
if( bodyGroup < target:GetNumBodyGroups() )then
targetBodyGroups[model] = targetBodyGroups[model] or {};
if( bodyGroupState == 0 )then
targetBodyGroups[model][tostring(bodyGroup)] = nil;
else
targetBodyGroups[model][tostring(bodyGroup)] = bodyGroupState;
end;
target:SetBodygroup(bodyGroup, bodyGroupState);
target:SetCharacterData("BodyGroups", targetBodyGroups);
end;
return true
end;
function ITEM:OnUse(player, itemEntity)
if (player:Alive() and !player:IsRagdolled()) then
if (!self.CanPlayerWear or self:CanPlayerWear(player, itemEntity) != false) then
local target = player
local targetBodyGroups = target:GetCharacterData("BodyGroups") or {};
local bodyGroupState = 2;
local model = target:GetModel();
if( bodyGroup < target:GetNumBodyGroups() )then
targetBodyGroups[model] = targetBodyGroups[model] or {};
if( bodyGroupState == 0 )then
targetBodyGroups[model][tostring(bodyGroup)] = nil;
else
targetBodyGroups[model][tostring(bodyGroup)] = bodyGroupState;
end;
target:SetBodygroup(bodyGroup, bodyGroupState);
target:SetCharacterData("BodyGroups", targetBodyGroups);
return true;
end;
end;
end;
end;
if (SERVER) then
function ITEM:OnCustomFunction(player, name)
if (name == "Remove") then
local target = player
local targetBodyGroups = target:GetCharacterData("BodyGroups") or {};
local bodyGroupState = 0;
local model = target:GetModel();
if( bodyGroup < target:GetNumBodyGroups() )then
targetBodyGroups[model] = targetBodyGroups[model] or {};
if( bodyGroupState == 0 )then
targetBodyGroups[model][tostring(bodyGroup)] = nil;
else
targetBodyGroups[model][tostring(bodyGroup)] = bodyGroupState;
end;
target:SetBodygroup(bodyGroup, bodyGroupState);
target:SetCharacterData("BodyGroups", targetBodyGroups);
end;
end;
end;
end;
ITEM:Register();