All pastes #919088 Raw Edit

Latheesan

public text v1 · immutable
#919088 ·published 2008-02-26 16:16 UTC
rendered paste body
        // 
        // A method in mysq mysql class to retrieve list of online charaters
        //
        public string[] getOnlinePlayers()
        {
            List<string> result = new List<string>();
            string Query = "SELECT * FROM `characters` WHERE `online` = '1' ORDER BY `acct` ASC";
            MySqlCommand onlinePlayerList = new MySqlCommand(Query, this.sqlConn);
            try
            {
                onlinePlayerList.ExecuteNonQuery();
                MySqlDataReader myReader = onlinePlayerList.ExecuteReader();
                while (myReader.Read())
                {
                    string Output = "";
                    Output = (string)myReader.GetValue(3)+" - ";
                    if ((int)myReader.GetValue(6) == 1)
                    {
                        Output += "Female - ";
                    }
                    else
                    {
                        Output += "Male - ";
                    }
                    Output += "Level " + (string)myReader.GetValue(8);
                    switch ((int)myReader.GetValue(4))
                    {
                        case 1: Output += "Human Race - "; break;
                        case 2: Output += "Orc Race - "; break;
                        case 3: Output += "Dwarf Race - "; break;
                        case 4: Output += "Night Elf Race - "; break;
                        case 5: Output += "Undead Race - "; break;
                        case 6: Output += "Tauren Race - "; break;
                        case 7: Output += "Gnome Race - "; break;
                        case 8: Output += "Troll Race - "; break;
                        case 9: Output += "Goblin Race - "; break;
                        case 10: Output += "Blood Elf Race - "; break;
                        case 11: Output += "Draenei Race - "; break;
                        default: Output += "Unknown Race - "; break;
                    }
                    switch ((int)myReader.GetValue(5))
                    {
                        case 1: Output += "Warrior Class - "; break;
                        case 2: Output += "Paladin Class - "; break;
                        case 3: Output += "Hunter Class - "; break;
                        case 4: Output += "Rogue Class - "; break;
                        case 5: Output += "Priest Class - "; break;
                        case 7: Output += "Shaman Class - "; break;
                        case 8: Output += "Mage Class - "; break;
                        case 9: Output += "Warlock Class - "; break;
                        case 11: Output += "Druid Class - "; break;
                        default: Output += "Unknown Class - "; break;
                    }
                    switch ((int)myReader.GetValue(30))
                    {
                        case 0: Output += "At Azeroth"; break;
                        case 1: Output += "At Kalimdor"; break;
                        case 2: Output += "At UnderMine"; break;
                        case 13: Output += "At Test zone"; break;
                        case 17: Output += "At Kalidar"; break;
                        case 30: Output += "At Alterac Valley"; break;
                        case 33: Output += "At Shadowfang Keep"; break;
                        case 34: Output += "At The Stockade"; break;
                        case 35: Output += "At Stormwind Prison"; break;
                        case 36: Output += "At Deadmines"; break;
                        case 37: Output += "At Plains of Snow"; break;
                        case 43: Output += "At Wailing Caverns"; break;
                        case 44: Output += "At Monastery Interior"; break;
                        case 47: Output += "At Razorfen Kraul"; break;
                        case 48: Output += "At Blackfathom Deeps"; break;
                        case 70: Output += "At Uldaman"; break;
                        case 90: Output += "At Gnomeregan"; break;
                        case 109: Output += "At Sunken Temple"; break;
                        case 129: Output += "At Razorfen Downs"; break;
                        case 169: Output += "At Emerald Forest"; break;
                        case 189: Output += "At Scarlet Monastery"; break;
                        case 209: Output += "At Zul'Farrak"; break;
                        case 229: Output += "At Blackrock Spire"; break;
                        case 230: Output += "At Blackrock Depths"; break;
                        case 249: Output += "At Onyxias Lair"; break;
                        case 269: Output += "At Caverns of Time"; break;
                        case 289: Output += "At Scholomance"; break;
                        case 309: Output += "At Zul'Gurub"; break;
                        case 329: Output += "At Stratholme"; break;
                        case 349: Output += "At Maraudon"; break;
                        case 369: Output += "At Deeprun Tram"; break;
                        case 389: Output += "At Ragefire Chasm"; break;
                        case 409: Output += "At The Molten Core"; break;
                        case 429: Output += "At Dire Maul"; break;
                        case 449: Output += "At Alliance PVP Barracks"; break;
                        case 450: Output += "At Horde PVP Barracks"; break;
                        case 451: Output += "At Development Land"; break;
                        case 469: Output += "At Blackwing Lair"; break;
                        case 489: Output += "At Warsong Gulch"; break;
                        case 509: Output += "At Ruins of Ahn'Qiraj"; break;
                        case 529: Output += "At Arathi Basin"; break;
                        case 530: Output += "At Burning Crusade Zones"; break;
                        case 531: Output += "At Temple of Ahn'Qiraj"; break;
                        case 532: Output += "At Karazhan"; break;
                        case 533: Output += "At Naxxramas"; break;
                        case 534: Output += "At Hyjal Past"; break;
                        case 540: Output += "At Shattered Halls"; break;
                        case 542: Output += "At Blood Furnace"; break;
                        case 543: Output += "At Hellfire Ramparts"; break;
                        case 544: Output += "At Magtheridon's Lair"; break;
                        case 545: Output += "At The Steamvault"; break;
                        case 546: Output += "At The Black Temple"; break;
                        case 547: Output += "At The Slave Pens"; break;
                        case 548: Output += "At Coilfang Resevoir"; break;
                        case 550: Output += "At The Eye"; break;
                        case 552: Output += "At The Arcatraz"; break;
                        case 553: Output += "At The Botanica"; break;
                        case 554: Output += "At The Mechanar"; break;
                        case 555: Output += "At Shadow Labyrinth"; break;
                        case 556: Output += "At Sethekk Halls"; break;
                        case 557: Output += "At Mana-Tombs"; break;
                        case 558: Output += "At Auchenai Crypts"; break;
                        case 559: Output += "At Nagrand Arena"; break;
                        case 560: Output += "At Hillsbrad Past"; break;
                        case 562: Output += "At Blade's Edge Arena"; break;
                        case 564: Output += "At Black Temple"; break;
                        case 565: Output += "At Gruul's Lair"; break;
                        case 566: Output += "At Eye of the Storm"; break;
                        case 568: Output += "At Zul'aman"; break;
                        default: Output += "At Unknown Location"; break;
                    }
                    result.Add(Output);
                }
                myReader.Close();
                return result.ToArray();
            }
            catch (Exception excp)
            {
                MessageBox.Show(excp.Message, "Could Not Get A List Of Online Players", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result.ToArray();
            }
        }

        //
        // Usage of the above method
        //
        private void refreshOnlinePlayerList()
        {
            onlinePlayerList.Items.Clear();
            MySQL db = new MySQL(Settings.Default.sqlHost, Settings.Default.sqlLoginDB, Settings.Default.sqlUser, Settings.Default.sqlPass);
            db.Connect();
            string[] onlinePlayer = db.getOnlinePlayers();
            db.Disconnect();
            for (int i = 0; i < onlinePlayer.Length; i++)
            {
                onlinePlayerList.Items.Add(onlinePlayer[i]);
            }
        }

        private void onlinePlayersTab_Enter(object sender, EventArgs e)
        {
            refreshOnlinePlayerList();
        }