dobrograd-13-06-2022/octolib/addon/lua/weapons/octolib_custom/cl_init.lua
Jonny_Bro (Nikita) e4d5311906 first commit
2023-11-16 15:01:19 +05:00

49 lines
1.3 KiB
Lua

include 'shared.lua'
function SWEP:RemoveModel()
if IsValid(self.csEnt) then self.csEnt:Remove() end
octolib.manipulateBones(self:GetOwner(), nil, 0.4)
end
function SWEP:DrawWorldModel()
self:SetHoldType(self.HoldType)
local worldModel = self:GetNetVar('WorldModel')
if worldModel and (self.lastMdl ~= worldModel or not IsValid(self.csEnt)) then
self:RemoveModel()
local ent = ClientsideModel(worldModel.model)
local ply = self:GetOwner()
ent:SetParent(ply, ply:LookupAttachment(worldModel.attachment or 'anim_attachment_rh'))
ent:SetLocalPos(worldModel.pos or Vector())
ent:SetLocalAngles(worldModel.ang or Angle())
if worldModel.color then ent:SetColor(worldModel.color) end
if worldModel.skin then ent:SetSkin(worldModel.skin) end
if worldModel.material then ent:SetMaterial(worldModel.material) end
if worldModel.scale then ent:SetModelScale(worldModel.scale) end
if worldModel.bodyGroups then
for k, v in pairs(worldModel.bodyGroups) do
ent:SetBodygroup(k, v)
end
end
self.csEnt = ent
self.lastMdl = worldModel
if worldModel.bones then
octolib.manipulateBones(ply, worldModel.bones, 0.4)
end
end
end
function SWEP:Holster()
self:RemoveModel()
return true
end
SWEP.OwnerChanged = SWEP.RemoveModel
SWEP.OnRemove = SWEP.RemoveModel