local dr_time1 = {}
local ready1 = {}

function breaking_glass_init(e)
	ready1[e] = 0
	dr_time1[e] = nil
end

function breaking_glass_main(e)

	PlayerDist = GetPlayerDistance(e)
	GetEntityPlayerVisibility(e)
	
	
if PlayerDist < 700 and g_Entity[e]['plrvisible'] == 1 then	
	--Prompt(ready1[e] .." - " ..g_Entity[e]['plrvisible'] .." - " .." g_Entity[e]['health'] " ..g_Entity[e]['health'])
	--Prompt(round(PlayerDist,1) .." - " ..g_Entity[e]['plrvisible'] .." - " .." g_Entity[e]['health'] " ..g_Entity[e]['health'])
	
	if ready1[e] == 0 then
		if g_Entity[e]['health'] >= 1 and g_Entity[e]['health'] < 50 then
			PlayAnimation(e,0) 
			PlaySound(e,0)
			ready1[e] = 1
		end	
	end

if ready1[e] == 1 then	
	if dr_time1[e] == nil then dr_time1[e] = GetTimer(e) end
	if GetTimer(e) > dr_time1[e] + 1000 then CollisionOff(e) end
end

end --PlayerDist
end --main

function breaking_glass_exit(e)	
end

function round(num, idp)
  local mult = 10^(idp or 0)
  return math.floor(num * mult + 0.5) / mult
end