Advertisement
Eiromplays

Untitled

Apr 10th, 2020
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.23 KB | None | 0 0
  1. public void GetHits(UnturnedPlayer player)
  2.         {
  3.             try
  4.             {
  5.                 if (HitsListExist(player))
  6.                 {
  7.                     MySqlConnection connection = CreateConnection();
  8.                     connection.Open();
  9.                     MySqlCommand command = new MySqlCommand("SELECT * FROM DarkWeb_Hits WHERE ID = @ID", connection);
  10.                     command.Parameters.AddWithValue("@ID", player.Player.gameObject.GetComponent<PlayerComponent>().currentPage);
  11.                     command.Prepare();
  12.                     MySqlDataReader reader = command.ExecuteReader();
  13.                     if (reader.Read())
  14.                     {
  15.                         EffectManager.sendUIEffect(12692, 12692, player.CSteamID, true, reader[1].ToString(), "Price: " + reader[3].ToString());
  16.                         connection.Close();
  17.                         reader.Close();
  18.                     }
  19.                     else
  20.                     {
  21.  
  22.                     }
  23.                 }
  24.             }
  25.             catch (Exception ex)
  26.             {
  27.                 Rocket.Core.Logging.Logger.LogException(ex);
  28.             }
  29.         }
  30.  
  31.  
  32.         public bool HitsListExist(UnturnedPlayer player)
  33.         {
  34.             try
  35.             {
  36.                 MySqlConnection connection = CreateConnection();
  37.                 connection.Open();
  38.                 MySqlCommand command = new MySqlCommand("SELECT * FROM DarkWeb_Hits WHERE ID = @ID", connection);
  39.                 command.Parameters.AddWithValue("@ID", player.Player.gameObject.GetComponent<PlayerComponent>().currentPage);
  40.                 command.Prepare();
  41.                 MySqlDataReader reader = command.ExecuteReader();
  42.                 if (reader.Read())
  43.                 {
  44.                     return true;
  45.                 }
  46.                 else
  47.                 {
  48.                     UnturnedChat.Say(player, "No more hits to load");
  49.                     player.Player.gameObject.GetComponent<PlayerComponent>().currentPage--;
  50.                     return false;
  51.                 }
  52.             }
  53.             catch (Exception ex)
  54.             {
  55.                 Rocket.Core.Logging.Logger.LogException(ex);
  56.             }
  57.  
  58.             return false;
  59.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement