On_PlayerHurt

Mar 1, 2015
On_PlayerHurt
  • Method:
    On_PlayerHurt

    Argument(s):
    HurtEvent he

    Examples:
    Python:
    Code (Python):
    def On_PlayerHurt(self, HurtEvent):
        attacker = HurtEvent.Attacker.Name
        victim = HurtEvent.Victim.Name
        amount = HurtEvent.DamageAmount
        Server.BroadcastFrom("DEATHMSG", attacker + " dealt " + str(amount) + "damage to " + victim)
     

    Javascript:
    Code (Javascript):
    function On_PlayerHurt(HurtEvent) {
        var attacker = HurtEvent.Attacker.Name;
        var victim = HurtEvent.Victim.Name;
        var amount = HurtEvent.DamageAmount;
        Server.BroadcastFrom("DEATHMSG", attacker + " dealt " + amount + "damage to " + victim);
    }
    C#:
    Code (C#):
    public override void Initialize()
    {
         Hooks.OnPlayerHurt += PlayerHurt;
    }

    public override void DeInitialize()
    {
         Hooks.OnPlayerHurt -= PlayerHurt;
    }
    Code (C#):
    public void PlayerHurt(HurtEvent he)
    {
         // Checking if the Attacker is a Player
         if (he.Attacker is Fougerite.Player)
         {
              Player attacker = (Player) he.Attacker;
              Player victim = (Player) he.Victim;

              string attackerName = attacker.Name;
              string victimName = victim.Name;

              float damageAmount = he.DamageAmount;

              Server.GetServer().Broadcast(attackerName + " dealt " + damageAmount + " damage to " + victimName);
         }
    }