Hello,
I post a lot recently but I really want to get my plugin working
I am using OnEntityTakeDamage and I want to check if the user is using a salvaged.sword when hitting a wall, I have tried multiple different combinations and I either get Null Reference errors or method takes 0 arguments.Code:private void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo) { if (entity is BuildingBlock) { var block = entity as BuildingBlock; if (block == null) return; if (block.grade == BuildingGrade.Enum.Wood) hitInfo.damageTypes.Scale(Rust.DamageType.Slash, 4); if (block.grade == BuildingGrade.Enum.Stone) hitInfo.damageTypes.Scale(Rust.DamageType.Slash, 80); } if (entity is Door) hitInfo.damageTypes.Scale(Rust.DamageType.Slash, 5); else return; }
I altered the below code that Kayzor posted... but I couldn't get it to work.
I wanted to use checkItem to check if the active item is salvaged.sword and thenCode:bool checkItem(BasePlayer player, string command, string[] args) { Item item = player.GetActiveItem(); if (item != null) { var weapon = item.GetHeldEntity() as BaseProjectile; if (weapon != null && weapon.Equals("salvaged.sword")) { return true; } } else { return false; } }
Code:if (block.grade == BuildingGrade.Enum.Wood && checkItem()) hitInfo.damageTypes.Scale(Rust.DamageType.Slash, 4);
Checking item in hand
Discussion in 'Rust Development' started by Nathan 3, Dec 13, 2016.