From 4b069975e4f06f900e107dc46627a294e7b5da82 Mon Sep 17 00:00:00 2001 From: edshot99 Date: Sat, 21 Dec 2024 15:39:13 -0600 Subject: [PATCH] improvements --- player_esp/lua/autorun/client/esp.lua | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/player_esp/lua/autorun/client/esp.lua b/player_esp/lua/autorun/client/esp.lua index f749588..2293aac 100644 --- a/player_esp/lua/autorun/client/esp.lua +++ b/player_esp/lua/autorun/client/esp.lua @@ -1,25 +1,35 @@ +local ESP = CreateConVar("cl_esp", 1, {FCVAR_ARCHIVE}, "Toggle all ESP functionality", 0, 1) +local ESPBox = CreateConVar("cl_esp_box", 1, {FCVAR_ARCHIVE}, "Toggle ESP Wireframe", 0, 1) +local ESPInfo = CreateConVar("cl_esp_info", 1, {FCVAR_ARCHIVE}, "Toggle ESP player information", 0, 1) + local DrawTextFont = "BudgetLabel" local plys = player.GetAll() timer.Create("edshot_esp_findplys", 3, 0, function() plys = player.GetAll() end) hook.Add("PostDrawHUD", "edshot_esp_PostDrawHUD", function() + if ESP:GetBool() and ESPInfo:GetBool() then for _, ply in pairs(plys) do if (not IsValid(ply)) or (ply == LocalPlayer()) then continue end + local plyPosition = ply:GetPos() + ply:OBBCenter() + plyPosition = plyPosition:ToScreen() + if not plyPosition.visible then continue end + local plyColor = Color(255, 255, 255) if (not ply:Alive()) then plyColor = Color(255, 0, 0) end - local plyPosition = ply:GetPos():ToScreen() draw.DrawText(ply:GetName(), DrawTextFont, plyPosition.x, plyPosition.y, plyColor) draw.DrawText(ply:Health(), DrawTextFont, plyPosition.x, plyPosition.y + 15, plyColor) draw.DrawText(ply:Armor(), DrawTextFont, plyPosition.x + 30, plyPosition.y + 15, plyColor) draw.DrawText(math.Round(LocalPlayer():GetPos():Distance(ply:GetPos()), 0), DrawTextFont, plyPosition.x + 60, plyPosition.y + 15, plyColor) end + end end) hook.Add("PostDrawOpaqueRenderables", "edshot_esp_PostDrawOpaqueRenderables", function(bDrawingDepth, bDrawingSkybox, isDraw3DSkybox) + if ESP:GetBool() and ESPBox:GetBool() then for _, ply in pairs(plys) do if (not IsValid(ply)) or (ply == LocalPlayer()) then continue end @@ -28,4 +38,16 @@ hook.Add("PostDrawOpaqueRenderables", "edshot_esp_PostDrawOpaqueRenderables", fu render.DrawWireframeBox(ply:GetPos(), ply:GetAngles(), ply:OBBMins(), ply:OBBMaxs(), plyColor) end + end +end) + +function ESPConfig(CPanel) + CPanel:AddControl("Header", {Description = "Configure the ESP."}) + CPanel:AddControl("Checkbox", {Label = "Toggle ESP", Command = "cl_esp", min = 0, max = 1, Type = "int"}) + CPanel:AddControl("Checkbox", {Label = "Toggle ESP Wireframe", Command = "cl_esp_box", min = 0, max = 1, Type = "int"}) + CPanel:AddControl("Checkbox", {Label = "Toggle ESP Information", Command = "cl_esp_info", min = 0, max = 1, Type = "int"}) +end + +hook.Add("PopulateToolMenu", "edshot_esp_config", function() + spawnmenu.AddToolMenuOption("Options", "Player", "edshot_esp_config", "ESP", "", "", ESPConfig) end)