/// <summary> /// Sends <see cref="Player"/> to jail, with time overload. <returns> Returns bool of operation success </returns> /// </summary> /// <param name="player">the <see cref="Player"/> to send into jail</param> /// <param name="jailedToTime">the time to jail the player. Null sets the time to remaining time, or if thats null, one year</param> public static bool SendToJail(Smod2.API.Player player, DateTime?jailedToTime) { if (player == null || player.PlayerRole.RoleID == Smod2.API.RoleType.SPECTATOR || player.OverwatchMode) { return(false); } Debug($"Attempting to jail {player.Name}"); if (AdminToolbox.ATPlayerDict.TryGetValue(player.UserID, out PlayerSettings psetting)) { if (!jailedToTime.HasValue || jailedToTime < DateTime.UtcNow) { Debug($"Jail time for \"{player.Name}\" not specified, jailing for a year."); } psetting.JailedToTime = jailedToTime ?? ((psetting.JailedToTime > DateTime.UtcNow) ? psetting.JailedToTime : DateTime.UtcNow.AddYears(1)); //Saves original variables psetting.originalPos = player.GetPosition(); if (!psetting.isJailed) { psetting.previousRole = player.PlayerRole.RoleID; psetting.playerPrevInv = player.GetInventory(); psetting.previousHealth = player.Health; foreach (AmmoType a in typeof(AmmoType).GetEnumValues()) { if (a != AmmoType.NONE) { psetting.Ammo[a] = player.GetAmmo(a); } } } //Changes role to Tutorial, teleports to jail, removes inv. Debug($"Variables stored, sending \"{player.Name}\" to jail"); player.ChangeRole(Smod2.API.RoleType.TUTORIAL, true, false); player.Teleport(JailPos, true); player.ClearInventory(); psetting.isJailed = true; return(true); } else { Debug($"Could not send player to jail! Player \"{player.Name}\" not in AT-PlayerDict!"); return(false); } }
IEnumerator <float> setAmmo(Smod2.API.Player Player) { plugin.Debug("=:BEFORE:= Player: " + Player.Name); plugin.Debug(" Ammo(Epsilon-11): " + Player.GetAmmo((AmmoType)0)); plugin.Debug(" Ammo(MP7, Logicer): " + Player.GetAmmo((AmmoType)1)); plugin.Debug(" Ammo(COM15, P90): " + Player.GetAmmo((AmmoType)2)); yield return(Timing.WaitForOneFrame); foreach (int ind in System.Enum.GetValues(typeof(AmmoType))) { int ammo = configs[(Role)Player.TeamRole.Role + "__AMMO_" + ind]; if (ammo >= 0) { Player.SetAmmo((AmmoType)ind, ammo); } } plugin.Debug("=:AFTER:= Player: " + Player.Name); plugin.Debug(" Ammo(Epsilon-11): " + Player.GetAmmo((AmmoType)0)); plugin.Debug(" Ammo(MP7, Logicer): " + Player.GetAmmo((AmmoType)1)); plugin.Debug(" Ammo(COM15, P90): " + Player.GetAmmo((AmmoType)2)); }