Exemple #1
0
        public static void UpdateStatus(bool info, int _userid)
        {
            List <SqlValue> values = new List <SqlValue>();

            List <SqlValue> where = new List <SqlValue>();
            where.Add(new SqlValue("userid", _userid));
            values.Add(new SqlValue("logout", Convert.ToInt32(info)));
            SQLEditor.UpdateValues("CDPlugin", values, where);
        }
 private static void ChRank(CommandArgs args)
 {
     if (args.Parameters.Count > 1)
     {
         TSPlayer player;
         if (TShockAPI.TShock.Utils.FindPlayer(args.Parameters[0]).Count == 1)
         {
             player = TShockAPI.TShock.Utils.FindPlayer(args.Parameters[0])[0];
             if (TShock.Groups.GroupExists(args.Parameters[1]))
             {
                 Group Group = TShockAPI.TShock.Utils.GetGroup(args.Parameters[1]);
                 if (IsRank(Group.Name) && !Group.HasPermission("dontchangemyrank"))
                 {
                     List <SqlValue> list = new List <SqlValue>();
                     List <SqlValue> where = new List <SqlValue>();
                     where.Add(new SqlValue("Username", "'" + player.UserAccountName + "'"));
                     list.Add(new SqlValue("Usergroup", "'" + Group.Name + "'"));
                     SQLEditor.UpdateValues("Users", list, where);
                     args.Player.SendMessage("You changed " + player.Name + "'s rank from " + player.Group.Name + " to " + Group.Name, Color.Green);
                     player.SendMessage(args.Player.Name + "has changed your rank to " + Group.Name + "!", Color.Green);
                     player.Group = Group;
                 }
                 else
                 {
                     args.Player.SendMessage("You cannot change that players rank!", Color.Red);
                 }
             }
         }
         else if (TShockAPI.TShock.Utils.FindPlayer(args.Parameters[0]).Count > 1)
         {
             args.Player.SendMessage("More than 1 player matched!", Color.Red);
         }
         else if (TShockAPI.TShock.Utils.FindPlayer(args.Parameters[0]).Count == 0)
         {
             args.Player.SendMessage("A player by that name does not exist!", Color.Red);
         }
     }
 }
Exemple #3
0
        public static void ChatColor(CommandArgs args)
        {
            if (args.Parameters.Count >= 3)
            {
                string[] text;
                text = new string[100];
                int i = 0;

                foreach (string word in args.Parameters)
                {
                    text[i] = word;
                    i      += 1;
                }
                byte text1, text2, text3;

                try { text1 = Convert.ToByte(text[0]); }
                catch (System.FormatException) { args.Player.SendMessage("The Red value was not a proper integer.", Color.Red); return; }
                catch (System.OverflowException) { args.Player.SendMessage("The Red value was not an integer between 0 and 255.", Color.Red); return; }
                try { text2 = Convert.ToByte(text[1]); }
                catch (System.FormatException) { args.Player.SendMessage("The Green value was not a proper integer.", Color.Red); return; }
                catch (System.OverflowException) { args.Player.SendMessage("The Green value was not an integer between 0 and 255.", Color.Red); return; }
                try { text3 = Convert.ToByte(text[2]); }
                catch (System.FormatException) { args.Player.SendMessage("The Blue value was not a proper integer.", Color.Red); return; }
                catch (System.OverflowException) { args.Player.SendMessage("The Blue value was not an integer between 0 and 255.", Color.Red); return; }
                if (args.Player.IsLoggedIn)
                {
                    if (SearchTable(SQLEditor.ReadColumn("ChatColor", "Name", new List <SqlValue>()), args.Player.UserAccountName) != -1)
                    {
                        int temp = SearchTable(SQLEditor.ReadColumn("ChatColor", "Name", new List <SqlValue>()), args.Player.UserAccountName);
                        if ((temp != -1) && (!Convert.ToBoolean(SQLEditor.ReadColumn("ChatColor", "CanChange", new List <SqlValue>())[temp])))
                        {
                            args.Player.SendMessage("You've been blocked from using Chat Colors by an Admin.", Color.Red); return;
                        }
                        List <SqlValue> values = new List <SqlValue>();
                        values.Add(new SqlValue("R", text1));
                        values.Add(new SqlValue("G", text2));
                        values.Add(new SqlValue("B", text3));
                        List <SqlValue> where = new List <SqlValue>();
                        where.Add(new SqlValue("Name", "'" + args.Player.UserAccountName + "'"));
                        SQLEditor.UpdateValues("ChatColor", values, where);
                    }
                    else
                    {
                        List <SqlValue> list = new List <SqlValue>();
                        list.Add(new SqlValue("Name", "'" + args.Player.UserAccountName + "'"));
                        list.Add(new SqlValue("CanChange", 1));
                        list.Add(new SqlValue("R", text1));
                        list.Add(new SqlValue("G", text2));
                        list.Add(new SqlValue("B", text3));
                        SQLEditor.InsertValues("ChatColor", list);
                    }
                }
                else
                {
                    args.Player.SendMessage("You need to be logged in to use this command.", Color.Red); return;
                }
                args.Player.SendMessage("This is your new text color!  You like? :)", text1, text2, text3); return;
            }
            else
            {
                args.Player.SendMessage("Not enough arguments. Format is /chatcolor Red Green Blue", Color.Red);
                return;
            }
        }
Exemple #4
0
        private static void SetCost(CommandArgs args)
        {
            if (args.Parameters.Count > 1)
            {
                string cmd = args.Parameters[0].ToLower();
                switch (cmd)
                {
                case "buff":
                {
                    Int32.TryParse(args.Parameters[1], out buffcost);
                    List <SqlValue> where = new List <SqlValue>();
                    List <SqlValue> list = new List <SqlValue>();
                    list.Add(new SqlValue("Cost", buffcost));
                    where.Add(new SqlValue("Command", "'" + "buff" + "'"));
                    SQLEditor.UpdateValues("CommandCosts", list, where);
                    TShockAPI.TShock.Utils.Broadcast("Using \"/buff\" now costs " + warpcost.ToString() + " " + ServerPointSystem.ServerPointSystem.currname + "s", Color.Yellow);
                    break;
                }

                case "warp":
                {
                    Int32.TryParse(args.Parameters[1], out warpcost);
                    List <SqlValue> where = new List <SqlValue>();
                    List <SqlValue> list = new List <SqlValue>();
                    list.Add(new SqlValue("Cost", warpcost));
                    where.Add(new SqlValue("Command", "'" + "warp" + "'"));
                    SQLEditor.UpdateValues("CommandCosts", list, where);
                    TShockAPI.TShock.Utils.Broadcast("Warping to un-priced warp points now costs " + warpcost.ToString() + " " + ServerPointSystem.ServerPointSystem.currname + "s", Color.Yellow);
                    break;
                }

                case "heal":
                {
                    Int32.TryParse(args.Parameters[1], out healcost);
                    List <SqlValue> where = new List <SqlValue>();
                    List <SqlValue> list = new List <SqlValue>();
                    list.Add(new SqlValue("Cost", healcost));
                    where.Add(new SqlValue("Command", "'" + "heal" + "'"));
                    SQLEditor.UpdateValues("CommandCosts", list, where);
                    TShockAPI.TShock.Utils.Broadcast("Using \"/heal\" now costs " + warpcost.ToString() + " " + ServerPointSystem.ServerPointSystem.currname + "s", Color.Yellow);
                    break;
                }

                case "tp":
                {
                    Int32.TryParse(args.Parameters[1], out tpcost);
                    List <SqlValue> where = new List <SqlValue>();
                    List <SqlValue> list = new List <SqlValue>();
                    list.Add(new SqlValue("Cost", tpcost));
                    where.Add(new SqlValue("Command", "'" + "tp" + "'"));
                    SQLEditor.UpdateValues("CommandCosts", list, where);
                    TShockAPI.TShock.Utils.Broadcast("Using \"/tp\" now costs " + warpcost.ToString() + " " + ServerPointSystem.ServerPointSystem.currname + "s", Color.Yellow);
                    break;
                }
                }
            }
            else
            {
                args.Player.SendMessage("/setcost [buff|heal|warp|tp] [amount]", Color.Yellow);
            }
        }