edshot_sandbox_hotfixes/player_esp/lua/autorun/client/esp.lua

54 lines
2.5 KiB
Lua
Raw Permalink Normal View History

2024-12-18 23:38:34 -05:00
2024-12-21 16:39:13 -05:00
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)
2024-12-18 23:38:34 -05:00
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()
2024-12-21 16:39:13 -05:00
if ESP:GetBool() and ESPInfo:GetBool() then
2024-12-18 23:38:34 -05:00
for _, ply in pairs(plys) do
if (not IsValid(ply)) or (ply == LocalPlayer()) then continue end
2024-12-21 16:39:13 -05:00
local plyPosition = ply:GetPos() + ply:OBBCenter()
plyPosition = plyPosition:ToScreen()
if not plyPosition.visible then continue end
2024-12-18 23:38:34 -05:00
local plyColor = Color(255, 255, 255)
if (not ply:Alive()) then plyColor = Color(255, 0, 0) end
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
2024-12-21 16:39:13 -05:00
end
2024-12-18 23:38:34 -05:00
end)
hook.Add("PostDrawOpaqueRenderables", "edshot_esp_PostDrawOpaqueRenderables", function(bDrawingDepth, bDrawingSkybox, isDraw3DSkybox)
2024-12-21 16:39:13 -05:00
if ESP:GetBool() and ESPBox:GetBool() then
2024-12-18 23:38:34 -05:00
for _, ply in pairs(plys) do
if (not IsValid(ply)) or (ply == LocalPlayer()) then continue end
local plyColor = Color(0, 255, 0)
if (not ply:Alive()) then plyColor = Color(255, 0, 0) end
render.DrawWireframeBox(ply:GetPos(), ply:GetAngles(), ply:OBBMins(), ply:OBBMaxs(), plyColor)
end
2024-12-21 16:39:13 -05:00
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)
2024-12-18 23:38:34 -05:00
end)