• Weapon Selection Dissapearing
    2 replies, posted
I am currently in the midst of adding a compass direction thing to my HUD and I have working code apart from a small issue where the weapon selection dissappears and you cannot see it when trying to switch weapons or you can only see the very top, example of what I am trying to explain: There is absolutely no errors and it looks as I want it to, the code is below: local width = ScrW() - 520 local height = ScrH() - 100 local ang = LocalPlayer():EyeAngles() ang:Normalize() local CompassDirections = { "N", "NE", "E", "SE", "S", "SW", "W", "NW" } local CompassDirectionsDeg = { "360", "45", "90", "135", "180", "225", "270", "315" } local CompassDirectionsLines = { "____", "______", "____", "______", "____", "______", "____", "______" } local width = ScrW() - 400 local height = 32 -- Directional local deg = math.ceil( ang.y - 90 ) while deg < 360 do deg = deg + 360 end while deg > 0 do deg = deg - 360 end compasspad = 0 - width + 360 compasswidth = ScrW() - 720 local i = 1 local directioncounter = 3 render.SetScissorRect(width + compasspad, height, width + compasspad + compasswidth, height + 20, true) width = width + math.Round(compasspad - compasswidth * 3 / 2) width = width + ang.y / 180 * compasswidth while i <= 18 do local txt = CompassDirections[directioncounter] draw.SimpleText(txt, "SMInfoFont", width, height - 3, DankConfig.SecondColor, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP) width = width + math.Round(compasswidth / 4) i = i + 1 directioncounter = directioncounter + 1 if directioncounter > #CompassDirections then directioncounter = 1 end end local width = ScrW() - 400 local height = 42 -- Lines local deg = math.ceil( ang.y - 90 ) while deg < 360 do deg = deg + 360 end while deg > 0 do deg = deg - 360 end compasspadline = 0 - width + 360 compasswidthline = ScrW() - 720 local i = 1 local directioncounter = 3 render.SetScissorRect( width + compasspadline, height, width + compasspadline + compasswidthline, height + 20, true ) width = width + math.Round( compasspadline - compasswidthline * 3 / 2 ) width = width + ang.y / 180 * compasswidthline while i <= 18 do local txt = CompassDirectionsLines[directioncounter] draw.SimpleText(txt, "TInfoFont", width, height, DankConfig.SecondColor, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP) width = width + math.Round( compasswidthdeg / 4 ) i = i + 1 directioncounter = directioncounter + 1 if directioncounter > #CompassDirectionsLines then directioncounter = 1 end end local width = ScrW() - 400 local height = 52 -- Degrees local deg = math.ceil( ang.y - 90 ) while deg < 360 do deg = deg + 360 end while deg > 0 do deg = deg - 360 end compasspaddeg = 0 - width + 360 compasswidthdeg = ScrW() - 720 local i = 1 local directioncounter = 3 render.SetScissorRect( width + compasspaddeg, height, width + compasspaddeg + compasswidthdeg, height + 20, true ) width = width + math.Round( compasspaddeg - compasswidthdeg * 3 / 2 ) width = width + ang.y / 180 * compasswidthdeg while i <= 18 do local txt = CompassDirectionsDeg[directioncounter] draw.SimpleText(txt, "TInfoFont", width, height, DankConfig.SecondColor, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP) width = width + math.Round( compasswidthdeg / 4 ) i = i + 1 directioncounter = directioncounter + 1 if directioncounter > #CompassDirectionsDeg then directioncounter = 1 end end I am also looking for any input to draw the lines and degrees without having to redo the whole thing as I am pretty new to this whole thing and wanna keep it to as least amount of useless code as possible but I used another HUD to get this code but that HUD doesn't have this issue.
What hook/element are you using to draw the compass?
I am using the regular HUDPaint hook, it's what the other one used so I presumed it was fine.
Sorry, you need to Log In to post a reply to this thread.