local pcam_x = CreateClientConVar("pcam_x", 0, true, false)
local pcam_y = CreateClientConVar("pcam_y", 0, true, false)
local pcam_w = CreateClientConVar("pcam_w", 300, true, false)
local pcam_h = CreateClientConVar("pcam_h", 300, true, false)
local CData = {}

chat.AddText(Color( 58, 58, 58), "[λρεx] ", Color( 16, 227, 0 ), "PropView Script Beta Loaded!  DON'T LEAK IT FAGGOT." )
print( "Propview script was made by Sasha http://steamcommunity.com/id/sv_scriptenforcer" )

function ViewPropMiniScreen()
	if MyProp != nil then
		if MyProp and MyProp:IsValid() then
			local pos = MyProp:GetPos() + Vector(0, 0, MyProp:OBBCenter().z)
			pos = pos - (EyeAngles():Forward() * 100)
			CData.origin = pos
			CData.angles = EyeAngles()
			CData.x = pcam_x:GetInt()
			CData.y = pcam_y:GetInt()
			CData.w = pcam_w:GetInt()
			CData.h = pcam_h:GetInt()
			render.RenderView( CData )
			draw.RoundedBox(1, (ScrW() / 2) - 1.5, (ScrH() / 2) - 1.5, 3, 3, Color(255,255,255,255))
		else
			MyProp = nil
		end
	end
end
hook.Add("HUDPaint", "VIEW MY PROP BITCH", ViewPropMiniScreen )		//I love naming my hooks like this, as you probably have noticed.  :3



function EntityCreated(ent)
	if ent != nil then
		if ent and ent:IsValid() then
			if string.match(string.lower(ent:GetClass()), "prop") then
				local spawner = nil
				for k, v in pairs(player.GetAll()) do
					if v != nil then
						if v and v:IsValid() then
							if v:Alive() then
								local tr = v:GetEyeTrace()
								if tr != nil and tr.Entity != nil then
									local trent = tr.Entity
									if trent and trent:IsValid() then
										if trent == ent then
											if v == LocalPlayer() then
												MyProp = ent
											end
											spawner = v
										end
									end
								end
							end
						end
					end
				end
				if spawner != nil and spawner:IsValid() then
					print("[λρεx]" ..spawner:Nick() .. " (" .. spawner:SteamID() .. ") spawned a " .. ent:GetClass() .. " with model " .. ent:GetModel() .. ".");		//This prints who spawned what, and the model path of that prop.
				end
			end
		end
	end
end
hook.Add("OnEntityCreated", "WHO SPAWNED WHAT NOW??",  EntityCreated)