// NORMAL CONFIGS
local PInfo_IsTTT = false // Force TTT, should not be set to true unless you have a custom gamemode name.
local PInfo_IsDarkRP = false // Force DARKRP, should not be set to true unless you have a custom gamemode name.
//local LerpSpeed = 10 // NOT USED
local PInfo_Size = 0.10 // The size of the info panel.
local PInfo_DisplayTime = 1 // How many seconds the info is displayed before fading out?
local PInfo_FadeSpeed = 10 // The fading speed
local PInfo_ShouldShowOnTab = false // Should we show all player's info when tabbing?
local PInfo_OnTabDisplayTime = 4 // How many seconds the info is displayed when pushing tab?
local PInfo_TabDisplayRange = 800 // The range at which the info is displayed when pressing tab.
local PInfo_Opacity = 1.2 // The opacity (don't go too high);
// Camera Variables
local HeightOffset = 65 // Offset of the display panel.
local RightOffset = 20 // Distance from the player.
local ForwardOffset = -5 // Distance in terms of depth
local ForwardBackOffset = 1.5 // More depth customization
// Drawing Variables.
local PaddingX = 40 // Padding X (Size)
local Height = 60 // The height of panels.
local PaddingY = 6 // Padding Y
local InfoRectSize = 10 // Size of the small rectangle with the color information.
local InfoRectAlpha = 100 // The alpha of said rectangle.
local InfoRectColor = Color( 150, 150, 150, InfoRectAlpha ) // Color, not used in DarkRP or TTT
local BackgroundColor = Color( 50, 50, 50, 100 )
//local gradient = surface.GetTextureID( "gui/gradient" )
--Chill:stripped this from another script that does the color thing I want.
--[[
function GetColorForPlayer(ply)
--if ply:SteamID() == "STEAM_0:0:68825805" then -- You should leave my steam ID here. :3
--return HSVToColor( math.abs(math.sin(0.3*RealTime())*128), 1, 1 ) -- Color fade
--elseif ply:IsAdmin() then -- Admins will get a light white color.
--return Color(255,255,255,60)
if ply:IsUserGroup("Noob") then
return Color(200,30,30,150)
elseif ply:IsUserGroup("user") then
return Color(255,255,120,150)
elseif ply:IsUserGroup("user2") then
return Color(255,250,80,150)
elseif ply:IsUserGroup("user3") then
return Color(255,240,50,150)
elseif ply:IsUserGroup("user4") then
return Color(255,230,0,150)
elseif ply:IsUserGroup("moderator") then
return Color(255,200,30,150)
elseif ply:IsUserGroup("admin") then
return Color(110,255,110,150)
elseif ply:IsUserGroup("super_admin") then
return Color(30,230,30,150)
elseif ply:IsUserGroup("mega_admin") then
return Color(30,210,210,150)
elseif ply:IsUserGroup("uber_admin") then
return Color(30,255,255,150)
elseif ply:IsUserGroup("operator") then
return Color(255,30,255,150)
elseif ply:IsUserGroup("superadmin") then
return Color(150,30,255,150)
end
end
]]--
--Chill: here's the one that applies the viewer's color to everyone else.
--color = GetColorForPlayer
--color = team.GetColor( ply:Team() )
--color = Color( color.r, color.g, color.b, InfoRectAlpha * ply.PInfo_Alpha * PInfo_Opacity )
// Text info
local TextColor = Color( 255, 255, 255, 200 ) // Color of the displayed text.
surface.CreateFont( "PInfo_Font", {
font = "Verdana",
size = 50,
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = true,
symbol = false,
rotary = false,
shadow = true,
additive = true,
outline = false
} )
local PInfo_Players = PInfo_Players or {}
local PI_IMG_HP = Material( "icon16/add.png" )
function PInfo_IsTTTActive()
if PInfo_IsTTT or gmod.GetGamemode().Name == "Trouble in Terrorist Town" then return true end
return false
end
function PInfo_IsDarkRPActive()
if PInfo_IsDarkRP or gmod.GetGamemode().Name == "DarkRP" then return true end
return false
end
PInfo_Values = PInfo_Values or {
// Return the name.
function( ply ) return ply:GetName() end,
// Return the health.
function( ply ) return "Health: " .. ply:Health(), PI_IMG_HP end,
--// Return the player's active weapon.
--function( ply )
--if IsValid( ply:GetActiveWeapon() ) then
--return ply:GetActiveWeapon():GetPrintName() or ""
--end
--end
}
hook.Add( "Initialize", "PInfo_Init", function()
if PInfo_IsDarkRPActive() then
PInfo_Values = {
// Return the name.
function( ply ) return ply:GetName() end,
// Return the job.
function( ply ) return ply.DarkRPVars.job or "Jobless" end,
// Return the health.
function( ply ) return "Health: " .. ply:Health(), PI_IMG_HP end,
// Return the cash.
function( ply ) return "$".. ( ply.DarkRPVars.money or 0 ) end,
--// Return the player's active weapon.
--function( ply )
--if IsValid( ply:GetActiveWeapon() ) then
--return ply:GetActiveWeapon():GetPrintName() or ""
--end
--end
}
// TTT Values
elseif PInfo_IsTTTActive() then
PInfo_Values = {
// Return the name.
function( ply ) return ply:GetName() end,
// Return the role.
function( ply )
local txt = "Innocent"
if ply:IsTraitor() then
txt = "Traitor"
elseif ply:IsDetective() then
txt = "Detective"
end
return txt;
end,
// Return the health status.
function( ply ) return LANG.GetUnsafeLanguageTable()[util.HealthToString( ply:Health() )], PI_IMG_HP end,
// Return the active weapon's print name.
--function( ply )
--if IsValid( ply:GetActiveWeapon() ) then
--return LANG.GetUnsafeLanguageTable()[(ply:GetActiveWeapon():GetPrintName() or "")]
--end
--end
}
end
end )
hook.Add( "PostDrawTranslucentRenderables", "PInfo_PostDrawTranslucentRenderables", function()
for ply,_ in pairs( PInfo_Players ) do
if !IsValid(ply) or !ply:Alive() then return end
if !ply.PInfo_Alpha then
ply.PInfo_Alpha = 0;
end
if ply.PInfo_Alpha <= 0 then return end
local offset = Vector( 0, 0, HeightOffset )
local ang = LocalPlayer():EyeAngles()
local pos = ply:GetPos() + offset + ang:Up() + ang:Right() * RightOffset + ang:Forward() * ( ForwardOffset + ( math.sin( CurTime() * 2 )) )
local backPos = pos + ang:Forward() * ForwardBackOffset
ang:RotateAroundAxis( ang:Forward(), 90 )
ang:RotateAroundAxis( ang:Right(), 90 )
local realAng = ang.y - 5
// Background cam
cam.Start3D2D( backPos, Angle( 0, realAng + 90 - 90 * ( ply.PInfo_Alpha ), 85 ), PInfo_Size )
local i = 0;
for k,v in pairs( PInfo_Values ) do
PInfo_BackDraw( ply, 5, i * ( Height + PaddingY ), v( ply ) )
i = i + 1;
end
cam.End3D2D()
// Foreground cam
cam.Start3D2D( pos, Angle( 0, realAng + 90 - 90 * ( ply.PInfo_Alpha ) , 85 ), PInfo_Size )
local i = 0;
for k,v in pairs( PInfo_Values ) do
PInfo_Draw( ply, 5, i * ( Height + PaddingY ), v( ply ) )
i = i + 1;
end
cam.End3D2D()
end
end )
hook.Add( "Think", "PInfo_Think", function()
if !IsValid( LocalPlayer() ) then return end
local eyeTrace = LocalPlayer():GetEyeTrace()
if eyeTrace.Entity and eyeTrace.Entity:IsPlayer() then
PInfo_AddDrawPlayer( eyeTrace.Entity );
end
PInfo_UpdateDrawPlayers()
end)
hook.Add( "ScoreboardShow", "PInfo_ScoreboardShow", function()
if PInfo_ShouldShowOnTab then
for _,ent in pairs(ents.FindInSphere( LocalPlayer():GetPos(), PInfo_TabDisplayRange )) do
if IsValid(ent) and ent:IsPlayer() then
PInfo_AddDrawPlayer( ent, PInfo_OnTabDisplayTime );
end
end
end
end )
// DRAWING FUNCTIONS (BACKGROUND)
function PInfo_BackDraw( ply, x, y, text, image )
if ( !text ) then return end
surface.SetFont( "PInfo_Font" )
local w,h = surface.GetTextSize( text )
surface.SetDrawColor( Color( BackgroundColor.r, BackgroundColor.g, BackgroundColor.b, BackgroundColor.a * ply.PInfo_Alpha * PInfo_Opacity ) )
surface.DrawRect( x, y, PaddingX + w, Height )
if ply and PInfo_IsDarkRPActive() then
color = ply:getJobTable().color
color = Color( color.r, color.g, color.b, InfoRectAlpha * ply.PInfo_Alpha * PInfo_Opacity )
elseif ply and PInfo_IsTTTActive() then
if ply:IsTraitor() then
color = Color( COLOR_RED.r * 0.75, COLOR_RED.g * 0.75, COLOR_RED.b * 0.75, InfoRectAlpha * ply.PInfo_Alpha * PInfo_Opacity )
elseif ply:IsDetective() then
color = Color( COLOR_BLUE.r * 0.75, COLOR_BLUE.g * 0.75, COLOR_BLUE.b * 0.75, InfoRectAlpha * ply.PInfo_Alpha * PInfo_Opacity )
else
color = Color( COLOR_GREEN.r * 0.75, COLOR_GREEN.g * 0.75, COLOR_GREEN.b * 0.75, InfoRectAlpha * ply.PInfo_Alpha * PInfo_Opacity )
end
end
surface.SetDrawColor( color or InfoRectColor )
surface.DrawRect( x - InfoRectSize, y, InfoRectSize - InfoRectSize * 0.5, Height )
surface.DrawRect( x - InfoRectSize, y, InfoRectSize, Height )
draw.DrawText( text, "PInfo_Font", x + w * 0.5 + PaddingX * 0.5 , y + h * 0.5 - 18, Color( 120, 120, 120, 150 * ply.PInfo_Alpha * PInfo_Opacity ), TEXT_ALIGN_CENTER )
end
// DRAWING FUNCTIONS (FOREGROUND)
function PInfo_Draw( ply, x, y, text, image )
if ( !text ) then return end
surface.SetFont( "PInfo_Font" )
local w,h = surface.GetTextSize( text )
surface.SetDrawColor( Color( 0, 0, 0, 20 * ply.PInfo_Alpha * PInfo_Opacity ) )
/*if ( image ) then
surface.SetMaterial( image )
surface.SetDrawColor( Color( 255, 255, 255, 255 * ply.PInfo_Alpha ) )
surface.DrawTexturedRect( x, y, Height * 0.25, Height * 0.25 )
end*/
draw.DrawText( text, "PInfo_Font", x + w * 0.5 + PaddingX * 0.5 , y + h * 0.5 - 18, Color( TextColor.r, TextColor.g, TextColor.b, TextColor.a * ply.PInfo_Alpha * PInfo_Opacity ) , TEXT_ALIGN_CENTER )
end
function PInfo_UpdateDrawPlayers()
for ply,time in pairs(PInfo_Players) do
if !IsValid( ply ) or !ply:Alive() then
PInfo_RemoveDrawPlayer( ply )
// Skip Local Player
elseif ply != LocalPlayer() then
if !ply.PInfo_Alpha or !time then
time = 10
ply.PInfo_Alpha = 1
end
if time > 0 then
if ply.PInfo_Alpha < 1 then
ply.PInfo_Alpha = math.Clamp( ply.PInfo_Alpha + FrameTime() * PInfo_FadeSpeed , 0, 1 )
end
PInfo_Players[ply] = time - FrameTime()
elseif ply.PInfo_Alpha > 0 then
ply.PInfo_Alpha = ply.PInfo_Alpha - FrameTime() * PInfo_FadeSpeed
else
PInfo_RemoveDrawPlayer( ply )
end
end
end
end
function PInfo_AddDrawPlayer( ply, time )
if !IsValid( ply ) or !ply:Alive() then return end
PInfo_Players[ply] = time or PInfo_DisplayTime;
ply.PInfo_Alpha = ply.PInfo_Alpha or 0;
end
function PInfo_RemoveDrawPlayer( ply )
PInfo_Players[ply] = nil;
end
hook.Add( "EntityRemove", "PInfo_EntityRemove", function( ent )
if ( IsValid( ent ) ) and ( ent:IsPlayer() ) then
PInfo_RemoveDrawPlayer( ent )
end
end )