Esempio n. 1
0
        public static void Login(int _userid)
        {
            List <SqlValue> where = new List <SqlValue>();
            where.Add(new SqlValue("userid", _userid));
            var sql = SQLEditor.ReadColumn("CDPlugin", "userid", where);

            if (sql.Count > 0)
            {
                UpdateStatus(true, _userid);
            }
            else
            {
                AddPos(new PlayerPos(_userid, 0, 0));
            }
        }
Esempio n. 2
0
        public void OnJoin(GreetPlayerEventArgs args)
        {
            Players.Add(new Mplayer(args.Who));

            var player  = TShock.Players[args.Who];
            var Mplayer = Utils.GetPlayers(args.Who);

            var readTableIP = SQLEditor.ReadColumn("muteList", "IP", new List <SqlValue>());

            if (readTableIP.Contains(player.IP))
            {
                Mplayer.muted    = true;
                Mplayer.muteTime = -1;
                foreach (TSPlayer tsplr in TShock.Players)
                {
                    if ((tsplr.Group.HasPermission("mute")) || (tsplr.Group.Name == "superadmin"))
                    {
                        tsplr.SendInfoMessage("A player that is on the perma-mute list is about to enter the server, and has been muted.");
                    }
                }
            }
            else
            {
                Mplayer.muteTime = -1;
                Mplayer.muted    = false;
            }
        }
Esempio n. 3
0
        public static bool InitializeTable()
        {
            var SQLEditor = new SqlTableEditor(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());

            try
            {
                if (SQLEditor.ReadColumn("ShopSystem", "Name", new List <SqlValue>()).Count < 1)
                {
                    Console.WriteLine("Writing item list for ShopSystem (This may take a while, please be patient)...");
                    for (int k = 1; k < 604; k++)
                    {
                        if (k == 269 || k == 270 || k == 271)    //this is a tshock bug
                        {
                        }
                        else
                        {
                            Item item  = TShockAPI.TShock.Utils.GetItemById(k);
                            int  value = item.value;
                            int  copper;
                            int  silver;
                            int  gold;
                            if (value % 10 != 0)
                            {
                                copper = Convert.ToInt32(item.value / 1.5);
                                silver = 0;
                                gold   = 0;
                            }
                            gold   = value / 1000;
                            value  = value - gold * 1000;
                            silver = value / 10;
                            value  = value - silver * 10;
                            copper = Convert.ToInt32(value * 1.5);
                            database.Query("INSERT INTO ShopSystem (Name, Copper, Silver, Gold, ForSale, MaxStack)" +
                                           " VALUES (@0, @1, @2, @3, 1, @4)", item.name, copper, silver, gold, item.maxStack);
                        }
                    }
                    Console.WriteLine("Wrote item list to SQL database successfully.");
                    Thread.Sleep(1000);
                }
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to write to SQL Database!");
                Log.Error("Write to SQL exception:(ShopSystem)");
                Log.Error(ex.ToString());
                return(false);
            }
        }
Esempio 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
        }
Esempio n. 5
0
 public void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
 {
     try
     {
         if (TShock.Players[ply].IsLoggedIn)
         {
             int RowID = SearchTable(SQLEditor.ReadColumn("ChatColor", "Name", new List <SqlValue>()), TShock.Players[ply].UserAccountName);
             if ((RowID != -1) && (Convert.ToBoolean(SQLEditor.ReadColumn("ChatColor", "CanChange", new List <SqlValue>())[RowID])))
             {
                 TShock.Players[ply].Group.R = Convert.ToByte(SQLEditor.ReadColumn("ChatColor", "R", new List <SqlValue>())[RowID].ToString());
                 TShock.Players[ply].Group.G = Convert.ToByte(SQLEditor.ReadColumn("ChatColor", "G", new List <SqlValue>())[RowID].ToString());
                 TShock.Players[ply].Group.B = Convert.ToByte(SQLEditor.ReadColumn("ChatColor", "B", new List <SqlValue>())[RowID].ToString());
             }
             else
             {
                 TShock.Players[ply].Group.R = 255;
                 TShock.Players[ply].Group.G = 255;
                 TShock.Players[ply].Group.B = 255;
             }
         }
         else
         {
             TShock.Players[ply].Group.R = 255;
             TShock.Players[ply].Group.G = 255;
             TShock.Players[ply].Group.B = 255;
         }
     }
     catch (Exception) { Console.Write("Chat color for user " + TShock.Players[ply].Name + " isn't working."); }
 }
Esempio 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());
        }
Esempio n. 7
0
        public void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            string cmd = text.Split(' ')[0];

            if (TShock.Players[ply].IsLoggedIn)
            {
                EPRPlayer player = ServerPointSystem.ServerPointSystem.GetEPRPlayerByIndex(ply);
                if (cmd == "/warp")
                {
                    if (text.Split(' ').Length > 1)
                    {
                        if (TShock.Warps.FindWarp(text.Split(' ')[1]).WarpPos != Vector2.Zero)
                        {
                            if (!TShock.Players[ply].Group.HasPermission("freewarp"))
                            {
                                int             warpcosttemp = warpcost;
                                int             currbal      = player.DisplayAccount;
                                string          warpname     = text.Split(' ')[1];
                                List <SqlValue> where2       = new List <SqlValue>();
                                where2.Add(new SqlValue("Command", "'" + "warp " + warpname + "'"));
                                if (SQLEditor.ReadColumn("CommandCosts", "Cost", where2).Count == 1)
                                {
                                    warpcosttemp = Int32.Parse(SQLEditor.ReadColumn("CommandCosts", "Cost", where2)[0].ToString());
                                }
                                if (currbal < warpcosttemp)
                                {
                                    TShock.Players[ply].SendMessage("You do not have enough " + ServerPointSystem.ServerPointSystem.currname + "s!", Color.Red);
                                    TShock.Players[ply].SendMessage("You need " + warpcosttemp + " " + ServerPointSystem.ServerPointSystem.currname + "s to use that command", Color.Red);
                                    e.Handled = true;
                                    return;
                                }
                                else
                                {
                                    EPREvents.PointUse(player, warpcosttemp, PointUsage.Command);
                                    player.TSPlayer.SendMessage(string.Format("Warped to {0} for {1} {2}(s)", warpname, warpcosttemp, ServerPointSystem.ServerPointSystem.currname), Color.Yellow);
                                    return;
                                }
                            }
                            //else
                            //    return;
                        }
                        //else
                        //    return;
                    }
                    //else
                    return;
                }
                else if (cmd == "/heal")
                {
                    if (!TShock.Players[ply].Group.HasPermission("freeheal"))
                    {
                        int currbal = player.DisplayAccount;
                        if (currbal < healcost)
                        {
                            TShock.Players[ply].SendMessage("You do not have enough " + ServerPointSystem.ServerPointSystem.currname + "s!", Color.Red);
                            TShock.Players[ply].SendMessage("You need " + healcost + " " + ServerPointSystem.ServerPointSystem.currname + "s to use that command", Color.Red);
                            e.Handled = true;
                            return;
                        }
                        else
                        {
                            EPREvents.PointUse(player, healcost, PointUsage.Command);
                            return;
                        }
                    }
                }
                else if (cmd == "/tp")
                {
                    if (!TShock.Players[ply].Group.HasPermission("freetp"))
                    {
                        int currbal = player.DisplayAccount;
                        if (currbal < tpcost)
                        {
                            TShock.Players[ply].SendMessage("You do not have enough " + ServerPointSystem.ServerPointSystem.currname + "s!", Color.Red);
                            TShock.Players[ply].SendMessage("You need " + tpcost + " " + ServerPointSystem.ServerPointSystem.currname + "s to use that command", Color.Red);
                            e.Handled = true;
                            return;
                        }
                        else
                        {
                            EPREvents.PointUse(player, tpcost, PointUsage.Command);
                            return;
                        }
                    }
                }
                else if (cmd == "/buff")
                {
                    if (!TShock.Players[ply].Group.HasPermission("freebuff"))
                    {
                        int currbal = player.DisplayAccount;
                        if (currbal < buffcost)
                        {
                            TShock.Players[ply].SendMessage("You do not have enough " + ServerPointSystem.ServerPointSystem.currname + "s!", Color.Red);
                            TShock.Players[ply].SendMessage("You need " + buffcost + " " + ServerPointSystem.ServerPointSystem.currname + "s to use that command", Color.Red);
                            e.Handled = true;
                            return;
                        }
                        else
                        {
                            EPREvents.PointUse(player, buffcost, PointUsage.Command);
                        }
                    }
                }
            }
            return;
        }
Esempio n. 8
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());

            #region Setup
            bool sethouse    = false;
            bool edithouse   = false;
            bool enterlocked = false;

            foreach (Group group in TShock.Groups.groups)
            {
                if (group.Name != "superadmin")
                {
                    if (group.HasPermission("sethouse"))
                    {
                        sethouse = true;
                    }
                    if (group.HasPermission("edithouse"))
                    {
                        edithouse = true;
                    }
                    if (group.HasPermission("enterlocked"))
                    {
                        enterlocked = true;
                    }
                }
            }
            List <string> perm = new List <string>();
            if (!sethouse)
            {
                perm.Add("sethouse");
            }
            if (!edithouse)
            {
                perm.Add("edithouse");
            }
            if (!enterlocked)
            {
                perm.Add("enterlocked");
            }
            TShock.Groups.AddPermissions("trustedadmin", perm);

            var table = new SqlTable("HousingDistrict",
                                     new SqlColumn("ID", MySqlDbType.Int32)
            {
                Primary = true, AutoIncrement = true
            },
                                     new SqlColumn("Name", MySqlDbType.Text)
            {
                Unique = true
            },
                                     new SqlColumn("TopX", MySqlDbType.Int32),
                                     new SqlColumn("TopY", MySqlDbType.Int32),
                                     new SqlColumn("BottomX", MySqlDbType.Int32),
                                     new SqlColumn("BottomY", MySqlDbType.Int32),
                                     new SqlColumn("Owners", MySqlDbType.Text),
                                     new SqlColumn("WorldID", MySqlDbType.Text),
                                     new SqlColumn("Locked", MySqlDbType.Int32)
                                     );
            SQLWriter.EnsureExists(table);

            for (int i = 0; i < SQLEditor.ReadColumn("HousingDistrict", "ID", new List <SqlValue>()).Count; i++)
            {
                string[]      list  = SQLEditor.ReadColumn("HousingDistrict", "Owners", new List <SqlValue>())[i].ToString().Split(',');
                List <string> items = new List <string>();

                foreach (string item in list)
                {
                    items.Add(item);
                }

                int locked = 0;

                if (SQLEditor.ReadColumn("HousingDistrict", "Locked", new List <SqlValue>())[i] != null)
                {
                    locked = (int)SQLEditor.ReadColumn("HousingDistrict", "Locked", new List <SqlValue>())[i];
                }

                Houses.Add(new House(
                               new Rectangle(
                                   (int)SQLEditor.ReadColumn("HousingDistrict", "TopX", new List <SqlValue>())[i],
                                   (int)SQLEditor.ReadColumn("HousingDistrict", "TopY", new List <SqlValue>())[i],
                                   (int)SQLEditor.ReadColumn("HousingDistrict", "BottomX", new List <SqlValue>())[i],
                                   (int)SQLEditor.ReadColumn("HousingDistrict", "BottomY", new List <SqlValue>())[i]),
                               items,
                               (int)SQLEditor.ReadColumn("HousingDistrict", "ID", new List <SqlValue>())[i],
                               (string)SQLEditor.ReadColumn("HousingDistrict", "Name", new List <SqlValue>())[i],
                               (string)SQLEditor.ReadColumn("HousingDistrict", "WorldID", new List <SqlValue>())[i],
                               locked));
            }
            #endregion

            #region Commands
            Commands.ChatCommands.Add(new Command("sethouse", HCommands.House, "house"));
            Commands.ChatCommands.Add(new Command("superadmin", HCommands.Convert, "converthouse"));
            Commands.ChatCommands.Add(new Command(HCommands.ChangeLock, "changelock"));
            Commands.ChatCommands.Add(new Command(HCommands.TellAll, "all"));
            #endregion
        }