コード例 #1
0
 public static void AddNewNobility(int Identifier, string Name, long Donation)
 {
     using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
     {
         using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.INSERT, false))
         {
             cmd.AddInsertValue("PlayerID", Identifier);
             cmd.AddInsertValue("PlayerName", Name);
             cmd.AddInsertValue("NobilityDonation", Donation);
             cmd.Finish("DB_NobilityBoard");
         }
         sql.Execute();
     }
 }
コード例 #2
0
        public static void AddNewMonsterSpawn(ushort mapid, ushort x, ushort y, int monsterid, int count, int drop, int range, bool guard)
        {
            using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
            {
                using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.INSERT, false))
                {
                    cmd.AddInsertValue("MonsterID", monsterid);
                    cmd.AddInsertValue("CenterX", x);
                    cmd.AddInsertValue("CenterY", y);
                    cmd.AddInsertValue("Drop", drop);
                    cmd.AddInsertValue("Count", count);
                    if (guard)
                        cmd.AddInsertValue("Range", (int)1);
                    else
                        cmd.AddInsertValue("Range", range);
                    cmd.Finish("DB_MobSpawns");
                }
                sql.Execute();
            }

            for (int i = 0; i < count; i++)
            {
                Entities.Monster spawnmob = Core.Kernel.Monsters[monsterid].Copy();
                spawnmob.Direction = (byte)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(0, 8);
                if (Core.Kernel.Maps[mapid].EnterMap(spawnmob))
                {
                    Maps.MapPoint Location = spawnmob.Map.CreateAvailableLocation<Entities.Monster>(x, y, range);
                    if (Location != null)
                    {
                        spawnmob.X = Location.X;
                        spawnmob.Y = Location.Y;
                        spawnmob.OriginalRange = range;
                        spawnmob.OriginalX = x;
                        spawnmob.OriginalY = y;

                        //if (drop > 0)
                        //{
                        //	spawnmob.DropData = Core.Kernel.DropData[drop].Copy();
                        //}

                        Threads.MonsterThread.AddToMonsterThread(spawnmob, !(((byte)spawnmob.Behaviour) < 3 || spawnmob.Behaviour == Enums.MonsterBehaviour.PhysicalGuard));

                        spawnmob.Screen.UpdateScreen(null);
                    }
                }
            }
        }
コード例 #3
0
        public static void AddNewArenaInfo(Data.ArenaInfo arena)
        {
            using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
            {
                using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.INSERT, false))
                {
                    cmd.AddInsertValue("PlayerID", arena.DatabaseID);
                    cmd.AddInsertValue("PlayerName", arena.Name);
                    cmd.AddInsertValue("ArenaLevel", arena.Level);
                    cmd.AddInsertValue("ArenaClass", arena.Class);
                    cmd.AddInsertValue("Mesh", arena.Mesh);
                    cmd.AddInsertValue("HonorPoints", arena.DatabaseID);
                    cmd.AddInsertValue("ArenaPoints", arena.ArenaPoints);
                    cmd.AddInsertValue("TotalWins", arena.ArenaTotalWins);
                    cmd.AddInsertValue("TotalWinsToday", arena.ArenaWinsToday);
                    cmd.AddInsertValue("TotalLoss", arena.ArenaTotalLoss);
                    cmd.AddInsertValue("TotalLossToday", arena.ArenaLossToday);
                    cmd.AddInsertValue("TodayUpdate", DateTime.Now);
                    cmd.Finish("DB_ArenaQualifier");
                }
                sql.Execute();
            }

            SetRecordID(arena);
        }
コード例 #4
0
        public static void UpdateAuthentication(Client.AuthClient client)
        {
            if (PlayerExists(client.DatabaseUID))
            {
                using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
                    {
                        cmd.AddWhereValue("PlayerID", client.DatabaseUID);
                        cmd.AddUpdateValue("PlayerLastEntityUID", client.EntityUID);
                        cmd.AddUpdateValue("PlayerLoginOK", true);

                        cmd.Finish("DB_Players");
                    }
                    sql.Execute();
                }
            }
            else
            {
                using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.INSERT, false))
                    {
                        cmd.AddInsertValue("PlayerID", client.DatabaseUID);
                        cmd.AddInsertValue("PlayerNew", true);
                        cmd.AddInsertValue("PlayerAccount", client.Account);
                        cmd.AddInsertValue("PlayerLastEntityUID", client.EntityUID);
                        cmd.AddInsertValue("PlayerLoginOK", true);
                        cmd.AddInsertValue("PlayerServer", client.Server);

                        cmd.Finish("DB_Players");
                    }
                    sql.Execute();
                }
            }
        }
コード例 #5
0
        // -1 = finished
        public static void SaveQuest(Entities.GameClient client, string Name, int Progress, string InfoString)
        {
            bool Exists = false;
            using (var existsql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
            {
                using (var existcmd = new SqlCommandBuilder(existsql, SqlCommandType.SELECT, true))
                {
                    existcmd.AddWhereValue("PlayerID", client.DatabaseUID);
                    existcmd.AddWhereValue("QuestName", Name);
                    existcmd.Finish("DB_Quests");
                }
                Exists = existsql.Read();
            }

            using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
            {
                if (Exists)
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
                    {
                        cmd.AddWhereValue("PlayerID", client.DatabaseUID);
                        cmd.AddWhereValue("QuestName", Name);
                        cmd.AddUpdateValue("QuestProgress", Progress.ToString());
                        cmd.AddUpdateValue("QuestInfo", InfoString);
                        cmd.Finish("DB_Quests");
                    }
                }
                else
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.INSERT, false))
                    {
                        cmd.AddInsertValue("PlayerID", client.DatabaseUID);
                        cmd.AddInsertValue("QuestName", Name);
                        cmd.AddInsertValue("QuestProgress", Progress.ToString());
                        cmd.AddInsertValue("QuestInfo", InfoString);
                        cmd.Finish("DB_Quests");
                    }
                }
                sql.Execute();
            }
        }
コード例 #6
0
        /// <summary>
        /// Saves profs.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="prof">The prof.</param>
        public static void SaveProf(Entities.GameClient client, Data.SpellInfo prof)
        {
            if (!client.LoggedIn || client.IsAIBot)
                return;
            bool Exists = false;
            using (var existsql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
            {
                using (var existcmd = new SqlCommandBuilder(existsql, SqlCommandType.SELECT, true))
                {
                    existcmd.AddWhereValue("PlayerID", client.DatabaseUID);
                    existcmd.AddWhereValue("Prof", prof.ID);
                    existcmd.Finish("DB_PlayerProfs");
                }
                Exists = existsql.Read();
            }

            using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
            {
                if (Exists)
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
                    {
                        cmd.AddWhereValue("PlayerID", client.DatabaseUID);
                        cmd.AddWhereValue("Prof", prof.ID);
                        cmd.AddUpdateValue("ProfLevel", prof.Level);
                        cmd.AddUpdateValue("ProfExperience", prof.Experience);
                        cmd.Finish("DB_PlayerProfs");
                    }
                }
                else
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.INSERT, false))
                    {
                        cmd.AddInsertValue("PlayerID", client.DatabaseUID);
                        cmd.AddInsertValue("Prof", prof.ID);
                        cmd.AddInsertValue("ProfLevel", prof.Level);
                        cmd.AddInsertValue("ProfExperience", prof.Experience);
                        cmd.Finish("DB_PlayerProfs");
                    }
                }

                sql.Execute();
            }
        }