function pHurt() {
        attackerEntity = Entity.GetEntityFromUserID(Event.GetInt("attacker"));
        localEntity = Entity.GetLocalPlayer();
     
        if (attackerEntity == localEntity) {
            victimName = Entity.GetName(Entity.GetEntityFromUserID(Event.GetInt("userid")));
            //Get hitgroup as a string
         
            hitboxName = hitgroupToHitbox(Event.GetInt("hitgroup"));
         
            damageDone = Event.GetInt("dmg_health");
            healthRemaining = Event.GetInt("health");
         
            hurtLogs.push([victimName, hitboxName, damageDone, healthRemaining, 0, 255, (Math.random() * (0.2 - 1.200) + 1.200).toFixed(4), Globals.Curtime()]);
        }
    }

    // [ victimName, hitboxName, damageDone, healthRemaining, curLength, opacity ];
    hurtLogs = [ ];

    typeSpeed = 0.05;
    fadeOutSpeed = 3;
    showDelayTime = typeSpeed + Globals.Curtime();
    function showOrHide() {
        for (var i = 0; i < hurtLogs.length; i++) {
            hurtLogs[i][4]++;
            toSay =  victimName + " "+ hitboxName  + " " + damageDone  + " "+ "(" + healthRemaining +")";
            if(Globals.Curtime() - hurtLogs[i][7] < 2)
            {
                continue
            }
            hurtLogs[i][5] -= Globals.Frametime() * 500;
         
            if (hurtLogs[i][5] < 0) {
                hurtLogs.shift(i, 1);
            }
        }
    }

    function drawLogs() {
        localplayer_index = Entity.GetLocalPlayer( );
        localplayer_alive = Entity.IsAlive( localplayer_index );
            if (localplayer_alive == true){
                screen = Render.GetScreenSize()
                textX = (screen[0]/2)
                textY = (screen[1]/2) + 62
         
                textYIncrement = 12;
             
                textCol = [255, 255, 255];
         
             
                for (var i = 0; i < hurtLogs.length; i++) {
                    currentLog = hurtLogs[i];
                 
                    victimName = currentLog[0];
                    hitboxName = currentLog[1];
                    damageDone = currentLog[2];
                    healthRemaining = currentLog[3];
         
                    consolasFont = Render.AddFont("consola", 11, 80);
                 
                    currentTextPos = textY + (textYIncrement * i);
                 
                    toSay =  victimName + " "+ hitboxName  + " " + "-"+damageDone  + " "+ "(" + healthRemaining +")";
         
                    textCol = [255,255,255];
                    textColdead = [200,0,0];
                    if (healthRemaining > 0){
                        Render.String(textX + 1, currentTextPos + 1, 1, toSay, [0, 0, 0, hurtLogs[i][5]], consolasFont);
                        Render.String(textX, currentTextPos, 1, toSay, [textCol[0], textCol[1], textCol[2], hurtLogs[i][5]], consolasFont);
                    }
                    if (healthRemaining <= 0){
                        Render.String(textX + 1, currentTextPos + 1, 1, toSay, [0, 0, 0, hurtLogs[i][5]], consolasFont);
                        Render.String(textX, currentTextPos, 1, toSay, [textColdead[0], textColdead[1], textColdead[2], hurtLogs[i][5]], consolasFont);
                    }
            }
        }
    }


    function hitgroupToHitbox(hitgroup) {
        hitbox = "generic";
     
        switch (hitgroup) {
            case 0:
            hitbox =  "head";
            break;
            case 1:
            hitbox =  "neck";
            break;
            case 2:
            hitbox =  "pelvis";
            break;
            case 3:
            hitbox =  "body";
            break;
            case 4:
            hitbox =  "chest";
            break;
            case 5:
            hitbox =  "chest";
            break;
            case 6:
            hitbox =  "upper chest";
            break;
            case 7:
            hitbox =  "left thigh";
            break;
            case 8:
            hitbox =  "right thigh";
            break;
            case 9:
            hitbox =  "left calf";
            break;
            case 10:
            hitbox =  "right calf";
            break;
            case 11:
            hitbox =  "left foot";
            break;
            case 12:
            hitbox =  "right foot";
            break;
            case 13:
            hitbox =  "left hand";
            break;
            case 14:
            hitbox =  "right hand";
            break;
            case 15:
            hitbox =  "left arm";
            break;
            case 16:
            hitbox =  "left forearm";
            break;
            case 17:
            hitbox =  "right arm";
            break;
            case 18:
            hitbox =  "right forearm";
        }
        return hitbox;
    }

    Cheat.RegisterCallback("player_hurt", "pHurt")
    Cheat.RegisterCallback("Draw", "drawLogs")
    Cheat.RegisterCallback("Draw", "showOrHide")