Untitled conversation
- User
-- cl_att.lua if CLIENT then SWEP._attachments = SWEP._attachments or {} -- Очистка вложений при удалении оружия function SWEP:OnRemove() for _, attachment in pairs(self._attachments) do if IsValid(attachment.csEnt) then attachment.csEnt:Remove() end end end local color_white = Color(255, 255, 255) local color_black = Color(0, 0, 0) -- Функция отрисовки оптических вложений local function drawOpticAttach(csEnt, flags) local weap = csEnt.parent if not IsValid(weap) then return end local ply = csEnt:GetParent() if not IsValid(ply) then return end if ply:GetActiveWeapon() ~= weap then return end csEnt:DrawModel(flags) if not qwb.ironsighted then return end local scopeMat = csEnt.opticMat or weap.DefaultScopeMat if not scopeMat then return end local attID = weap:LookupAttachment("muzzle") if not attID or attID <= 0 then return end local att = weap:GetAttachment(attID) if not att then return end local pos, ang = LocalToWorld(csEnt.opticPos, csEnt.opticAng or Angle(-90, 0, 0), csEnt:GetPos(), att.Ang) local w, h = unpack(csEnt.opticSize or {512, 512}) local radius = math.max(w, h) local semiRadius = radius * 0.5 if not draw_Circle then -- Убедитесь, что функция draw_Circle доступна return end qwb.fullyClearStencil() render.SetStencilEnable(true) render.SetStencilCompareFunction(STENCIL_ALWAYS) render.SetStencilFailOperation(STENCIL_ZERO) render.SetStencilZFailOperation(STENCIL_ZERO) render.SetStencilPassOperation(STENCIL_REPLACE) render.SetStencilReferenceValue(1) cam.Start3D2D(pos, ang, 0.01) draw.NoTexture() surface.SetDrawColor(color_black) draw_Circle(semiRadius, semiRadius, semiRadius, 30) cam.End3D2D() render.SetStencilCompareFunction(STENCIL_EQUAL) cam.Start3D2D(pos, ang, 0.01) local mat = weap.mat if not mat then return end surface.SetDrawColor(color_white) surface.SetMaterial(mat) surface.DrawTexturedRect(0, 0, w, h) surface.SetDrawColor(color_white) surface.SetMaterial(scopeMat) surface.DrawTexturedRect(0, 0, w, h) cam.End3D2D() render.SetStencilEnable(false) end -- Обработка сетевого сообщения установки вложения net.Receive("qwb.setAttachment", function() local weap = net.ReadEntity() if not IsValid(weap) then return end local attachType, attachID = net.ReadString(), net.ReadString() if not attachType or not attachID then return end local attachmentData = weap.Attachments and weap.Attachments[attachType] and weap.Attachments[attachType][attachID] if not attachmentData then return end weap._attachments = weap._attachments or {} weap._attachments[attachType] = weap._attachments[attachType] or {} local attachment = weap._attachments[attachType] attachment.id = attachID if IsValid(attachment.csEnt) then attachment.csEnt:Remove() end local owner = weap:GetOwner() attachment.csEnt = ClientsideModel(attachmentData.mdl) if not IsValid(attachment.csEnt) then return end attachment.csEnt:SetParent(weap) attachment.csEnt:AddEffects(EF_BONEMERGE) attachment.csEnt:SetLocalPos(attachmentData.pos) attachment.csEnt:SetLocalAngles(attachmentData.ang) attachment.csEnt:SetModelScale(attachmentData.scale or 1) attachment.csEnt.parent = weap if attachmentData.opticPos and owner == LocalPlayer() then attachment.csEnt.opticPos = attachmentData.opticPos attachment.csEnt.opticAng = attachmentData.opticAng attachment.csEnt.opticSize = attachmentData.opticSize attachment.csEnt.opticMat = attachmentData.opticMat or weap.DefaultScopeMat attachment.csEnt.RenderOverride = drawOpticAttach end attachment.csEnt:Spawn() end) -- Обработка сетевого сообщения удаления вложения net.Receive("qwb.removeAttachment", function() local weap = net.ReadEntity() if not IsValid(weap) then return end if not weap._attachments then return end local attachType = net.ReadString() if not attachType then return end local attachment = weap._attachments[attachType] if not attachment then return end if IsValid(attachment.csEnt) then attachment.csEnt:Remove() end weap._attachments[attachType] = nil end) end - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.