include("shared.lua")

net.Receive("DarkRP_DonationBox", function()
	local amount = net.ReadUInt(32)
	chat.AddText(Color(50, 255, 50, 255), "Jemand hat $"..string.Comma(amount).." in deine Spendentruhe gelegt.")
	surface.PlaySound("mg_mp3/buy_item.mp3")
end)

local local_ply, distance
function ENT:Draw()
	self:DrawModel()
	local_ply = local_ply or LocalPlayer()
	distance = local_ply:EyePos():DistToSqr(self:GetPos())
	if distance < 2250000 then
		local pos = self:GetPos()
		local ang = self:GetAngles()
		local owner = self:Getowning_ent()
		owner = "Besitzer: "..((IsValid(owner) and owner:Name()) or "Niemand")
		surface.SetFont("HUDNumber5")
		ang:RotateAroundAxis(ang:Up(), 90)
		ang:RotateAroundAxis(ang:Forward(), 76.5)
		cam.Start3D2D(pos + (ang:Right() * -20) + (ang:Up() * -14.51), ang, 0.15)
			draw.DrawText("Spendentruhe", "HUDNumber5", 0, -70, color_white, TEXT_ALIGN_CENTER)
		cam.End3D2D()
		cam.Start3D2D(pos + (ang:Right() * -20) + (ang:Up() * -14.51), ang, 0.11)
			draw.DrawText(owner, "HUDNumber5", 0, -20, color_white, TEXT_ALIGN_CENTER)
			draw.DrawText("Spenden: $"..string.Comma(self:GetMoneyInput()), "HUDNumber5", 0, 10, color_white, TEXT_ALIGN_CENTER)
		cam.End3D2D()
	end
end