All pastes #264358 Raw Edit

Mine

public text v1 · immutable
·published 2006-12-02 09:14 UTC
rendered paste body
	function PICKUP:DrawHUD()
		self.xScale = ScrW() / 1024
		self.yScale = ScrH() / 768

		for _, pl in pairs(player.GetAll()) do

			if (pl ~= LocalPlayer()) then

				local bc, tc = pl:WorldSpaceAABB()												-- Get the players bounding box
				local Ta =	Vector(tc.x, tc.y, tc.z):ToScreen()									-- Get the screen coords of one of the corners

				if Ta.visible then																-- If the corner we just got is visible...

					local Tb,Tc,Td =	Vector(tc.x, bc.y, tc.z):ToScreen(),					-- ...get the rest of the bounding box corners
										Vector(bc.x, tc.y, tc.z):ToScreen(),					-- ( these first ones are the at the top of the player)
										Vector(bc.x, bc.y, tc.z):ToScreen()

					local Ba,Bb,Bc,Bd =	Vector(tc.x, tc.y, bc.z):ToScreen(),					-- ( these are the ones at the bottom)
										Vector(tc.x, bc.y, bc.z):ToScreen(),
										Vector(bc.x, tc.y, bc.z):ToScreen(),
										Vector(bc.x, bc.y, bc.z):ToScreen()

					local x,y =	math.min(Ta.x, Tb.x, Tc.x, Td.x,   Ba.x, Bb.x, Bc.x, Bd.x),		-- Get the lowest x,y values (the top left of the 2d bounding box)
								math.min(Ta.y, Tb.y, Tc.y, Td.y,   Ba.y, Bb.y, Bc.y, Bd.y)

					local w,h =	math.max(Ta.x, Tb.x, Tc.x, Td.x,   Ba.x, Bb.x, Bc.x, Bd.x) - x,	-- Get the highest x,y values, and subtract the lowest (Giving us the height & Width)
								math.max(Ta.y, Tb.y, Tc.y, Td.y,   Ba.y, Bb.y, Bc.y, Bd.y) - y

					draw.SimpleTextOutlined(pl:Nick(), "Default", x + (w*0.1), y+ (h*0.1), color_white, nil, nil, 1, color_black) 

					surface.SetDrawColor( 30, 200, 30, 255 )
					surface.DrawOutlinedRect( x, y, w, h )										-- Draw the box
					surface.DrawOutlinedRect( x-1, y, w+2, h+1 )								-- Make it thicker

				end
			end
		end
	end