public void KickPlayer(string Reason) { var Disconnect = new Disconnect(); Disconnect.Reason = Reason; Disconnect.Write(this); if (BaseSocket.Connected == true) { BaseSocket.Close(); } BaseStream.Close(); BaseStream.Dispose(); var Values = new Dictionary <string, string>(); // -- Update the PlayerDB. Values.Add("KickCounter", (ServerCore.Database.GetDatabaseInt(CS.LoginName, "PlayerDB", "KickCounter") + 1).ToString()); Values.Add("KickMessage", Reason); ServerCore.Database.Update("PlayerDB", Values, "Name='" + CS.LoginName + "'"); //ServerCore.nh.HandleDisconnect(this); }
/// <summary> /// Performs basic login functions for this client. /// </summary> public void Login() { if (!ServerCore.Database.ContainsPlayer(CS.LoginName)) // -- Create the user in the PlayerDB. { ServerCore.Database.CreatePlayer(CS.LoginName, CS.IP, ServerCore); } CS.LoginName = ServerCore.Database.GetPlayerName(CS.LoginName); if ((ServerCore.Database.GetDatabaseInt(CS.LoginName, "PlayerDB", "Banned") > 0)) { var Disconnecter = new Disconnect(); Disconnecter.Reason = "Banned: " + ServerCore.Database.GetDatabaseString(CS.LoginName, "PlayerDB", "BanMessage"); Disconnecter.Write(this); if (BaseSocket.Connected == true) { BaseSocket.Close(); } BaseStream.Close(); BaseStream.Dispose(); ServerCore.Logger._Log("Info", "Client", "Disconnecting player " + CS.LoginName + ": Player is banned."); return; } //TODO: Load muted, stopped, ect. From PlayerDB. CS.ID = ServerCore.Database.GetDatabaseInt(CS.LoginName, "PlayerDB", "Number"); CS.Stopped = (ServerCore.Database.GetDatabaseInt(CS.LoginName, "PlayerDB", "Stopped") > 0); CS.Global = (ServerCore.Database.GetDatabaseInt(CS.LoginName, "PlayerDB", "Global") > 0); CS.MuteTime = ServerCore.Database.GetDatabaseInt(CS.LoginName, "PlayerDB", "Time_Muted"); CS.LoggedIn = true; CS.PlayerRank = ServerCore.Rankholder.GetRank(ServerCore.Database.GetDatabaseInt(CS.LoginName, "PlayerDB", "Rank")); CS.FormattedName = CS.PlayerRank.Prefix + CS.LoginName + CS.PlayerRank.Suffix; ServerCore.Database.SetDatabase(CS.LoginName, "PlayerDB", "LoginCounter", (ServerCore.Database.GetDatabaseInt(CS.LoginName, "PlayerDB", "LoginCounter") + 1)); ServerCore.Database.SetDatabase(CS.LoginName, "PlayerDB", "IP", CS.IP); CS.CurrentMap = ServerCore.MainMap; // -- Finds our main map, and sends it to the client. CS.CurrentMap.SendMap(this); CS.CurrentMap.Clients.Add(this); // -- Add the client to the map CS.MyEntity = new Entity(ServerCore, CS.CurrentMap, CS.LoginName, (short)(CS.CurrentMap.Map.SpawnX * 32), (short)(CS.CurrentMap.Map.SpawnZ * 32), (short)((CS.CurrentMap.Map.SpawnY * 32) + 51), CS.CurrentMap.Map.SpawnRotation, CS.CurrentMap.Map.SpawnLook); // -- Create the entity.. CS.MyEntity.MyClient = this; CS.CurrentMap.SpawnEntity(CS.MyEntity); // -- Send the client spawn to everyone. CS.CurrentMap.Entities.Add(CS.MyEntity); // -- Add the entity to the map so that their location will be updated. CS.CurrentMap.SendAllEntities(this); ServerCore.Logger._Log("Info", "Client", "Player logged in. (Name = " + CS.LoginName + ")"); Chat.SendGlobalChat(ServerCore, "&ePlayer " + CS.FormattedName + "&e has joined."); Chat.SendClientChat(this, ServerCore.WelcomeMessage); //TODO: CPE ExtPlayerList ServerCore.OnlinePlayers += 1; }