public string[] OnCall(ICommandSender sender, string[] args) { if (args.Length > 0) { PluginOptions pluginOptions = eventLogic._343Config; Regex regex = new Regex(@"\D+"); string PlayerIDString = regex.Replace(args[0], ""); foreach (Player player in PluginManager.Manager.Server.GetPlayers()) { if (Int32.TryParse(PlayerIDString, out int PlayerIDInt)) { if (player.PlayerId == PlayerIDInt) { player.ChangeRole(Smod2.API.RoleType.CLASSD, true, true, true); SCP_343Manager _343Manager = eventLogic.Get343Manager(player); _343Manager.Is343 = true; foreach (Smod2.API.Item item in player.GetInventory()) { item.Remove(); } player.GiveItem(Smod2.API.ItemType.FLASHLIGHT); if (pluginOptions.SCP343_HP != -1) { player.HP = pluginOptions.SCP343_HP; } if (player.GetUserGroup().BadgeText == null) { _343Manager.PreviousBadgeColor = ""; _343Manager.PreviousBadgeName = ""; } else { _343Manager.PreviousBadgeColor = player.GetUserGroup().Color; _343Manager.PreviousBadgeName = player.GetUserGroup().BadgeText; } if (pluginOptions.SCP343_shouldbroadcast) { player.PersonalBroadcast(5, "You're SCP-343! Check your console for more information about SCP-343.", true); player.SendConsoleMessage("----------------------------------------------------------- \n" + pluginOptions.SCP343_broadcastinfo + "\n ----------------------------------------------------------- "); } player.SetRank("red", "SCP-343"); return(new string[] { "Made " + player.Name + " SCP-343!" }); } } } return(new string[] { "Couldn't parse playerid." }); } else { return(new string[] { "You must put a playerid." }); } }
/// <summary> /// In case 343 dies this will remove him from the list. /// </summary> public void OnPlayerDie(PlayerDeathEvent ev) { if (Is343(ev.Player)) { SCP_343Manager _343Manager = Get343Manager(ev.Player); _343Manager.Is343 = false; ev.Player.SetRank(_343Manager.PreviousBadgeColor, _343Manager.PreviousBadgeColor); } }
/// <summary> /// Makes it so 343 loses his divine touch when the round ends. /// </summary> public void OnRoundEnd(RoundEndEvent ev) { foreach (Player player in Smod2.PluginManager.Manager.Server.GetPlayers()) { if (Is343(player)) { SCP_343Manager _343Manager = Get343Manager(player); _343Manager.Is343 = false; player.SetRank(_343Manager.PreviousBadgeColor, _343Manager.PreviousBadgeColor); player.HP = 100; } } }
public SCP_343Manager Add343Manager(ReferenceHub Ply) { /// If we already have the <see cref="SCP_343Manager"/> then we know they're already SCP-343. if (Ply.TryGetComponent(out SCP_343Manager _343Manager)) { return(_343Manager); } /// Don't allow the dedicated server to become SCP-343 (The server is a non-active player that doesn't do anything) if (Ply == ReferenceHub.HostHub) { return(null); } /// We add <see cref="SCP_343Manager"/> to the player and it returns it after we add it so we can set some values to match the config values. SCP_343Manager _343ManagerComp = Ply.gameObject.AddComponent <SCP_343Manager>(); return(_343ManagerComp); }
/// <summary> /// Plugin checks if its disabled and if not it updates all config values and goes through every person on the server and adds all D-Class to a list and randomly generates a number to see if 343 should spawn and randomly picks one d-class to be 343. /// </summary> public void OnRoundStart(RoundStartEvent ev) { if (plugin.GetConfigBool("343_disable")) { plugin.PluginManager.DisablePlugin(plugin); return; } _343Config.UpdateValues(plugin); int randomNumber = RNG.Next(0, 100); List <Smod2.API.Player> DClassList = new List <Smod2.API.Player>(); if (!(randomNumber <= (float)plugin.GetConfigFloat($"{plugin.Details.configPrefix}_spawnchance"))) { return; } foreach (Smod2.API.Player player in plugin.PluginManager.Server.GetPlayers()) { if (player.TeamRole.Role == Smod2.API.RoleType.CLASSD) { DClassList.Add(player); } } if (DClassList.Count > 0 && plugin.PluginManager.Server.GetPlayers().Count > 2) { Player TheChosenOne = DClassList[RNG.Next(DClassList.Count)]; Add343Manager(TheChosenOne); SCP_343Manager _343Manager = Get343Manager(TheChosenOne); _343Manager.Is343 = true; if (TheChosenOne.GetUserGroup().BadgeText == null) { _343Manager.PreviousBadgeColor = ""; _343Manager.PreviousBadgeName = ""; } else { _343Manager.PreviousBadgeColor = TheChosenOne.GetUserGroup().Color; _343Manager.PreviousBadgeName = TheChosenOne.GetUserGroup().BadgeText; } foreach (Smod2.API.Item item in TheChosenOne.GetInventory()) { item.Remove(); } TheChosenOne.GiveItem(Smod2.API.ItemType.FLASHLIGHT); if (_343Config.SCP343_shouldbroadcast) { TheChosenOne.PersonalBroadcast(5, "You're SCP-343! Check your console for more information about SCP-343.", true); TheChosenOne.SendConsoleMessage("\n----------------------------------------------------------- \n" + _343Config.SCP343_broadcastinfo + "\n ----------------------------------------------------------- "); } if (_343Config.SCP343_HP != -1) { TheChosenOne.HP = _343Config.SCP343_HP; } TheChosenOne.SetRank("red", "SCP-343"); } }