I was wondering if there was a way so players can not take damage from other players. I'm creating a building server and trying to make sure no-one is killed on sight.
Regards,
JP.
Making players take no damage?
Discussion in 'Reign of Kings Discussion' started by JPascale, Feb 3, 2017.
-
Add the method code to a new plugin or to the main class of a existing plugin.
Than can only a player or admin with permission myserver.admin do damage to other players.
Code:private void OnEntityHealthChange(EntityDamageEvent e) { if (e == null) return; if (e.Damage == null) return; if (e.Damage.DamageSource == null) return; if (e.Damage.Damager == null) return; if (e.Entity == null) return; if (e.Entity == e.Damage.DamageSource) return; string damageSource = e.Damage.Damager.name.ToString(); if (e.Damage.DamageSource.IsPlayer && e.Entity.IsPlayer) { if(!e.Damage.DamageSource.Owner.HasPermission("myserver.admin")) { e.Damage.Amount = 0f; e.Damage.ImpactDamage = 0f; e.Damage.MiscDamage = 0f; } } }