private static ulong GetSteamId(BoltEntity playerEntity) { if (playerEntity == null) { return(0UL); } return(CoopKick.GetSteamId(playerEntity.source)); }
public static void KickPlayer(BoltConnection connection, BoltEntity playerEntity, int duration, string message = "HOST_KICKED_YOU") { if (!BoltNetwork.isServer) { return; } if (connection == null && playerEntity == null) { return; } if (connection == null) { connection = playerEntity.source; } try { ulong steamId = CoopKick.GetSteamId(connection); if (steamId == 0UL) { steamId = CoopKick.GetSteamId(playerEntity); } string name = (!(playerEntity == null)) ? playerEntity.GetState <IPlayerState>().name : steamId.ToString(); if (duration >= 0 && steamId > 0UL && !CoopKick.IsBanned(steamId)) { CoopKick.Instance.kickedSteamIds.Add(new CoopKick.KickedPlayer { Name = name, SteamId = steamId, BanEndTime = ((duration <= 0) ? 0L : (DateTime.UtcNow.ToUnixTimestamp() + (long)duration)) }); CoopKick.SaveList(); } } catch (Exception exception) { Debug.LogException(exception); } connection.Disconnect(new CoopKickToken { KickMessage = message, Banned = (duration == 0) }); }