Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- TcpClient tcpClient = (TcpClient)client;
- MyClient myClient = new MyClient(tcpClient);
- String fromClient;
- commands = new mudcommands();
- Console.WriteLine(myClient.IPAddress + " has connected to the server.\n");
- bool isConnected = false;
- String input = "";
- string username = "";
- String password = "";
- while (input.Length == 0 && myClient.IsAlive())
- {
- myClient.SendToClient("Welcome to The Clone Wars Era, we are currently not open for mudding at this time, If you are an admin or a builder, please type in your username and password, else please try again another time.\r\n");
- myClient.SendToClient("Username: ");
- if (!myClient.IsAlive())
- {
- return;
- }
- input = myClient.toServer().Trim();
- DataTable Username = DBclass.GetInstance().DoSql("Select name from players where name='" + input + "'");
- try
- {
- username = Username.Rows[0].Field<string>("name");
- }
- catch (Exception )
- {
- throw;
- }
- if (input.ToLower() == username)
- {
- if (true)
- {
- myClient.SendToClient("Password: ");
- password = myClient.toServer().Trim();
- DataTable Password = DBclass.GetInstance().DoSql("Select Password from players where Password='" + password + "'");
- if (password == Password.Rows[0].Field<string>("Password").ToString())
- {
- lock (_newClientNumber)
- {
- while (clientlist.ContainsValue(clientnumber))
- {
- clientnumber++;
- }
- clientlist.Add(myClient, clientnumber);
- }
- DataTable ID = DBclass.GetInstance().DoSql("Select ID from players where name='" + username + "'");
- myClient.playerID = ID.Rows[0].Field<int>("ID");
- int playerloc = players.getPlayerLocation(players.playerID(username));
- myClient.SendToClient("You are logged in under the username " + input);
- myClient.SendToClient("> ");
- isConnected = true;
- //commands.look();
- }
- else
- {
- myClient.SendToClient("Password failed: please try again.");
- tcpClient.Close();
- }
- }
- }
- else
- {
- myClient.SendToClient("Username failed, if you feel you have recieved this in error, please contact Joshua at Rpgdudester@hotmail.com ");
- tcpClient.Close();
- }
- }
- while (isConnected == true && myClient.IsAlive())
- {
- fromClient = myClient.toServer().Trim();
- myClient.SendToClient(input + " > ");
- string[] split = fromClient.ToLower().Split(' ');
- switch (split[0])
- {
- case "say":
- foreach (MyClient sendto in clientlist.Keys)
- {
- sendto.SendToClient(input + " said " + fromClient.Remove(0, 4));
- }
- break;
- case "quit":
- myClient.SendToClient("You have left the Clone Wars and returned to a peasant's life.");
- isConnected = false;
- break;
- //this area is for the movement commands, added in on 03/01/2010 by Jpb
- case "north":
- commands.Move(fromClient);
- break;
- case "south":
- commands.Move(fromClient);
- break;
- case "west":
- commands.Move(fromClient);
- break;
- case "east":
- commands.Move(fromClient);
- break;
- case "test":
- myClient.SendToClient("This is a test for " + input);
- break;
- case "look":
- commands.look();
- break;
- default:
- myClient.SendToClient("What are you trying to do?");
- break;
- }
- }
- clientlist.Remove(myClient);
- tcpClient.Close();
- Console.WriteLine(myClient.IPAddress + " has logged out of the server.\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement