Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // If the code reaches here - there is no player on the bot list to add
- // and we are checking here to see if the player is stored on the bz database
- public void CheckDB(PublicPlayer StoredPlayer, Queue<EventArgs> q)
- {
- //Open connection
- if (this.OpenConnection(q) == true)
- {
- int Bux = 0;
- string query = "SELECT bz_bux FROM bz_bank WHERE player_name = \"" + StoredPlayer.PlayerName + "\"";
- //Create Command
- MySqlCommand cmd = new MySqlCommand(query, connection);
- //Create a data reader and Execute the command
- MySqlDataReader dataReader = cmd.ExecuteReader();
- bool exists = dataReader.HasRows;
- if (exists)
- {
- //Read the data and store them in the list
- while (dataReader.Read())
- {
- Bux = int.Parse(dataReader["bz_bux"] + "");
- }
- StoredPlayer.BZBux = Bux * .01;
- }
- else
- {
- string query2 = "INSERT INTO bz_bank (player_name, bz_bux) VALUES (\"" + StoredPlayer.PlayerName + "\", 0);";
- //create command and assign the query and connection from the constructor
- MySqlCommand cmd2 = new MySqlCommand(query2, connection);
- //Execute command
- cmd2.ExecuteNonQuery();
- q.Enqueue(msg.arena("New Player Detected - Player inserted into database."));
- }
- if (this.CloseConnection(q) == true)
- q.Enqueue(msg.arena("Connection closed."));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment