// by @kust1k and @Lazarus

var shot_data = [];

function player_hurt()
{

    attacker = Event.GetInt("attacker");
    attacker_entindex = Entity.GetEntityFromUserID(attacker);

    victim = Event.GetInt("userid");
    victim_entindex = Entity.GetEntityFromUserID(victim);
  
    if (attacker_entindex != Entity.GetLocalPlayer()) return;
  
    shot_data = [true, 255, Event.GetString("health")];

}

function on_paint()
{
  
    var screen_size = Global.GetScreenSize();
  
    if (shot_data[0])
    {
      
        shot_data[1] = shot_data[1] - 5;
      
        if (shot_data[1] <= 0)
        {
            shot_data[0] = false; 
        }
      
        var a = 4;
        var b = a + 6;
      
        var red = [255,0,0,shot_data[1]]
        var white = [255,255,255,shot_data[1]]
      
        var color = shot_data[2] <= 0 ? red : white;
      
        Render.Line(screen_size[0] / 2 - b, screen_size[1] / 2 - b, screen_size[0] / 2 - a, screen_size[1] / 2 - a, color); //Left Upper
        Render.Line(screen_size[0] / 2 - b, screen_size[1] / 2 + b, screen_size[0] / 2 - a, screen_size[1] / 2 + a, color); //Left Down
        Render.Line(screen_size[0] / 2 + b, screen_size[1] / 2 + b, screen_size[0] / 2 + a, screen_size[1] / 2 + a, color); //Right Down
        Render.Line(screen_size[0] / 2 + b, screen_size[1] / 2 - b, screen_size[0] / 2 + a, screen_size[1] / 2 - a, color); //Right Upper
      
    }
  
}
Cheat.RegisterCallback("Draw", "on_paint");
Cheat.RegisterCallback("player_hurt", "player_hurt");