Guest User

Untitled

a guest
Oct 27th, 2017
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.55 KB | None | 0 0
  1. [Command("login", "[Usage] /login Password")]
  2.         public void LoginCommand(Client player, string password)
  3.         {
  4.             var connection = new MySqlConnection(myConnectionString);
  5.             var command = connection.CreateCommand();
  6.             var name = API.getPlayerName(player);
  7.  
  8.             connection.Open();
  9.             command.CommandText = "SELECT * FROM AccountsTable WHERE username = @username AND password = @password";
  10.             command.Prepare();
  11.  
  12.             command.Parameters.AddWithValue("@username", name);
  13.             command.Parameters.AddWithValue("@password", password);
  14.  
  15.             var reader = command.ExecuteReader();
  16.  
  17.             if (reader.HasRows && reader.Read())
  18.             {
  19.                 try
  20.                 {
  21.                     using (connection = new MySqlConnection(myConnectionString))
  22.                     {
  23.                         connection.Open();
  24.                         using (command = connection.CreateCommand())
  25.                         {
  26.  
  27.                             command.CommandText = "SELECT password FROM AccountsTable WHERE username=@username";
  28.                             command.Prepare();
  29.  
  30.                             command.Parameters.AddWithValue("@username", name);
  31.  
  32.                             pInfo.Level = reader.GetInt32("level");
  33.                             pInfo.Money = reader.GetInt32("cash");
  34.                             pInfo.Bank = reader.GetInt32("bank");
  35.                             pInfo.Score = reader.GetInt32("score");
  36.                             pInfo.Team = reader.GetString("team");
  37.                             pInfo.Skill = reader.GetString("skill");
  38.                             pInfo.Class = reader.GetInt32("pclass");
  39.                             pInfo.Skin = reader.GetString("pskin");
  40.                             pInfo.AdminLevel = reader.GetInt32("adminlevel");
  41.                             pInfo.Health = reader.GetInt32("health");
  42.                             pInfo.Armour = reader.GetInt32("armour");
  43.                             pInfo.Wantedlevel = reader.GetInt32("wantedlevel");
  44.                             pInfo.Jailed = reader.GetInt32("jailed");
  45.                             pInfo.House = reader.GetInt32("houseowned");
  46.                             pInfo.LifeInsurance = reader.GetInt32("lifeinsurance");
  47.                             pInfo.JailHour = reader.GetInt32("jailhour");
  48.                             pInfo.JailMinute = reader.GetInt32("jailminute");
  49.                             pInfo.Earnings = reader.GetInt32("earnings");
  50.                             pInfo.Taxes = reader.GetInt32("taxes");
  51.                             pInfo.TaxDay = reader.GetInt32("taxesday");
  52.                             pInfo.Donor = reader.GetInt32("donor");
  53.                             pInfo.HealthInsurance = reader.GetInt32("healthins");
  54.                             pInfo.DaysAlive = reader.GetInt32("pdaysalive");
  55.                             pInfo.HoursAlive = reader.GetInt32("phoursalive");
  56.                             pInfo.MinutesAlive = reader.GetInt32("pminutesalive");
  57.                             pInfo.SecondsAlive = reader.GetInt32("psecondsalive");
  58.  
  59.                             API.sendChatMessageToPlayer(player, COLOR_SKYBLUE + "[Bot Eva] " + COLOR_WHITE + "You have " + COLOR_GREEN + "Successfully " + COLOR_WHITE + "Logged in.");
  60.  
  61.                             pInfo.LoggedIn = true;
  62.  
  63.                             if (pInfo.AdminLevel >= 1)
  64.                             {
  65.                                 API.sendChatMessageToPlayer(player, "Welcome Back " + COLOR_PINK + "Admin" + COLOR_WHITE + "!");
  66.  
  67.                             }
  68.                             else
  69.                             {
  70.                                 API.sendChatMessageToPlayer(player, "Logged In As A " + COLOR_GREEN + "Registered " + COLOR_WHITE + "Player!");
  71.  
  72.                             }
  73.  
  74.                             API.setEntityDimension(player, 0);
  75.  
  76.                             if (pInfo.Team == "TEAM_CIVILIAN" || pInfo.Skill == "SKILL_NONE")
  77.                             {
  78.  
  79.                                 player.position = SpawnPositions[Rnd.Next(SpawnPositions.Count)];
  80.  
  81.  
  82.                                 //local classid = pInfo.Class;
  83.                                 //player: SetModel(PedSkins[classid]["Spawn_ModelName"])
  84.                                 API.givePlayerWeapon(player, WeaponHash.Unarmed, 1, true, true);
  85.                                 API.givePlayerWeapon(player, WeaponHash.Knife, 1, false, true);
  86.                                 API.givePlayerWeapon(player, WeaponHash.Pistol50, 100, false, true);
  87.                                 API.givePlayerWeapon(player, WeaponHash.MicroSMG, 100, false, true);
  88.  
  89.                                 var WantedLevel = pInfo.Wantedlevel;
  90.  
  91.                                 if (WantedLevel >= 1)
  92.                                 {
  93.  
  94.                                     //pInfo.WantedLevelCoolerMinute = 60;
  95.                                     API.sendChatMessageToPlayer(player, "Wanted Level - " + WantedLevel);
  96.  
  97.  
  98.                                 }
  99.  
  100.  
  101.                                 if (pInfo.JailHour >= 1 || pInfo.JailMinute >= 1)
  102.                                 {
  103.  
  104.                                     player.position = JailSpawn[Rnd.Next(JailSpawn.Count)];
  105.  
  106.  
  107.                                     API.sendChatMessageToPlayer(player, "Welcome Back To " + COLOR_SKYBLUE + "Jail " + COLOR_WHITE + "Don't Drop The Soap! " + COLOR_RED + "No Random Brawls In Jail" + COLOR_WHITE + ". \nJail Time " + COLOR_SKYBLUE + "" + pInfo.JailHour + " " + COLOR_YELLOW + "Hours, " + COLOR_SKYBLUE + "" + pInfo.JailMinute + " " + COLOR_YELLOW + "Minutes");
  108.                                     //SetPlayerWantedLevel(player.id, 0)
  109.                                     pInfo.Wantedlevel = 0;
  110.  
  111.                                     pInfo.Jailed = 1;
  112.  
  113.                                 }
  114.  
  115.  
  116.                                 else if (pInfo.Team == "TEAM_LAW" || pInfo.Skill == "SKILL_COP")
  117.                                 {
  118.                                     player.position = new Vector3(451.09948730469f, -974.49481201172f, 29.689586639404f);
  119.  
  120.  
  121.                                     API.sendChatMessageToPlayer(player, "You Are A " + COLOR_LIGHTBLUE + "Law Enforcement Agent " + COLOR_YELLOW + "Protect " + COLOR_WHITE + "The City By Catching " + COLOR_ORANGE + "Criminals!");
  122.  
  123.                                     //local classid = pInfo.Class;
  124.                                     //player: SetModel(PedSkins[classid]["Spawn_ModelName"])
  125.  
  126.                                     API.givePlayerWeapon(player, WeaponHash.Unarmed, 1, true, true);
  127.                                     API.givePlayerWeapon(player, WeaponHash.Nightstick, 1, false, true);
  128.                                     API.givePlayerWeapon(player, WeaponHash.HeavyPistol, 100, false, true);
  129.                                     API.givePlayerWeapon(player, WeaponHash.AssaultSMG, 100, false, true);
  130.  
  131.                                 }
  132.                             }
  133.                             string saltedPassword = (string)command.ExecuteScalar();
  134.  
  135.                             PasswordDerivation.Verify(saltedPassword, password);
  136.                         }
  137.                     }
  138.                 }
  139.                 catch (Exception err) { Console.WriteLine(err); }
  140.                 finally { connection.Close(); }
  141.             }
  142.             else
  143.             {
  144.  
  145.                 API.sendChatMessageToPlayer(player, COLOR_SKYBLUE + "[Bot Eva] " + COLOR_RED + "You Are Not Registered. Register First!");
  146.  
  147.             }
  148.  
  149.         }
Add Comment
Please, Sign In to add comment