

Login Protection
Prevent players from taking damage until they move after logging in
Description
<h3>Tired of dying when logging into a server?</h3> <p>Login Protection prevents the player from taking damage when they join a server because the server thinks the player is ready even though their client is still loading.</p> <p>Once the player moves or does anything, they are considered "active" and no longer protected. Players standing in lava or on fire will also not be protected.</p> <p>There is also a single config option <code>ProtectionTimeSeconds</code>. If this is set to a number then the player's protection will expire that many seconds after logging in (this may be before the player can actually see anything. Make sure you set the number high enough).</p> <p> </p> <p>Exposes a single serverside method to check if a player is protected or not, as well as 3 events:</p> <pre class="language-csharp"><code>var loginProtection = Api.ModLoader.GetModSystem<LoginProtectionModSystem>(); loginProtection.OnLoginProtectionStart += player => doSomething(player); loginProtection.OnLoginProtectionStop += player => doSomething(player); loginProtection.OnShouldProtect += player => shouldProtect(player); if (wouldDoSomething && loginProtection.IsPlayerProtected(player)) Dont();</code></pre> <div class="spoiler"> <div class="spoiler-toggle">Full code example using reflection:</div> <div class="spoiler-text"> <pre class="language-csharp"><code>internal class YourModSystem : ModSystem { private System.Func<IPlayer, bool> isPlayerProtected;
public void InjurePlayer (IPlayer player) { if (_api.IsServerSide()) { if (isPlayerProtected == null) { var loginProtection = _api.ModLoader.GetModSystem("LoginProtection.LoginProtectionModSystem"); if (loginProtection != null) { var isPlayerProtectedMethod = loginProtection.GetType().GetMethod("IsPlayerProtected"); isPlayerProtected = isPlayerProtectedMethod.CreateDelegate(typeof(System.Func<IPlayer, bool>), loginProtection) as System.Func<IPlayer, bool>; } else { isPlayerProtected = (IPlayer p) => false; } } if (!isPlayerProtected(player))) { ExplodePlayer(player); } } } }</code></pre></div></div>
Ratings & reviews
Sign in to leave a rating or comment.

