--pavetr.top/ds local crosshairType local crosshairGap local crosshairSize local crosshairThickness local crosshairDot local crosshairOutline local crosshairAlpha local crosshairColourR local crosshairColourG local crosshairColourB local playerFov function SetupCvars() crosshairEnabled = CreateClientConVar("xhair_enable", "0", true, false, "Turns the crosshair on or of (0-1)") crosshairType = CreateClientConVar("xhair_type", "1", true, false, "Sets the crosshair type") crosshairGap = CreateClientConVar("xhair_gap", "0", true, false, "Sets the crosshair gap") crosshairSize = CreateClientConVar("xhair_size", "4", true, false, "Sets the crosshair size") crosshairThickness = CreateClientConVar("xhair_thickness", "2", true, false, "Sets the crosshair thickness") crosshairDot = CreateClientConVar("xhair_dot", "0", true, false, "Turns the crosshair dot on or off (0-1)") crosshairOutline = CreateClientConVar("xhair_outline", "1", true, false, "Turns the crosshair outline on or off (0-1)") crosshairRemoveInScope = CreateClientConVar("xhair_removeinscope", "0", true, false, "Turns the removal of the crosshair while scoped on or off (0-1)") crosshairAlpha = CreateClientConVar("xhair_a", "255", true, false, "Sets the crosshair alpha channel (0-255)") crosshairColourR = CreateClientConVar("xhair_r", "0", true, false, "Sets the crosshairs red channel (0-255)") crosshairColourG = CreateClientConVar("xhair_g", "255", true, false, "Sets the crosshairs green channel (0-255)") crosshairColourB = CreateClientConVar("xhair_b", "0", true, false, "Sets the crosshairs blue channel (0-255)") if (engine.ActiveGamemode() == "terrortown") then crosshairtttDisable = GetConVar("ttt_disable_crosshair") end concommand.Add("xhair_menu", CrosshairMenu) end function PaintCrosshair() if(crosshairEnabled:GetBool() == true) then if(playerFov == nil) then playerFov = LocalPlayer():GetFOV() end if (crosshairType:GetInt() == 1 && (playerFov == LocalPlayer():GetFOV() || crosshairRemoveInScope:GetBool())) then local middleX = ScrW() / 2 local middleY = ScrH() / 2 if (crosshairOutline:GetBool() == true) then surface.SetDrawColor(Color(0, 0, 0, crosshairAlpha:GetInt())) //Right outline surface.DrawRect(middleX + crosshairGap:GetInt() - 1, middleY - math.floor(crosshairThickness:GetInt() / 2) - 1, crosshairSize:GetInt() + 2, crosshairThickness:GetInt() + 2) //Left outline surface.DrawRect(middleX - crosshairGap:GetInt() - crosshairSize:GetInt() + crosshairThickness:GetInt() % 2 - 1, middleY - math.floor(crosshairThickness:GetInt() / 2) - 1, crosshairSize:GetInt() + 2, crosshairThickness:GetInt() + 2) //Bottom outline surface.DrawRect(middleX - math.floor(crosshairThickness:GetInt() / 2) - 1, middleY + crosshairGap:GetInt() - 1, crosshairThickness:GetInt() + 2, crosshairSize:GetInt() + 2) //Top outline surface.DrawRect(middleX - math.floor(crosshairThickness:GetInt() / 2) - 1, middleY - crosshairSize:GetInt() - crosshairGap:GetInt() + crosshairThickness:GetInt() % 2 - 1, crosshairThickness:GetInt() + 2, crosshairSize:GetInt() + 2) if (crosshairDot:GetBool() == true) then //Dot outline surface.DrawRect(middleX - math.floor(crosshairThickness:GetInt() / 2) - 1, middleY - math.floor(crosshairThickness:GetInt() / 2) - 1, crosshairThickness:GetInt() + 2, crosshairThickness:GetInt() + 2) end end surface.SetDrawColor(Color(crosshairColourR:GetInt(), crosshairColourG:GetInt(), crosshairColourB:GetInt(), crosshairAlpha:GetInt())) //Right surface.DrawRect(middleX + crosshairGap:GetInt(), middleY - math.floor(crosshairThickness:GetInt() / 2), crosshairSize:GetInt(), crosshairThickness:GetInt()) //Left surface.DrawRect(middleX - crosshairGap:GetInt() - crosshairSize:GetInt() + crosshairThickness:GetInt() % 2, middleY - math.floor(crosshairThickness:GetInt() / 2), crosshairSize:GetInt(), crosshairThickness:GetInt()) //Bottom surface.DrawRect(middleX - math.floor(crosshairThickness:GetInt() / 2), middleY + crosshairGap:GetInt(), crosshairThickness:GetInt(), crosshairSize:GetInt()) //Top surface.DrawRect(middleX - math.floor(crosshairThickness:GetInt() / 2), middleY - crosshairSize:GetInt() - crosshairGap:GetInt() + crosshairThickness:GetInt() % 2, crosshairThickness:GetInt(), crosshairSize:GetInt()) if (crosshairDot:GetBool() == true) then //Dot surface.DrawRect(middleX - math.floor(crosshairThickness:GetInt() / 2), middleY - math.floor(crosshairThickness:GetInt() / 2), crosshairThickness:GetInt(), crosshairThickness:GetInt()) end end end end local function HideHudCrosshair(name) if(name == "CHudCrosshair" && crosshairType:GetInt() > 0 && crosshairEnabled:GetBool() == true) then if (playerFov == LocalPlayer():GetFOV() || crosshairRemoveInScope:GetBool()) then return false else return true end end end function CrosshairMenu() local Frame = vgui.Create("DFrame") Frame:SetPos(ScrW() / 2 + 20, ScrH() / 2 + 5) if (engine.ActiveGamemode() == "terrortown") then Frame:SetSize(235, 330) else Frame:SetSize(235, 300) end Frame:SetTitle("Crosshair customization") Frame:SetVisible(true) Frame:SetDraggable(true) Frame:ShowCloseButton(true) Frame:MakePopup() local ColorPicker = vgui.Create("DColorMixer", Frame) ColorPicker:SetSize(200, 200) ColorPicker:SetPos(10, 30) ColorPicker:SetPalette(true) ColorPicker:SetAlphaBar(true) ColorPicker:SetWangs(true) ColorPicker:SetColor(Color( 255, 255, 255 )) ColorPicker:SetConVarA("xhair_a") ColorPicker:SetConVarR("xhair_r") ColorPicker:SetConVarG("xhair_g") ColorPicker:SetConVarB("xhair_b") local EnabledCheckBox = vgui.Create("DCheckBoxLabel", Frame) EnabledCheckBox:SetPos(160, 125) EnabledCheckBox:SetText("Enabled") EnabledCheckBox:SetConVar("xhair_enable") EnabledCheckBox:SetValue(crosshairType:GetBool()) local SizeLabel = vgui.Create("DLabel", Frame) SizeLabel:SetPos(55, 240) SizeLabel:SetBright(true) SizeLabel:SetText("Size") local SizeNumberWang = vgui.Create("DNumberWang", Frame) SizeNumberWang:SetSize(40, 20) SizeNumberWang:SetPos(10, 240) SizeNumberWang:SetValue(crosshairSize:GetInt()) SizeNumberWang:SetConVar("xhair_size") local GapLabel = vgui.Create("DLabel", Frame) GapLabel:SetPos(55, 270) GapLabel:SetBright(true) GapLabel:SetText("Gap") local GapNumberWang = vgui.Create("DNumberWang", Frame) GapNumberWang:SetSize(40, 20) GapNumberWang:SetPos(10, 270) GapNumberWang:SetValue(crosshairGap:GetInt()) GapNumberWang:SetConVar("xhair_gap") local ThicknessLabel = vgui.Create("DLabel", Frame) ThicknessLabel:SetPos(130, 240) ThicknessLabel:SetBright(true) ThicknessLabel:SetText("Thickness") local ThicknessNumberWang = vgui.Create("DNumberWang", Frame) ThicknessNumberWang:SetSize(40, 20) ThicknessNumberWang:SetPos(85, 240) ThicknessNumberWang:SetValue(crosshairThickness:GetInt()) ThicknessNumberWang:SetConVar("xhair_thickness") local DotCheckBox = vgui.Create("DCheckBoxLabel", Frame) DotCheckBox:SetPos(85, 270) DotCheckBox:SetText("Dot") DotCheckBox:SetConVar("xhair_dot") DotCheckBox:SetValue(crosshairDot:GetBool()) local OutlineCheckBox = vgui.Create("DCheckBoxLabel", Frame) OutlineCheckBox:SetPos(130, 270) OutlineCheckBox:SetText("Outline") OutlineCheckBox:SetConVar("xhair_outline") OutlineCheckBox:SetValue(crosshairOutline:GetBool()) if (engine.ActiveGamemode() == "terrortown") then local OutlineCheckBox = vgui.Create("DCheckBoxLabel", Frame) OutlineCheckBox:SetPos(10, 300) OutlineCheckBox:SetText("Disable TTT xhair") OutlineCheckBox:SetConVar("ttt_disable_crosshair") OutlineCheckBox:SetValue(crosshairtttDisable:GetBool()) end end hook.Add("Initialize", "crosshairSetup", function() SetupCvars() hook.Add("HUDPaint","DrawCrosshair",PaintCrosshair) hook.Add("HUDShouldDraw", "HideHudCrosshair", HideHudCrosshair) end)