Vgui information on head

Today I am releasing a custom addon that I have been using that everyone I know loves so far. I don’t know how to code much actually barely but its a start.

http://images.akamai.steamusercontent.com/ugc/425944361419563333/D8CFA0A9CCCF7C059419806CDA592BD0BA64F8AA/

This code isn’t much but it is very useful for games that are two TEAMS such as zombie survival TEAM_UNDEAD and TEAM_SURVIVOR this is configurable so you can make it so 1 TEAM may only see the information of the their TEAM.

This is based off ulx ranks

Please give me feeback thank you!



--Codded by DarkMinion--
local ply = LocalPlayer();
local Tags = {} 
Tags["owner"] = "Owner";
Tags["superadmin"] = "Super Admin";
Tags["admin"] = "Administrator";
Tags["mod"] = "Moderator";
Tags["vip"] = "VIP";
Tags["operator"] = "DJ";
Tags["user"] = "";
-- Example Tags["USERGROUP"] = "DISPLAY NAME";

hook.Add("PostDrawOpaqueRenderables", "drawadminname", function()
        for k, ply in pairs( player.GetAll() ) do
        if (  !ply:Alive() ) then return end  
        local offset = Vector(0,0,85)
        local offset2 = Vector(0,0,80)
		local offset3 = Vector(0,0,75)
		local offset4 = Vector(0,0,70)
        local ang = LocalPlayer():EyeAngles()
        local pos = ply:GetPos() + offset + ang:Up()
        local pos2 = ply:GetPos() + offset2 + ang:Up()
		local pos3 = ply:GetPos() + offset3 + ang:Up()
		local pos4 = ply:GetPos() + offset4 + ang:Up()
        ang:RotateAroundAxis(ang:Forward(),90)
        ang:RotateAroundAxis(ang:Right(),90)
        local tag = Tags[ply:GetUserGroup()]
        if tag and (team.GetName(LocalPlayer():Team()) == team.GetName(ply:Team())) then
        cam.Start3D2D(pos,Angle(0,ang.y,90),0.25)
                draw.SimpleTextOutlined(ply:Nick() ,"Trebuchet24",1,1,team.GetColor(ply:Team()),TEXT_ALIGN_CENTER,1,1,HSVToColor( ply:Health(), 1, 1) )
        cam.End3D2D()
		cam.Start3D2D(pos2,Angle(0,ang.y,90),0.25)
                draw.SimpleTextOutlined(tag ,"Trebuchet24",2,2,HSVToColor(math.abs(math.sin(CurTime() *0.1) *335), 1, 1),TEXT_ALIGN_CENTER,1,1,Color(0,0,0))
        cam.End3D2D()
		cam.Start3D2D(pos3,Angle(0,ang.y,90),0.25)
                draw.SimpleTextOutlined("Armor: " .. ply:Armor()  ,"Trebuchet24",3,3,team.GetColor(ply:Team()),TEXT_ALIGN_CENTER,1,1,HSVToColor( ply:Armor(), 1, 1) )
        cam.End3D2D()
		cam.Start3D2D(pos4,Angle(0,ang.y,90),0.25)
                draw.SimpleTextOutlined("Health: " .. ply:Health()  ,"Trebuchet24",3,3,team.GetColor(ply:Team()),TEXT_ALIGN_CENTER,1,1,HSVToColor( ply:Health(), 1, 1) )
        cam.End3D2D()
        end
        end
end)



If you wan’t this so that all TEAM_ can see eachothers vgui comment out


 --if tag and (team.GetName(LocalPlayer():Team()) == team.GetName(ply:Team())) then

and either remove an “end” or comment it.

I believe this addon is so useful and for how small the code is I never have seen one of these before other then just for DarkRP.

[editline]24th September 2015[/editline]

If you’d like to edit it for yourself and you are a good coder could you please help me advance it?
I haven’t really wanting to release this because I wanted my server to be custom but facepunch is an amazing community and I need to giveback to it. If someone would like to add a function to it so it gets jobs for darkrp please post a reply to those who need it for darkrp.

http://cache.www.gametracker.com/server_info/192.223.24.91:27015/b_160_400_2_ffffff_c5c5c5_ff9900_000000_1_1_1.png Here is my server if you want to see what it looks like in person before bothering to test it.

Neat.
I’ve been having trouble with 3d2d for some reason, and this could be a big help hehe <3

Edit:

Although you should try not to hard code it that much, instead of calling Start3D2D so much and making the positions variables like that, you could find the text height and add to the position depending on the height.

I actually don’t know how I would do that mind telling me XD?

Woops Didn’t see you respond :V

You would use:



surface.SetFont("Trebuchet24")


then do something like this:



local tw, th = surface.GetTextSize( "YourTexthere" )


The tw is the text width and the th is the text height.
So just start your 3d2d at the top vector, then just alter the SimpleTextOutlined’s x, y position. :slight_smile:

so example:



draw.SimpleText( "Test", "Trebuchet18", 3, 3+th, color_white, TEXT_ALIGN_LEFT )
draw.SimpleText( "Test2", "Trebuchet18", 3, 3+th*2, color_white, TEXT_ALIGN_LEFT )
draw.SimpleText( "Test3", "Trebuchet18", 3, 3+th*3, color_white, TEXT_ALIGN_LEFT )


or you could do a for loop and do:



local myText = {"Test", "Test2", "Test3"}

surface.SetFont( 'Trebuchet18' )
for i, v in pairs( myText ) do
  local tw, th = surface.GetTextSize( v )
  draw.SimpleText( (v or "Error"), "Trebuchet18", 3, 3+th*i, color_white, TEXT_ALIGN_LEFT )
end


I might have made like the smallest error, if I did, sorry its early V:

(And With the for loop if the player didn’t have a tag then you could do a check before the drawing of the text doing
if v ~= “” then
so it will automatically ‘slide’ the text below back up, I guess you could say, so you don’t just have this weird gap just sitting there. :V

This looks pretty cool I think I will try it out. Thanks for the release.

<3