private static IEnumerator BanPlayerCoroutine(SteamPlayer executor, string target) { var ip = 0u; if (PlayerTool.tryGetSteamPlayer(target, out var steamPlayer)) { ip = steamPlayer.getIPv4AddressOrZero(); } PlayerTool.tryGetSteamID(target, out var cSteamID); var steamId = steamPlayer?.playerID.steamID ?? cSteamID; if (!steamId.IsValid()) { if (executor != null) { ChatManager.SendServerMessage("Target not found", executor, EChatMode.SAY); } else { CommandWindow.LogError("Target not found"); } yield break; } Provider.requestBanPlayer(Provider.server, steamId, ip, "Banned", SteamBlacklist.PERMANENT); var banData = new SocketData("BanPlayer", steamId.ToString()); SocketManager.Emit(banData); ChatManager.SendServerMessage("Banned target successfully", executor, EChatMode.SAY); yield return(null); }
private static IEnumerator UnbanPlayerCoroutine(SteamPlayer executor, string target) { PlayerTool.tryGetSteamPlayer(target, out var steamPlayer); PlayerTool.tryGetSteamID(target, out var cSteamID); var steamId = steamPlayer?.playerID.steamID ?? cSteamID; if (!steamId.IsValid()) { if (executor != null) { ChatManager.SendServerMessage("Target not found", executor, EChatMode.SAY); } else { CommandWindow.LogError("Target not found"); } yield break; } Provider.requestUnbanPlayer(Provider.server, steamId); var unbanData = new SocketData("UnbanPlayer", steamId.ToString()); SocketManager.Emit(unbanData); ChatManager.SendServerMessage("Unbanned target successfully", executor, EChatMode.SAY); yield return(null); }
public override void Execute(PointBlankPlayer executor, string[] args) { if (!PlayerTool.tryGetSteamID(args[0], out CSteamID id)) { UnturnedChat.SendMessage(executor, Translations["Base_InvalidPlayer"], ConsoleColor.Red); return; } SteamWhitelist.whitelist(id, args[1], ((UnturnedPlayer)executor)?.SteamID ?? CSteamID.Nil); UnturnedChat.SendMessage(executor, string.Format(Translations["Permit_Added"], id), ConsoleColor.Green); }
public override void Execute(PointBlankPlayer executor, string[] args) { if (!PlayerTool.tryGetSteamID(args[0], out CSteamID id)) { UnturnedChat.SendMessage(executor, Translations["Base_InvalidPlayer"], ConsoleColor.Red); return; } SteamAdminlist.ownerID = id; UnturnedChat.SendMessage(executor, string.Format(Translations["Owner_Set"], id), ConsoleColor.Green); }
public override void Execute(PointBlankPlayer executor, string[] args) { if (!PlayerTool.tryGetSteamID(args[0], out CSteamID id)) { UnturnedChat.SendMessage(executor, Translations["Base_InvalidPlayer"], ConsoleColor.Red); return; } if (!SteamBlacklist.unban(id)) { UnturnedChat.SendMessage(executor, string.Format(Translations["Unban_NotBanned"], id), ConsoleColor.Red); return; } UnturnedChat.SendMessage(executor, string.Format(Translations["Unban_Unban"], id), ConsoleColor.Green); }
public override void Execute(PointBlankPlayer executor, string[] args) { if (!PlayerTool.tryGetSteamID(args[0], out CSteamID player)) { UnturnedChat.SendMessage(executor, Translations["Base_InvalidPlayer"], ConsoleColor.Red); return; } if (executor == null) { SteamAdminlist.admin(player, CSteamID.Nil); CommandWindow.Log(string.Format(Translations["Admin_Set"], player), ConsoleColor.Green); } else { SteamAdminlist.admin(player, (PointBlankPlayer.IsServer(executor) ? CSteamID.Nil : ((UnturnedPlayer)executor).SteamID)); executor.SendMessage(string.Format(Translations["Admin_Set"], player), Color.green); } }
public override void Execute(PointBlankPlayer executor, string[] args) { uint ip; if (!PlayerTool.tryGetSteamID(args[0], out CSteamID player) || (executor != null && ((UnturnedPlayer)executor).SteamID == player)) { UnturnedChat.SendMessage(executor, Translations["Base_InvalidPlayer"], ConsoleColor.Red); return; } ip = SteamGameServerNetworking.GetP2PSessionState(player, out P2PSessionState_t p2PSessionState_t) ? p2PSessionState_t.m_nRemoteIP : 0u; if (args.Length < 2 || uint.TryParse(args[1], out uint duration)) { duration = SteamBlacklist.PERMANENT; } string reason = args.Length < 3 ? Translations["Ban_Reason"] : args[2]; SteamBlacklist.ban(player, ip, ((UnturnedPlayer)executor)?.SteamID ?? CSteamID.Nil, reason, duration); UnturnedChat.SendMessage(executor, string.Format(Translations["Ban_Success"], player), ConsoleColor.Green); }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer robber = caller as UnturnedPlayer; // Check Syntax if (command.Length > 1 || command.Length == 0) { UnturnedChat.Say(caller, $"Correct Usage: {Syntax}"); return; } // Check if player has a cooldown on the command if (Main.Instance.cooldowns.TryGetValue(robber.CSteamID, out DateTime expireDate)) { if (DateTime.Now < expireDate) { UnturnedChat.Say(caller, Main.Instance.Translate("Cooldown")); return; } else { Main.Instance.cooldowns.Remove(robber.CSteamID); } } // Check if player he's trying to rob is not in his group and is near him and is on the server if (!PlayerTool.tryGetSteamID(command[0], out CSteamID steamID)) { UnturnedChat.Say(caller, Main.Instance.Translate("PlayerNotFound")); return; } Player victim = PlayerTool.getPlayer(steamID); List <Player> nearbyPlayers = new List <Player>(); PlayerTool.getPlayersInRadius(robber.Position, Main.Instance.Configuration.Instance.Radius, nearbyPlayers); if (nearbyPlayers.Count == 0 || !nearbyPlayers.Contains(victim)) { UnturnedChat.Say(caller, Main.Instance.Translate("VictimNotNearby", victim.name)); return; } if (robber.Player.quests.groupID.ToString() != "0") { if (victim.quests.groupID == robber.Player.quests.groupID) { UnturnedChat.Say(caller, Main.Instance.Translate("VictimInGroup", victim.name)); return; } } // Check if victim has his hands up if (Main.Instance.Configuration.Instance.ShouldVictimBeSurrendered) { if (victim.animator.gesture != EPlayerGesture.SURRENDER_START) { UnturnedChat.Say(caller, Main.Instance.Translate("PlayerNotSurrender", victim.name)); return; } } // Get all of the group members involved in the robbery and all the witnesses List <Player> groupMembersNearby = new List <Player>(); List <Player> witnessesNearby = new List <Player>(); foreach (Player nearbyPlayer in nearbyPlayers) { if (nearbyPlayer == victim) { continue; } if (nearbyPlayer == robber.Player) { continue; } if (nearbyPlayer.quests.groupID == robber.Player.quests.groupID) { groupMembersNearby.Add(nearbyPlayer); } else { witnessesNearby.Add(nearbyPlayer); } } // Calculate the chance int chance = Main.Instance.Configuration.Instance.BaseChance; // First remove the witnesses chance and make sure minimum chance is there for (int b = 0; b < witnessesNearby.Count; b++) { int updatedChance = chance - Main.Instance.Configuration.Instance.WitnessDecreaseChance; if (updatedChance < Main.Instance.Configuration.Instance.MinimumChance) { break; } chance = updatedChance; } // Then add the group members chance and make sure maximum chance is there for (int b = 0; b < groupMembersNearby.Count; b++) { int updatedChance = chance + Main.Instance.Configuration.Instance.GroupMemberIncreaseChance; if (updatedChance > Main.Instance.Configuration.Instance.MaximumChance) { break; } chance = updatedChance; } UnturnedChat.Say(caller, chance.ToString()); // Check if rob is successfull or not if (chance >= UnityEngine.Random.Range(1, 101)) { if (Main.Instance.Configuration.Instance.AutoDropItem) { Logger.Log("DropItems called"); Main.Instance.DropItems(victim, robber); } UnturnedChat.Say(caller, Main.Instance.Translate("RobberySuccessfull")); Main.Instance.cooldowns.Add(robber.CSteamID, DateTime.Now.AddSeconds(Main.Instance.Configuration.Instance.CommandCooldown)); if (Main.Instance.Configuration.Instance.GroupMembersGetCooldown) { if (groupMembersNearby.Count == 0) { return; } foreach (Player groupMember in groupMembersNearby) { if (Main.Instance.cooldowns.ContainsKey(groupMember.channel.owner.playerID.steamID)) { continue; } Main.Instance.cooldowns.Add(groupMember.channel.owner.playerID.steamID, DateTime.Now.AddSeconds(Main.Instance.Configuration.Instance.CommandCooldown)); } } } else { UnturnedChat.Say(caller, Main.Instance.Translate("RobberyFailed")); Main.Instance.cooldowns.Add(robber.CSteamID, DateTime.Now.AddSeconds(Main.Instance.Configuration.Instance.CommandCooldown)); if (Main.Instance.Configuration.Instance.GroupMembersGetCooldown) { if (groupMembersNearby.Count == 0) { return; } foreach (Player groupMember in groupMembersNearby) { if (Main.Instance.cooldowns.ContainsKey(groupMember.channel.owner.playerID.steamID)) { continue; } Main.Instance.cooldowns.Add(groupMember.channel.owner.playerID.steamID, DateTime.Now.AddSeconds(Main.Instance.Configuration.Instance.CommandCooldown)); } } } }