var traceContainer = [];
function tracer(eyepos, hitpos, time) {
    this.eyepos = eyepos
    this.position = hitpos
    this.time = time
}
var impact = 0;
function onBulletImpact() {
    if (Globals.Tickcount() > impact) {
        if (Entity.GetEntityFromUserID(Event.GetInt("userid")) == Entity.GetLocalPlayer()) {
            var x = Event.GetFloat("x")
            var y = Event.GetFloat("y")
            var z = Event.GetFloat("z")

            var pos = [x, y, z]

            var view = Entity.GetEyePosition(Entity.GetLocalPlayer());

            traceContainer.push(new tracer(view, pos, Globals.Tickcount()))
            impact = Globals.Tickcount()
        }
    }
}
function onDraw() {
    if (0) {
        traceContainer = [];
        return
    }
    var t = 300
    var col = UI.GetColor("Misc", "JAVASCRIPT", "Local Cross color")
    
    for (i in traceContainer) {
       
        var ss = Render.GetScreenSize()
        var view2s = Render.WorldToScreen(traceContainer[i].eyepos)
        var pos2s = Render.WorldToScreen(traceContainer[i].position)
        if (1) {
         
           
            if (1) {
                currenteye = Entity.GetEyePosition(Entity.GetLocalPlayer())
                
                var dx = currenteye[0] - traceContainer[i].eyepos[0];
                var dy = currenteye[1] - traceContainer[i].eyepos[1];
                var dz = currenteye[2] - traceContainer[i].eyepos[2];

                var dist = Math.sqrt(dx * dx + dy * dy + dz * dz);

                if (1) {
                    Render.Line(pos2s[0]+3, pos2s[1], pos2s[0]-5, pos2s[1], col)
                    
					Render.Line(pos2s[0]-1, pos2s[1]+4, pos2s[0]-1, pos2s[1]-4, col) //VERT
                }
            }
        }
        if (traceContainer[i].time + t < Globals.Tickcount()) {
            traceContainer.shift()
        }
        if (5 < traceContainer.length) {
            traceContainer.shift()
        }
    }
}


UI.AddColorPicker("Local Cross color")

Cheat.RegisterCallback("Draw", "onDraw")
Cheat.RegisterCallback("bullet_impact", "onBulletImpact")