local twep = {"weapon_mu_knife"}
local tgun = {"weapon_mu_magnum"}
local ESP = CreateClientConVar("Murder_ESP", "1", true, false)
local Murderer = CreateClientConVar("Murder_Auto", "1", true, false)
local names = CreateClientConVar("Murder_Names", "1", true, false)
local evidence = CreateClientConVar("Murder_Evidence", "1", true, false)
local round = true

for _,v in pairs(player.GetAll()) do
v.HatMurderer = nil
end
for _,v in pairs(ents.GetAll()) do
v.HatESPTracked = nil
end

function check()
	for _,v in pairs( ents.GetAll() ) do
		local pl = v.Owner
		if IsValid(pl) and !v.hatESPTracked then
			if table.HasValue(twep, v:GetClass()) then
                if IsValid(v) then
                    local col = pl:GetPlayerColor()
                    col = Color(col.x * 255, col.y * 255, col.z * 255)
                    chat.AddText(col, pl:Name(), ", ", pl:GetNWString("bystanderName"), Color(255, 255, 255), " is the ", Color(255, 0, 0), "MURDERER")
                else
                    chat.AddText(Color(200, 200, 200), "The knife is on the ground.")
                end
			end
			if table.HasValue(tgun, v:GetClass()) then
                if IsValid(v) then
                    local col = pl:GetPlayerColor()
                    col = Color(col.x * 255, col.y * 255, col.z * 255)
                    chat.AddText(col, pl:Name(), ", ", pl:GetNWString("bystanderName"), Color(255, 255, 255), " has a ", Color(0, 255, 0), "GUN")
                else
                    chat.AddText(Color(200, 200, 200), "A gun is on the ground.")
                end
			end
		end
	end
end
concommand.Add( "Murder_Check", check)

function getNames()
	for _,v in pairs( player.GetAll() ) do
		if IsValid(v) then
			local col = v:GetPlayerColor()
			col = Color(col.x * 255, col.y * 255, col.z * 255)
			print(col, v:GetName(), ", ", v:GetNWString("bystanderName"))
		end
	end
end
concommand.Add( "Murder_getNames", getNames)
hook.Add("CreateMove", "murder_checker", function()
	if Murderer:GetInt() == 1 and GAMEMODE.RoundStage == 1 and round == false then
        round = true
		for _,v in pairs( ents.GetAll() ) do
		local pl = v.Owner
			if IsValid(pl) and !v.hatESPTracked then
				if IsValid(v) and table.HasValue(twep, v:GetClass()) then
					local col = pl:GetPlayerColor()
					col = Color(col.x * 255, col.y * 255, col.z * 255)
					chat.AddText(col, pl:Name(), ", ", pl:GetNWString("bystanderName"), Color(255, 255, 255), " is the ", Color(255, 0, 0), "MURDERER")
				end
				if IsValid(v) and table.HasValue(tgun, v:GetClass()) then
					local col = pl:GetPlayerColor()
					col = Color(col.x * 255, col.y * 255, col.z * 255)
					chat.AddText(col, pl:Name(), ", ", pl:GetNWString("bystanderName"), Color(255, 255, 255), " has a ", Color(0, 255, 0), "GUN")
				end
			end
		end
    elseif GAMEMODE.RoundStage != 1 then
        round = false
	end
end)

hook.Add( "HUDPaint", "aimbot.Wallhack", function()
for k,v in pairs ( player.GetAll() ) do
 
        local Position = ( v:GetPos() + Vector( 0,0,80 ) ):ToScreen()
        local Name = ""
 
        if v == LocalPlayer() then Name = "" else Name = v:Name() end
 
end
 
end )
local function coordinates( ent )
	local min, max = ent:OBBMins(), ent:OBBMaxs()
	local corners = {
			Vector( min.x, min.y, min.z ),
			Vector( min.x, min.y, max.z ),
			Vector( min.x, max.y, min.z ),
			Vector( min.x, max.y, max.z ),
			Vector( max.x, min.y, min.z ),
			Vector( max.x, min.y, max.z ),
			Vector( max.x, max.y, min.z ),
			Vector( max.x, max.y, max.z )
	}
 
	local minX, minY, maxX, maxY = ScrW() * 2, ScrH() * 2, 0, 0
	for _, corner in pairs( corners ) do
		local onScreen = ent:LocalToWorld( corner ):ToScreen()
        minX, minY = math.min( minX, onScreen.x ), math.min( minY, onScreen.y )
        maxX, maxY = math.max( maxX, onScreen.x ), math.max( maxY, onScreen.y )
	end
 
	return minX, minY, maxX, maxY
end

local function MESPCheck(v)
	if v:Alive() == true && v:Health() ~= 0 && v:Health() >= 0 && v ~= LocalPlayer() && LocalPlayer():Alive() then
		return true
	else
		return false
	end
end

hook.Add("HUDPaint", "ESPs", function()
	if ESP:GetInt() == 1 then
		for k,v in pairs(player.GetHumans()) do
			for k,v2 in pairs(v:GetWeapons()) do
				if v2:GetClass() == "weapon_mu_knife" and MESPCheck(v) then
					cam.Start3D(EyePos(), EyeAngles())
					v:SetMaterial("models/debug/debugwhite")
					v:SetColor(Color(255, 0, 0, 255))
					render.MaterialOverride("models/debug/debugwhite")
					render.SuppressEngineLighting( false )
					render.SetBlend( 0.3 )
					render.SetColorModulation( 1, 0, 0 )
					v:DrawModel()
					cam.End3D()
				elseif v2:GetClass() == "weapon_mu_magnum" and MESPCheck(v) then
					cam.Start3D(EyePos(), EyeAngles())
					v:SetMaterial("models/debug/debugwhite")
					v:SetColor(Color(0, 255, 0, 255))
					render.MaterialOverride("models/debug/debugwhite")
					render.SuppressEngineLighting( false )
					render.SetBlend( 0.3 )
					render.SetColorModulation( 0, 1, 0 )
					v:DrawModel()
					cam.End3D()
				end
			end
			if names:GetInt() == 1 and MESPCheck(v) then
				local ESP = (v:EyePos()):ToScreen()
				local col = v:GetPlayerColor()
				col = Color(col.x * 255, col.y * 255, col.z * 255)
				local x1,y1,x2,y2 = coordinates(v)
				surface.SetDrawColor(col)
	
		
				surface.DrawLine( x1, y1, math.min( x1 + 25, x2 ), y1 )
				surface.DrawLine( x1, y1, x1, math.min( y1 + 25, y2 ) )

	
				surface.DrawLine( x2, y1, math.max( x2 - 25, x1 ), y1 )
				surface.DrawLine( x2, y1, x2, math.min( y1 + 25, y2 ) )
	
 
				surface.DrawLine( x1, y2, math.min( x1 + 25, x2 ), y2 )
				surface.DrawLine( x1, y2, x1, math.max( y2 - 25, y1 ) )
 
 
				surface.DrawLine( x2, y2, math.max( x2 - 25, x1 ), y2 )
				surface.DrawLine( x2, y2, x2, math.max( y2 - 25, y1 ) )
				draw.DrawText(v:Name() .. ", " .. v:GetNWString("bystanderName"), "DefaultFixed", ESP.x, ESP.y, col, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
			end
		end
	end
	if evidence:GetInt() == 1 then
		for k, v in pairs(ents.FindByClass("mu_loot")) do
			if IsValid(v) then
				cam.Start3D(EyePos(), EyeAngles())
				v:SetMaterial("models/debug/debugwhite")
				v:SetColor(Color(255, 255, 255, 255))
				render.MaterialOverride("models/debug/debugwhite")
				render.SuppressEngineLighting( false )
				render.SetBlend( 0.3 )
				render.SetColorModulation( 0, 1, 0 )
				v:DrawModel()
				cam.End3D()
			end
		end
        for k, v in pairs(ents.FindByClass("weapon_mu")) do
            if IsValid(v) then
				cam.Start3D(EyePos(), EyeAngles())
				v:SetMaterial("models/debug/debugwhite")
				v:SetColor(Color(0, 0, 255, 255))
				render.MaterialOverride("models/debug/debugwhite")
				render.SuppressEngineLighting( false )
				render.SetBlend( 0.3 )
				render.SetColorModulation( 0, 1, 0 )
				v:DrawModel()
				cam.End3D()
			end
        end
	end
end)

local struc = {}
struc.pos = {}
struc.pos[1] = 100 -- x pos
struc.pos[2] = 200 -- y pos
struc.color = Color(255,0,0,255) -- Red
struc.text = "Hello World" -- Text
struc.font = "DefaultFixed" -- Font
struc.xalign = TEXT_ALIGN_CENTER -- Horizontal Alignment
struc.yalign = TEXT_ALIGN_CENTER -- Vertical Alignment
draw.Text( struc )