Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Dynamic 2D/3D box esp
- by Kujou
- ]]--
- local function Draw3DBox(pos,min,max)
- -- Thanks dad
- local b = {}
- -- Bottom Square
- b[1] = {Vector(min.x,min.y,min.z),Vector(max.x,min.y,min.z)}
- b[2] = {Vector(min.x,min.y,min.z),Vector(min.x,max.y,min.z)}
- b[3] = {Vector(min.x,max.y,min.z),Vector(max.x,max.y,min.z)}
- b[4] = {Vector(max.x,max.y,min.z),Vector(max.x,min.y,min.z)}
- -- Pillars
- b[5] = {Vector(min.x,min.y,min.z),Vector(min.x,min.y,max.z)}
- b[6] = {Vector(min.x,max.y,min.z),Vector(min.x,max.y,max.z)}
- b[7] = {Vector(max.x,max.y,min.z),Vector(max.x,max.y,max.z)}
- b[8] = {Vector(max.x,min.y,min.z),Vector(max.x,min.y,max.z)}
- -- Top Square
- b[9] = {Vector(min.x,min.y,max.z),Vector(max.x,min.y,max.z)}
- b[10] = {Vector(min.x,min.y,max.z),Vector(min.x,max.y,max.z)}
- b[11] = {Vector(min.x,max.y,max.z),Vector(max.x,max.y,max.z)}
- b[12] = {Vector(max.x,max.y,max.z),Vector(max.x,min.y,max.z)}
- -- Iterate corners and draw line to join them
- for k,v in next,b do
- local p = pos:ToScreen()
- local s = (pos + v[1]):ToScreen()
- local e = (pos + v[2]):ToScreen()
- surface.DrawLine(s.x,s.y,e.x,e.y)
- end
- end
- local function Draw2DBox(pos,min,max)
- local h = (pos + Vector(0,0,max.z)):ToScreen().y
- min = min + pos
- max = max + pos
- pos = pos:ToScreen()
- -- just the sides of the box are needed
- local s = {}
- s[1] = Vector(min.x,min.y,0):ToScreen().x
- s[2] = Vector(min.x,max.y,0):ToScreen().x
- s[3] = Vector(max.x,max.y,0):ToScreen().x
- s[4] = Vector(max.x,min.y,0):ToScreen().x
- -- lowest = left side of the box, highest = right side of the box
- local lowest = math.min(unpack(s))
- local highest = math.max(unpack(s))
- -- Drawing the box itself
- surface.DrawOutlinedRect(lowest,h,highest-lowest,pos.y-h)
- end
- local function DrawESP()
- for k,v in next, player.GetAll() do
- if (v == LocalPlayer() || v:IsDormant() || !ply:Alive()) then
- continue
- end
- local pos,min,max = ply:GetPos(),ply:OBBMins(),ply:OBBMaxs()
- surface.SetDrawColor(255,0,0)
- Draw3DBox(pos,min,max)
- surface.SetDrawColor(0,255,0)
- Draw2DBox(pos,min,max)
- end
- end
- hook.Add("HUDPaint","esp",DrawESP)
Add Comment
Please, Sign In to add comment