1. Hi! I am trying to nullify or modify the damage that players take. Trying to do something like this;

    Code:
    void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitinfo)
            {
                if (entity as BasePlayer == null || hitInfo == null) return;
                    if (hitinfo.hasDamage)
                    {
                        if (hitinfo.damageTypes?.Get(Rust.DamageType.All) > 0.0f)
                        {
                            hitinfo.damageTypes.Set(Rust.DamageType.All, 0.25);
                        }
                    }
            }
    I tried to look into some plugins that modify the damage but the only thing that I made is modify some damage types, but I am trying to modify all the damages types.

    Thanks!
     
  2. Wulf

    Wulf Community Admin

    All you should need is hitInfo.damageAmount, just set it to what you want.
     
  3. Hi Wulf. But how should I do that?

    hitInfo.damageAmount(0.25) or something like that?
     
  4. Wulf

    Wulf Community Admin

    If that's the amount you want to set it to, I believe so.
     
  5. Code:
    Type `HitInfo' does not contain a definition for `damageAmount' and no extension method `damageAmount' of type `HitInfo' could be found. Are you missing an assembly reference?
     
  6. Wulf

    Wulf Community Admin

    The casing matters, you have hitinfo; hitInfo was what I had as an example.
     
  7. Code:
    void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitinfo)
            {
                BasePlayer player = entity.ToPlayer();            if (entity as BasePlayer == null || hitInfo == null) return;
                if (HasPermission(player, "zzz"))
                {
                    if (hitinfo.hasDamage)
                    {
                            hitInfo.damageAmount(0.0);
                    }
                }
            }
    Code:
    error CS0103: The name `hitInfo' does not exist in the current context
     
  8. Wulf

    Wulf Community Admin

    Like I said, hitinfo is what you use, so you'd need to use hitinfo, not hitInfo.
     
  9. Sorry, I am a little confused.
    I did this.
    Code:
    void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo)
            {
                BasePlayer player = entity.ToPlayer();            if (entity as BasePlayer == null || hitInfo == null) return;
                if (HasPermission(player, "zzz"))
                {
                    if (hitInfo.hasDamage)
                    {
                            hitInfo.damageAmount(0.0);
                    }
                }
            }
    Code:
    error CS1061: Type `HitInfo' does not contain a definition for `damageAmount' and no extension method `damageAmount' of type `HitInfo' could be found. Are you missing an assembly reference?
    I don't know what I'm doing wrong.
    [DOUBLEPOST=1463799775][/DOUBLEPOST]Solved

    Code:
    void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo)
            {
                BasePlayer player = entity.ToPlayer();            if (entity as BasePlayer == null || hitInfo == null) return;
                    if (hitInfo.hasDamage)
                    {
                        hitInfo.damageTypes.ScaleAll(1.0f);
                    }
            }