Exemplo n.º 1
0
 private static void SetWarpCost(CommandArgs args)
 {
     if (args.Parameters.Count > 1)
     {
         if (TShock.Warps.FindWarp(args.Parameters[0]).WarpPos != Vector2.Zero)
         {
             string warpname;
             warpname = args.Parameters[0];
             int cost = 100;
             Int32.TryParse(args.Parameters[1], out cost);
             List <SqlValue> list = new List <SqlValue>();
             list.Add(new SqlValue("Command", "'" + "warp " + warpname + "'"));
             if (SQLEditor.ReadColumn("CommandCosts", "Command", list).Count < 1)
             {
                 list.Add(new SqlValue("Cost", cost));
                 SQLEditor.InsertValues("CommandCosts", list);
             }
             else
             {
                 List <SqlValue> list2 = new List <SqlValue>();
                 list2.Add(new SqlValue("Cost", cost));
                 SQLEditor.UpdateValues("CommandCosts", list2, list);
             }
             args.Player.SendMessage("It now costs " + cost.ToString() + " " + ServerPointSystem.ServerPointSystem.currname + "s to warp to " + warpname, Color.Green);
         }
         else
         {
             args.Player.SendMessage("You must enter a valid warp!", Color.Yellow);
         }
     }
     else
     {
         args.Player.SendMessage("/setwarpcost [warp name] [amount]", Color.Yellow);
     }
 }
Exemplo n.º 2
0
        public static void AddPos(PlayerPos info)
        {
            List <SqlValue> list = new List <SqlValue>();

            list.Add(new SqlValue("userid", info.userid));
            list.Add(new SqlValue("x", info.x));
            list.Add(new SqlValue("y", info.y));
            list.Add(new SqlValue("logout", Convert.ToInt32(false)));
            SQLEditor.InsertValues("CDPlugin", list);
        }
Exemplo n.º 3
0
        private static bool DayRegions_Add(string name)
        {
            List <SqlValue> values = new List <SqlValue>();

            values.Add(new SqlValue("Region", "'" + name + "'"));
            lock (db)
            {
                SQLeditor.InsertValues("DayRegions", values);
            }
            return(true);
        }
Exemplo n.º 4
0
        internal void OnInitialize()
        {
            if (C3Config.TeamColor1 < 1 || C3Config.TeamColor1 > 4 || C3Config.TeamColor1 == C3Config.TeamColor2 || C3Config.TeamColor2 > 4 || C3Config.TeamColor2 < 1)
            {
                throw new Exception("Team Colours are inccorectly set up. Check c3config.json");
            }

            SQLEditor = new SqlTableEditor(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());

            ApocalypseMonsters.AddNPCs();
            int ArenaCount;

            #region TestPerms
            //Checks to see if permissions have been moved around
            bool vote             = false;
            bool joinvote         = false;
            bool setflags         = false;
            bool setspawns        = false;
            bool managec3settings = false;
            bool cvote            = false;
            bool duel             = false;
            foreach (Group group in TShock.Groups.groups)
            {
                if (group.Name != "superadmin")
                {
                    if (group.HasPermission("vote"))
                    {
                        vote = true;
                    }
                    if (group.HasPermission("joinvote"))
                    {
                        joinvote = true;
                    }
                    if (group.HasPermission("setflags"))
                    {
                        setflags = true;
                    }
                    if (group.HasPermission("managec3settings"))
                    {
                        managec3settings = true;
                    }
                    if (group.HasPermission("cvote"))
                    {
                        cvote = true;
                    }
                    if (group.HasPermission("duel"))
                    {
                        duel = true;
                    }
                    if (group.HasPermission("setspawns"))
                    {
                        setspawns = true;
                    }
                }
            }
            List <string> perm = new List <string>();
            if (!vote)
            {
                perm.Add("vote");
            }
            if (!joinvote)
            {
                perm.Add("joinvote");
            }
            if (!duel)
            {
                perm.Add("duel");
            }
            TShock.Groups.AddPermissions("default", perm);

            perm.Clear();
            if (!setflags)
            {
                perm.Add("setflags");
            }
            if (!setflags)
            {
                perm.Add("setspawns");
            }
            if (!managec3settings)
            {
                perm.Add("managec3settings");
            }
            if (!cvote)
            {
                perm.Add("cvote");
            }
            if (!setspawns)
            {
                perm.Add("setspawns");
            }
            TShock.Groups.AddPermissions("trustedadmin", perm);
            #endregion
            //Converted v2.2
            #region AddCommands
            if (C3Mod.C3Config.TeamColor1 == 1)
            {
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam1Flag, "setctfredflag"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam1Spawn, "setctfredspawn"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlagTeam1Spawn, "setoneflagredspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetDuelTeam1Spawn, "setduelredspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetTDMTeam1Spawn, "settdmredspawn"));
            }
            else if (C3Mod.C3Config.TeamColor1 == 2)
            {
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam1Flag, "setctfgreenflag"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam1Spawn, "setctfgreenspawn"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlagTeam1Spawn, "setoneflaggreenspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetDuelTeam1Spawn, "setduelgreenspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetTDMTeam1Spawn, "settdmgreenspawn"));
            }
            else if (C3Mod.C3Config.TeamColor1 == 3)
            {
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam1Flag, "setctfblueflag"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam1Spawn, "setctfbluespawn"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlagTeam1Spawn, "setoneflagbluespawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetDuelTeam1Spawn, "setduelbluespawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetTDMTeam1Spawn, "settdmbluespawn"));
            }
            else if (C3Mod.C3Config.TeamColor1 == 4)
            {
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam1Flag, "setctfyellowflag"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam1Spawn, "setctfyellowspawn"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlagTeam1Spawn, "setoneflagyellowspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetDuelTeam1Spawn, "setduelyellowspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetTDMTeam1Spawn, "settdmyellowspawn"));
            }
            if (C3Mod.C3Config.TeamColor2 == 1)
            {
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam2Flag, "setctfredflag"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam2Spawn, "setctfredspawn"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlagTeam2Spawn, "setoneflagredspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetDuelTeam2Spawn, "setduelredspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetTDMTeam2Spawn, "settdmredspawn"));
            }
            else if (C3Mod.C3Config.TeamColor2 == 2)
            {
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam2Flag, "setctfgreenflag"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam2Spawn, "setctfgreenspawn"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlagTeam2Spawn, "setoneflaggreenspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetDuelTeam2Spawn, "setduelgreenspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetTDMTeam2Spawn, "settdmgreenspawn"));
            }
            else if (C3Mod.C3Config.TeamColor2 == 3)
            {
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam2Flag, "setctfblueflag"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam2Spawn, "setctfbluespawn"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlagTeam2Spawn, "setoneflagbluespawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetDuelTeam2Spawn, "setduelbluespawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetTDMTeam2Spawn, "settdmbluespawn"));
            }
            else if (C3Mod.C3Config.TeamColor2 == 4)
            {
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam2Flag, "setctfyellowflag"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetCTFTeam2Spawn, "setctfyellowspawn"));
                Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlagTeam2Spawn, "setoneflagyellowspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetDuelTeam2Spawn, "setduelyellowspawn"));
                Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetTDMTeam2Spawn, "settdmyellowspawn"));
            }


            Commands.ChatCommands.Add(new Command("setflags", C3Commands.AddCTFArena, "addctfarena"));
            Commands.ChatCommands.Add(new Command("setflags", C3Commands.SetOneFlag, "setoneflag"));
            Commands.ChatCommands.Add(new Command("setflags", C3Commands.AddOneFlagArena, "addoneflagarena"));
            Commands.ChatCommands.Add(new Command("setflags", C3Commands.AddDuelArena, "addduelarena"));
            Commands.ChatCommands.Add(new Command("setflags", C3Commands.AddTDMArena, "addtdmarena"));

            Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetFFASpawn, "setffaspawn"));
            Commands.ChatCommands.Add(new Command("setflags", C3Commands.AddFFAArena, "addffaarena"));

            Commands.ChatCommands.Add(new Command("vote", C3Commands.StartVote, "vote"));
            Commands.ChatCommands.Add(new Command("joinvote", C3Commands.JoinVote, "join"));
            Commands.ChatCommands.Add(new Command("managec3settings", C3Commands.Stop, "stop"));
            Commands.ChatCommands.Add(new Command(C3Commands.Quit, "quit"));
            Commands.ChatCommands.Add(new Command("managec3settings", C3Commands.SetCTFLimit, "setctflimit"));
            Commands.ChatCommands.Add(new Command("managec3settings", C3Commands.SetOneFlagLimit, "setoneflaglimit"));
            Commands.ChatCommands.Add(new Command("managec3settings", C3Commands.SetDuelLimit, "setduellimit"));
            Commands.ChatCommands.Add(new Command("managec3settings", C3Commands.SetTDMLimit, "settdmlimit"));

            Commands.ChatCommands.Add(new Command("managec3settings", C3Commands.SetFFALimit, "setffalimit"));

            Commands.ChatCommands.Add(new Command("cvote", C3Commands.CancelVote, "cvote"));
            Commands.ChatCommands.Add(new Command("duel", C3Commands.ChallengePlayer, "duel"));
            Commands.ChatCommands.Add(new Command(C3Commands.AcceptChallenge, "accept"));

            Commands.ChatCommands.Add(new Command(C3Commands.ListArenaID, "list"));
            Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetApocPlayerSpawn, "setapocplayerspawn"));
            Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetApocMonsterSpawn, "setapocmonsterspawn"));
            Commands.ChatCommands.Add(new Command("setspawns", C3Commands.SetApocSpectatorSpawn, "setapocspectatorspawn"));
            #endregion

            #region FlagPoints

            var table = new SqlTable("FlagPoints",
                                     new SqlColumn("Name", MySqlDbType.Text),
                                     new SqlColumn("RedX", MySqlDbType.Int32),
                                     new SqlColumn("RedY", MySqlDbType.Int32),
                                     new SqlColumn("BlueX", MySqlDbType.Int32),
                                     new SqlColumn("BlueY", MySqlDbType.Int32),
                                     new SqlColumn("RedSpawnX", MySqlDbType.Int32),
                                     new SqlColumn("RedSpawnY", MySqlDbType.Int32),
                                     new SqlColumn("BlueSpawnX", MySqlDbType.Int32),
                                     new SqlColumn("BlueSpawnY", MySqlDbType.Int32)
                                     );
            SQLWriter.EnsureExists(table);

            if ((ArenaCount = SQLEditor.ReadColumn("FlagPoints", "Name", new List <SqlValue>()).Count) != 0)
            {
                for (int i = 0; i < ArenaCount; i++)
                {
                    string name       = SQLEditor.ReadColumn("FlagPoints", "Name", new List <SqlValue>())[i].ToString();
                    int    redx       = Int32.Parse(SQLEditor.ReadColumn("FlagPoints", "RedX", new List <SqlValue>())[i].ToString());
                    int    redy       = Int32.Parse(SQLEditor.ReadColumn("FlagPoints", "RedY", new List <SqlValue>())[i].ToString());
                    int    bluex      = Int32.Parse(SQLEditor.ReadColumn("FlagPoints", "BlueX", new List <SqlValue>())[i].ToString());
                    int    bluey      = Int32.Parse(SQLEditor.ReadColumn("FlagPoints", "BlueY", new List <SqlValue>())[i].ToString());
                    int    redspawnx  = Int32.Parse(SQLEditor.ReadColumn("FlagPoints", "RedSpawnX", new List <SqlValue>())[i].ToString());
                    int    redspawny  = Int32.Parse(SQLEditor.ReadColumn("FlagPoints", "RedSpawnY", new List <SqlValue>())[i].ToString());
                    int    bluespawnx = Int32.Parse(SQLEditor.ReadColumn("FlagPoints", "BlueSpawnX", new List <SqlValue>())[i].ToString());
                    int    bluespawny = Int32.Parse(SQLEditor.ReadColumn("FlagPoints", "BlueSpawnY", new List <SqlValue>())[i].ToString());

                    CTF.Arenas.Add(new CTFArena(new Vector2(redx, redy), new Vector2(bluex, bluey), new Vector2(redspawnx, redspawny), new Vector2(bluespawnx, bluespawny), name));
                }
            }

            #endregion

            #region DuelSpawns

            table = new SqlTable("DuelSpawns",
                                 new SqlColumn("Name", MySqlDbType.Text),
                                 new SqlColumn("RedSpawnX", MySqlDbType.Int32),
                                 new SqlColumn("RedSpawnY", MySqlDbType.Int32),
                                 new SqlColumn("BlueSpawnX", MySqlDbType.Int32),
                                 new SqlColumn("BlueSpawnY", MySqlDbType.Int32)
                                 );
            SQLWriter.EnsureExists(table);

            if ((ArenaCount = SQLEditor.ReadColumn("DuelSpawns", "Name", new List <SqlValue>()).Count) != 0)
            {
                for (int i = 0; i < ArenaCount; i++)
                {
                    string name  = SQLEditor.ReadColumn("DuelSpawns", "Name", new List <SqlValue>())[0].ToString();
                    int    redx  = Int32.Parse(SQLEditor.ReadColumn("DuelSpawns", "RedSpawnX", new List <SqlValue>())[0].ToString());
                    int    redy  = Int32.Parse(SQLEditor.ReadColumn("DuelSpawns", "RedSpawnY", new List <SqlValue>())[0].ToString());
                    int    bluex = Int32.Parse(SQLEditor.ReadColumn("DuelSpawns", "BlueSpawnX", new List <SqlValue>())[0].ToString());
                    int    bluey = Int32.Parse(SQLEditor.ReadColumn("DuelSpawns", "BlueSpawnY", new List <SqlValue>())[0].ToString());

                    Duel.Arenas.Add(new DuelArena(new Vector2(redx, redy), new Vector2(bluex, bluey), name));
                }
            }

            #endregion

            #region OneFlagPoints

            table = new SqlTable("OneFlagPoints",
                                 new SqlColumn("Name", MySqlDbType.Text),
                                 new SqlColumn("FlagX", MySqlDbType.Int32),
                                 new SqlColumn("FlagY", MySqlDbType.Int32),
                                 new SqlColumn("RedSpawnX", MySqlDbType.Int32),
                                 new SqlColumn("RedSpawnY", MySqlDbType.Int32),
                                 new SqlColumn("BlueSpawnX", MySqlDbType.Int32),
                                 new SqlColumn("BlueSpawnY", MySqlDbType.Int32)
                                 );
            SQLWriter.EnsureExists(table);

            if ((ArenaCount = SQLEditor.ReadColumn("OneFlagPoints", "Name", new List <SqlValue>()).Count) != 0)
            {
                for (int i = 0; i < ArenaCount; i++)
                {
                    string name       = SQLEditor.ReadColumn("OneFlagPoints", "Name", new List <SqlValue>())[i].ToString();
                    int    flagx      = Int32.Parse(SQLEditor.ReadColumn("OneFlagPoints", "FlagX", new List <SqlValue>())[i].ToString());
                    int    flagy      = Int32.Parse(SQLEditor.ReadColumn("OneFlagPoints", "FlagY", new List <SqlValue>())[i].ToString());
                    int    redspawnx  = Int32.Parse(SQLEditor.ReadColumn("OneFlagPoints", "RedSpawnX", new List <SqlValue>())[i].ToString());
                    int    redspawny  = Int32.Parse(SQLEditor.ReadColumn("OneFlagPoints", "RedSpawnY", new List <SqlValue>())[i].ToString());
                    int    bluespawnx = Int32.Parse(SQLEditor.ReadColumn("OneFlagPoints", "BlueSpawnX", new List <SqlValue>())[i].ToString());
                    int    bluespawny = Int32.Parse(SQLEditor.ReadColumn("OneFlagPoints", "BlueSpawnY", new List <SqlValue>())[i].ToString());

                    OneFlagCTF.Arenas.Add(new OneFlagArena(new Vector2(flagx, flagy), new Vector2(redspawnx, redspawny), new Vector2(bluespawnx, bluespawny), name));
                }
            }

            #endregion

            #region TDMSpawns

            table = new SqlTable("TDMSpawns",
                                 new SqlColumn("Name", MySqlDbType.Text),
                                 new SqlColumn("RedSpawnX", MySqlDbType.Int32),
                                 new SqlColumn("RedSpawnY", MySqlDbType.Int32),
                                 new SqlColumn("BlueSpawnX", MySqlDbType.Int32),
                                 new SqlColumn("BlueSpawnY", MySqlDbType.Int32)
                                 );
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter.EnsureExists(table);

            if ((ArenaCount = SQLEditor.ReadColumn("TDMSpawns", "Name", new List <SqlValue>()).Count) != 0)
            {
                for (int i = 0; i < ArenaCount; i++)
                {
                    string name  = SQLEditor.ReadColumn("TDMSpawns", "Name", new List <SqlValue>())[i].ToString();
                    int    redx  = Int32.Parse(SQLEditor.ReadColumn("TDMSpawns", "RedSpawnX", new List <SqlValue>())[i].ToString());
                    int    redy  = Int32.Parse(SQLEditor.ReadColumn("TDMSpawns", "RedSpawnY", new List <SqlValue>())[i].ToString());
                    int    bluex = Int32.Parse(SQLEditor.ReadColumn("TDMSpawns", "BlueSpawnX", new List <SqlValue>())[i].ToString());
                    int    bluey = Int32.Parse(SQLEditor.ReadColumn("TDMSpawns", "BlueSpawnY", new List <SqlValue>())[i].ToString());

                    TDM.Arenas.Add(new TDMArena(new Vector2(redx, redy), new Vector2(bluex, bluey), name));
                }
            }

            #endregion

            #region FFASpawns

            table = new SqlTable("FFASpawns",
                                 new SqlColumn("Name", MySqlDbType.Text),
                                 new SqlColumn("SpawnX", MySqlDbType.Int32),
                                 new SqlColumn("SpawnY", MySqlDbType.Int32)
                                 );
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter.EnsureExists(table);

            if ((ArenaCount = SQLEditor.ReadColumn("FFASpawns", "Name", new List <SqlValue>()).Count) != 0)
            {
                for (int i = 0; i < ArenaCount; i++)
                {
                    string name = SQLEditor.ReadColumn("FFASpawns", "Name", new List <SqlValue>())[i].ToString();
                    int    x    = Int32.Parse(SQLEditor.ReadColumn("FFASpawns", "SpawnX", new List <SqlValue>())[i].ToString());
                    int    y    = Int32.Parse(SQLEditor.ReadColumn("FFASpawns", "SpawnY", new List <SqlValue>())[i].ToString());

                    FFA.Arenas.Add(new FFAArena(new Vector2(x, y), name));
                }
            }

            #endregion

            #region Apocalypse

            table = new SqlTable("Apocalypse",
                                 new SqlColumn("SpawnX", MySqlDbType.Int32),
                                 new SqlColumn("SpawnY", MySqlDbType.Int32),
                                 new SqlColumn("MonsterSpawnX", MySqlDbType.Int32),
                                 new SqlColumn("MonsterSpawnY", MySqlDbType.Int32),
                                 new SqlColumn("SpectatorSpawnX", MySqlDbType.Int32),
                                 new SqlColumn("SpectatorSpawnY", MySqlDbType.Int32)
                                 );
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter.EnsureExists(table);

            if (SQLEditor.ReadColumn("Apocalypse", "SpawnX", new List <SqlValue>()).Count == 0)
            {
                List <SqlValue> list = new List <SqlValue>();
                list.Add(new SqlValue("SpawnX", 0));
                list.Add(new SqlValue("SpawnY", 0));
                list.Add(new SqlValue("MonsterSpawnX", 0));
                list.Add(new SqlValue("MonsterSpawnY", 0));
                list.Add(new SqlValue("SpectatorSpawnX", 0));
                list.Add(new SqlValue("SpectatorSpawnY", 0));
                SQLEditor.InsertValues("Apocalypse", list);
            }
            else
            {
                Apocalypse.PlayerSpawn.X   = Int32.Parse(SQLEditor.ReadColumn("Apocalypse", "SpawnX", new List <SqlValue>())[0].ToString());
                Apocalypse.PlayerSpawn.Y   = Int32.Parse(SQLEditor.ReadColumn("Apocalypse", "SpawnY", new List <SqlValue>())[0].ToString());
                Apocalypse.MonsterSpawn.X  = Int32.Parse(SQLEditor.ReadColumn("Apocalypse", "MonsterSpawnX", new List <SqlValue>())[0].ToString());
                Apocalypse.MonsterSpawn.Y  = Int32.Parse(SQLEditor.ReadColumn("Apocalypse", "MonsterSpawnY", new List <SqlValue>())[0].ToString());
                Apocalypse.SpectatorArea.X = Int32.Parse(SQLEditor.ReadColumn("Apocalypse", "SpectatorSpawnX", new List <SqlValue>())[0].ToString());
                Apocalypse.SpectatorArea.Y = Int32.Parse(SQLEditor.ReadColumn("Apocalypse", "SpectatorSpawnY", new List <SqlValue>())[0].ToString());
            }

            #endregion
        }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
0
        public void OnInitialize()
        {
            SQLEditor = new SqlTableEditor(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            SQLWriter = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
            bool setcost          = false;
            bool freewarp         = false;
            bool freetp           = false;
            bool freeheal         = false;
            bool freebuff         = false;
            bool checkcommandcost = false;

            foreach (Group group in TShock.Groups.groups)
            {
                if (group.Name != "superadmin")
                {
                    if (group.HasPermission("setcost"))
                    {
                        setcost = true;
                    }
                    if (group.HasPermission("freewarp"))
                    {
                        freewarp = true;
                    }
                    if (group.HasPermission("freetp"))
                    {
                        freetp = true;
                    }
                    if (group.HasPermission("freeheal"))
                    {
                        freeheal = true;
                    }
                    if (group.HasPermission("freebuff"))
                    {
                        setcost = true;
                    }
                    if (group.HasPermission("checkcommandcost"))
                    {
                        checkcommandcost = true;
                    }
                }
            }

            List <string> permlist = new List <string>();

            if (!setcost)
            {
                permlist.Add("setcost");
            }
            if (!freewarp)
            {
                permlist.Add("freewarp");
            }
            if (!freetp)
            {
                permlist.Add("freetp");
            }
            if (!freeheal)
            {
                permlist.Add("freeheal");
            }
            if (!freebuff)
            {
                permlist.Add("freebuff");
            }
            if (!checkcommandcost)
            {
                permlist.Add("checkcommandcost");
            }
            TShock.Groups.AddPermissions("trustedadmin", permlist);

            Commands.ChatCommands.Add(new Command("setcost", SetCost, "setcost"));
            Commands.ChatCommands.Add(new Command("setcost", SetWarpCost, "setwarpcost"));
            Commands.ChatCommands.Add(new Command("checkcommandcost", CheckCommandCost, "checkcommandcost"));
            Commands.ChatCommands.Add(new Command("checkcommandcost", CheckWarpCost, "checkwarpcost"));
            var table = new SqlTable("CommandCosts",
                                     new SqlColumn("Command", MySqlDbType.String, 255)
            {
                Unique = true
            },
                                     new SqlColumn("Cost", MySqlDbType.Int32)
                                     );

            SQLWriter.EnsureExists(table);
            if (SQLEditor.ReadColumn("CommandCosts", "Command", new List <SqlValue>()).Count == 0)
            {
                List <SqlValue> tp = new List <SqlValue>();
                tp.Add(new SqlValue("Command", "'" + "tp" + "'"));
                tp.Add(new SqlValue("Cost", 100));
                SQLEditor.InsertValues("CommandCosts", tp);
                List <SqlValue> heal = new List <SqlValue>();
                heal.Add(new SqlValue("Command", "'" + "heal" + "'"));
                heal.Add(new SqlValue("Cost", 100));
                SQLEditor.InsertValues("CommandCosts", heal);
                List <SqlValue> buff = new List <SqlValue>();
                buff.Add(new SqlValue("Command", "'" + "buff" + "'"));
                buff.Add(new SqlValue("Cost", 100));
                SQLEditor.InsertValues("CommandCosts", buff);
                List <SqlValue> warp = new List <SqlValue>();
                warp.Add(new SqlValue("Command", "'" + "warp" + "'"));
                warp.Add(new SqlValue("Cost", 100));
                SQLEditor.InsertValues("CommandCosts", warp);
            }
            List <SqlValue> where1 = new List <SqlValue>();

            where1.Add(new SqlValue("Command", "'" + "warp" + "'"));
            warpcost = Int32.Parse(SQLEditor.ReadColumn("CommandCosts", "Cost", where1)[0].ToString());
            List <SqlValue> where2 = new List <SqlValue>();

            where2.Add(new SqlValue("Command", "'" + "tp" + "'"));
            tpcost = Int32.Parse(SQLEditor.ReadColumn("CommandCosts", "Cost", where1)[0].ToString());
            List <SqlValue> where3 = new List <SqlValue>();

            where3.Add(new SqlValue("Command", "'" + "heal" + "'"));
            healcost = Int32.Parse(SQLEditor.ReadColumn("CommandCosts", "Cost", where1)[0].ToString());
            List <SqlValue> where4 = new List <SqlValue>();

            where4.Add(new SqlValue("Command", "'" + "buff" + "'"));
            buffcost = Int32.Parse(SQLEditor.ReadColumn("CommandCosts", "Cost", where1)[0].ToString());
        }