Exemplo n.º 1
0
        private static void Release(PrisonManager manager, PrisonHelper prioner)
        {
            manager.Release(prioner.PrisonID);

            var player = TShock.Players.FirstOrDefault(p => p != null && p.UserAccountName == prioner.User && p.RealPlayer);

            UpdateGroup(player, prioner.User, prioner.Group);

            if (player != null)
            {
                var ePlayer = ExtendedAdmin.Players[player.Index];

                ePlayer.PrisonRecord = null;

                player.Teleport(Main.spawnTileX, Main.spawnTileY);
                player.SendMessage("You have been freed from prison", Color.Green);
                TShock.Utils.Broadcast(string.Format("{0} has been released from prison!", player.Name), Color.Goldenrod);
            }
        }
Exemplo n.º 2
0
        public static void SendToPrison(CommandArgs args)
        {
            if (args.Parameters.Count < 2 || args.Parameters.Count > 2)
            {
                args.Player.SendMessage("Invalid syntax! Proper syntax: /sendtoprison <player> <minutes>", Color.Red);
                return;
            }

            var player = TShock.Utils.FindPlayer(args.Parameters[0]);

            if (player == null || player.Count == 0)
            {
                args.Player.SendMessage("No player matched your query.", Color.Red);
                return;
            }

            if (player.Count > 1)
            {
                args.Player.SendMessage("More than one player matched your query.", Color.Red);
                return;
            }

            int minutes = args.Parameters[1].ToIntegerOrDefault(-1);

            if (minutes < 1)
            {
                args.Player.SendMessage("Invalid number of minutes.", Color.Red);
                return;
            }

            ExtendedTSPlayer ePlayer = ExtendedAdmin.Players[player[0].Index];

            PrisonManager manager = new PrisonManager(TShock.DB);

            manager.AddPrisonRecord(player[0], DateTime.Now.AddMinutes(minutes));

            ServerPointSystem.ServerPointSystem.Deduct(new CommandArgs("deduct", player[0], new List<string>()
            {
                player[0].Name,
                ExtendedAdmin.Config.PrisonShards.ToString()
            }));

            UpdateGroup(player[0], player[0].UserAccountName, ExtendedAdmin.Config.PrisonGroup);

            ePlayer.PrisonRecord = manager.GetPrisonerUser(player[0].UserAccountName);

            var warp = TShock.Warps.FindWarp(ExtendedAdmin.Config.PrisonWarp);
            if (warp.WarpPos != Vector2.Zero)
            {
                player[0].Teleport((int)warp.WarpPos.X, (int)warp.WarpPos.Y + 3);
            }
            else
            {
                player[0].Spawn();
            }

            args.Player.SendMessage("Player sent to prison.", Color.Green);
            player[0].SendMessage(string.Format("You have been sent to prison for {0} minute(s)", minutes), Color.Red);
            TShock.Utils.Broadcast(string.Format("{0} has been sent to prison!", player[0].Name), Color.Goldenrod);
        }
Exemplo n.º 3
0
        public static void ReleaseFromPrison(CommandArgs args)
        {
            if (args.Parameters.Count < 1 || args.Parameters.Count > 1)
            {
                args.Player.SendMessage("Invalid syntax! Proper syntax: /releaseprisoner <user>", Color.Red);
                return;
            }

            PrisonManager manager = new PrisonManager(TShock.DB);

            PrisonHelper prisoner = manager.GetPrisonerUser(args.Parameters[0]);

            if (prisoner != null)
            {
                Release(manager, prisoner);

                if (args.Player != null)
                {
                    args.Player.SendMessage("Prisoner has been released.", Color.Green);
                }
            }
            else
            {
                if (args.Player != null)
                {
                    args.Player.SendMessage("No prisoner matched your query", Color.Red);
                }
            }
        }
Exemplo n.º 4
0
        public static void ExtendSentence(CommandArgs args)
        {
            if (args.Parameters.Count < 2 || args.Parameters.Count > 2)
            {
                args.Player.SendMessage("Invalid syntax! Proper syntax: /extendsentence <player> <minutes>", Color.Red);
                return;
            }

            var player = TShock.Utils.FindPlayer(args.Parameters[0]);

            if (player.Count == 0)
            {
                args.Player.SendMessage("No player found with that query.", Color.Red);
                return;
            }

            if (player.Count > 1)
            {
                args.Player.SendMessage("More than one player matched query.", Color.Red);
                return;
            }

            if (args.Parameters[1].ToIntegerOrDefault(-1) < 1)
            {
                args.Player.SendMessage("Invalid number of minutes.", Color.Red);
                return;
            }

            PrisonManager manager = new PrisonManager(TShock.DB);

            if (manager.IPInPrison(player[0].IP))
            {
                manager.ExtendSentence(player[0], args.Parameters[1].ToIntegerOrDefault(-1));

                var ePlayer = ExtendedAdmin.Players[player[0].Index];

                ePlayer.PrisonRecord.Until = ePlayer.PrisonRecord.Until.AddMinutes(args.Parameters[1].ToIntegerOrDefault(-1));

                ePlayer.Player.SendMessage(string.Format("Your sentence has been extended by {0} minute(s)", args.Parameters[1].ToIntegerOrDefault(-1)), Color.Red);

                TShock.Utils.Broadcast(string.Format("{0}'s sentence has been extended!", ePlayer.Player.Name), Color.Goldenrod);
            }
            else
            {
                args.Player.SendMessage("Player is not currently in prison.", Color.Red);
                return;
            }
        }
Exemplo n.º 5
0
        public static void ClearPrison(CommandArgs args)
        {
            PrisonManager manager = new PrisonManager(TShock.DB);

            foreach (PrisonHelper prioner in manager.GetAllCurrentPrisoners())
            {
                Release(manager, prioner);
            }
        }
Exemplo n.º 6
0
        private void ServerHooks_Join(int ply, HandledEventArgs args)
        {
            var tPlayer = TShock.Players[ply];
            var player = new ExtendedTSPlayer(tPlayer);

            Players[ply] = player;

            PrisonManager prisonManager = new PrisonManager(TShock.DB);

            if (prisonManager.IPInPrison(player.Player.IP))
            {
                player.PrisonRecord = prisonManager.GetPrisonRecordByIP(player.Player.IP);
            }
        }