Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void InsertPlayer(uint ID, string character)
- {
- using (MySqlConnection conn = new MySqlConnection(Database.ConnectionString))
- {
- conn.Open();
- MySqlCommand cmd = new MySqlCommand("INSERT INTO `numberlottery` VALUES (" + ID + ",'" + character + "')", conn);
- cmd.ExecuteNonQuery();
- }
- }
- ------------------------------------------------------------------------------------------
- public static int IsParticipant(uint ID)
- {
- int number = -1;
- using (MySqlConnection conn = new MySqlConnection(Database.ConnectionString))
- {
- conn.Open();
- MySqlCommand cmd = new MySqlCommand("SELECT * FROM `numberlottery` WHERE PlayerID = " + ID, conn);
- MySqlDataReader rdr = cmd.ExecuteReader();
- if (rdr.Read())
- {
- number = 1;
- }
- }
- return number;
- }
- ------------------------------------------------------------------------------------------
- public class Database
- {
- public static string mysqlUser = "";
- public static string mysqlPassword = "";
- public static string mysqlDatabase = "";
- public static string ConnectionString;
- public static void OpenDatabases()
- {
- ConnectionString = "Server='localhost';Database='" + mysqlDatabase + "';Username='" + mysqlUser + "';Password='" + mysqlPassword + "';Pooling=true;Min Pool Size=5;Max Pool Size=40; Connection Timeout=5900;";
- }
- public static int GetVoteCount(string account)
- {
- string ConnectionString = "Server='';Database='';Username='';Password='';Pooling=false;";
- int count = 0;
- using (MySqlConnection conn = new MySqlConnection(ConnectionString))
- {
- conn.Open();
- MySqlDataAdapter DataAdapter = null;
- DataSet DSet = new DataSet();
- DataAdapter = new MySqlDataAdapter("SELECT * FROM `co_vote` WHERE AccountID ='" + account + "'", conn);//read
- DataAdapter.Fill(DSet, "table");
- if (DSet != null && DSet.Tables["table"].Rows.Count > 0)
- {
- DataRow DR = DSet.Tables["table"].Rows[0];
- count = Convert.ToInt32(DR["Points"]);
- }
- }
- return count;
- }
- ------------------------------------------------------------------------------------------
- /*
- public static string mysqlUser = "";
- public static string mysqlPassword = "";
- public static string mysqlDatabase = "";
- public const string SERVER = "localhost";
- static MySqlConnection conn = new MySqlConnection("Server=" + SERVER + ";Database='" + mysqlDatabase + "';Username='" + mysqlUser + "';Password='" + mysqlPassword + "';");
- static bool did = false;
- public static MySqlConnection Connection
- {
- get
- {
- if (!did)
- { conn.Open(); did = true; conn.StateChange += new System.Data.StateChangeEventHandler(conn_StateChange); }
- return conn;
- }
- }
- static void conn_StateChange(object sender, System.Data.StateChangeEventArgs e)
- {
- if (e.CurrentState == System.Data.ConnectionState.Closed || e.CurrentState == System.Data.ConnectionState.Broken)
- {
- conn.Dispose();
- conn = new MySqlConnection("Server=" + SERVER + ";Database='" + mysqlDatabase + "';Username='" + mysqlUser + "';Password='" + mysqlPassword + "';");
- conn.Open();
- conn.StateChange +=new System.Data.StateChangeEventHandler(conn_StateChange);
- }
- }*/
- ------------------------------------------------------------------------------------------
- public static Main.AuthWorker.AuthInfo Authenticate(string User, string Password)
- {
- using (MySqlConnection conn = new MySqlConnection(ConnectionString))
- {
- conn.Open();
- Main.AuthWorker.AuthInfo Info = new ConquerSx.Main.AuthWorker.AuthInfo();
- Info.Account = User;
- try
- {
- MySqlDataAdapter DataAdapter = null;
- DataAdapter = new MySqlDataAdapter("SELECT * FROM `Accounts` WHERE `AccountID` = '" + User + "'", conn);//read
- DataSet DSet = new DataSet();
- DataAdapter.Fill(DSet, "Account");
- if (DSet != null && DSet.Tables["Account"].Rows.Count > 0)
- {
- DataRow DR = DSet.Tables["Account"].Rows[0];
- string RealAccount = (string)DR["AccountID"];
- if (User == RealAccount)
- {
- string RealPassword = (string)DR["Password"];
- if (Main.PassCrypto.EncryptPassword(RealPassword) == Password)
- {
- int status = 0;
- if (!int.TryParse((string)DR["Status"], out status))
- Info.Status = (string)DR["Status"];
- else
- Info.Status = "[" + ((AccountStatus)status).ToString() + "]";
- Info.Character = (string)DR["Character"];
- if (Info.Character == "")
- Info.LogonType = 2;
- else
- Info.LogonType = 1;
- }
- else
- {
- Info.LogonType = 255;
- }
- }
- else
- {
- Info.LogonType = 255;
- }
- }
- else
- {
- Info.LogonType = 255;
- }
- }
- catch (Exception Exc) { Program.WriteLine(Exc); }
- return Info;
- }
- }
- ------------------------------------------------------------------------------------------
- public static void TopGuildReset()
- {
- using (MySqlConnection conn = new MySqlConnection(ConnectionString))
- {
- conn.Open();
- foreach (Game.Character Chaar in Game.World.H_Chars.Values)
- {
- {
- Chaar.StatEff.Remove(ConquerSx.Game.StatusEffectEn.TopDeputyLeader);
- Chaar.StatEff.Remove(ConquerSx.Game.StatusEffectEn.TopGuildLeader);
- Chaar.TopDeputyLeader = 0;
- Chaar.TopGuildLeader = 0;
- }
- }
- MySqlCommand cmd = new MySqlCommand("UPDATE `characters` SET `TopGuildLeader` = 0 ,`TopDeputyLeader` = 0 WHERE EntityID > 0", conn);//write
- cmd.ExecuteNonQuery();
- }
- }
- ------------------------------------------------------------------------------------------
- ctrl+f:
- //read
- and
- //write
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement