Hi! I am trying to nullify or modify the damage that players take. Trying to do something like this;
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.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); } } }
Thanks!
Solved Nullify players damage C#
Discussion in 'Rust Development' started by Reynostrum, May 21, 2016.
-
Wulf Community Admin
All you should need is hitInfo.damageAmount, just set it to what you want.
-
Hi Wulf. But how should I do that?
hitInfo.damageAmount(0.25) or something like that? -
Wulf Community Admin
-
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?
-
Wulf Community Admin
-
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
-
Wulf Community Admin
-
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?
[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); } }