private void HandleMessage(BattlEyeMessageEventArgs args) { if (args.Message != null) { if (args.Message.StartsWith("Player #") && args.Message.EndsWith("(unverified)")) { string message = args.Message; string[] array = message.Split(new char[] { ' ' }, 6, StringSplitOptions.RemoveEmptyEntries); string text = array[1].Replace("#", ""); string text2 = array[2]; string text3 = array[5]; Console.WriteLine(string.Concat(new string[] { "#", text, " ", text2, " with GUID ", text3, " joined the game." })); } } }
private static void BattlEyeMessageReceived(BattlEyeMessageEventArgs args) { //if (args.Id == playerListId) //{ // playerList = args.Message; //} Console.WriteLine(args.Message); }
private void HandleMessage(BattlEyeMessageEventArgs args) { if (args.Message != null) { if (args.Message.StartsWith("Player #") && args.Message.EndsWith("(unverified)")) { string message = args.Message; string[] array = Regex.Split(message, " - GUID: "); string text = array[0].Replace("Player #", ""); this.write("Debug1: " + text, ConsoleColor.Yellow); string numPlayers2 = text.Split(' ')[0]; this.write("Debug2: " + numPlayers2, ConsoleColor.Yellow); int numPlayers1 = Int32.Parse(numPlayers2); numPlayers = numPlayers1 + 1; string[] array2 = text.Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries); string id = array2[0]; string text2 = array2[1]; string guid = array[1].Replace(" (unverified)", ""); this.write(text2 + " tried to connect...", ConsoleColor.DarkCyan); if (this.isWhitelisted(guid, text2)) { this.write(" " + text2 + " is whitelisted.", ConsoleColor.DarkCyan); } else { this.write(" kicking " + text2, ConsoleColor.Yellow); this.kick(id); } } else if (args.Message.StartsWith("Players on server:")) { this.playerResult = args.Message + "\n"; } else if (args.Message.StartsWith("RCon admin #") && args.Message.EndsWith("logged in")) { Console.WriteLine(args.Message); } } }
void battlEyeClient_BattlEyeMessageReceived(BattlEyeMessageEventArgs args) { try { var message = new ServerMessage(args.Id, args.Message); lock (_lock) { ProcessMessage(message); } } catch (Exception e) { _log.Error(e); } }
private static void DumpMessage(BattlEyeMessageEventArgs args) { // new clien tobj DayzClient client = new DayzClient(); // echo message to console Console.WriteLine(args.Message); try { Match matchString; // Grab the user data if it matches our regular expresion - Thanks to mmmmmkay for this Regex! matchString = Regex.Match(args.Message, @"Verified GUID\s\W(?<guid>.+)\W\sof player #(?<player_id>[0-9]{1,3})\s(?<user>.+)", RegexOptions.IgnoreCase); if (matchString.Success) { client.GUID = matchString.Groups["guid"].Value; client.playerNo = Convert.ToInt32(matchString.Groups["player_id"].Value); client.UserName = matchString.Groups["user"].Value; // did we get a valid result? verify if (client.GUID != null && client.UserName != null) { if (VerifyWhiteList(client) == false) { // user is not white listed kick and send message KickPlayer(client); // log event client.logType = DayzClient.LogTypes.Kick; LogPlayer(client); } else { // display welcome message WelcomeMessage(client); // log event; client.logType = DayzClient.LogTypes.Success; LogPlayer(client); } } } } catch (Exception ex) { // do nothing } finally { client = null; } }
private static void BattlEyeMessageReceived(BattlEyeMessageEventArgs args) { Console.WriteLine(args.Message); }
private static void DumpMessage(BattlEyeMessageEventArgs args) { Console.WriteLine(args.Message); }
void BattlEyeMessageReceived(BattlEyeMessageEventArgs args) { if (OnBeMessageReceivedEvent != null) { var message = new Message(args.Message, args.Id); if (args.Id != 256) { _commandResponses[args.Id] = message; } else { OnBeMessageReceivedEvent(message); } } }
private void HandleMessage(BattlEyeMessageEventArgs args) { string message = args.Message; if (_initialized) { // Message filtering if (args.Id != 256) this.Received(args.Id, message); else { if (_form != null) { // Global chat if (message.StartsWith("(Global)")) { if (Settings.Default.showGlobalChat) _form.Log(message, LogType.GlobalChat, this.IsCall(message)); } // Side chat else if (message.StartsWith("(Side)")) { if (Settings.Default.showSideChat) _form.Log(message, LogType.SideChat, this.IsCall(message)); } // Direct chat else if (message.StartsWith("(Direct)")) { if (Settings.Default.showDirectChat) _form.Log(message, LogType.DirectChat, this.IsCall(message)); } // Vehicle chat else if (message.StartsWith("(Vehicle)")) { if (Settings.Default.showVehicleChat) _form.Log(message, LogType.VehicleChat, this.IsCall(message)); } // Command chat else if (message.StartsWith("(Command)")) { if (Settings.Default.showCommandChat) _form.Log(message, LogType.CommandChat, this.IsCall(message)); } // Group chat else if (message.StartsWith("(Group)")) { if (Settings.Default.showGroupChat) _form.Log(message, LogType.GroupChat, this.IsCall(message)); } // Unknown chat else if (message.StartsWith("(Unknown)")) { if (Settings.Default.showUnknownChat) _form.Log(message, LogType.UnknownChat, this.IsCall(message)); } else if (message.StartsWith("Player #")) { if (_pending != "" && message.EndsWith(" " + _pending + " disconnected")) _pendingLeft = true; if (Settings.Default.refreshOnJoin && message.EndsWith("disconnected") && !_form.pendingPlayers) { Thread thread = new Thread(new ThreadStart(_form.thread_Player)); thread.IsBackground = true; thread.Start(); } // Connect/disconnect/kick/ban messages if (Settings.Default.showPlayerConnectMessages) _form.Log(message, LogType.Console, false); } else if (message.StartsWith("Verified GUID (")) { // GUID verification messages if (Settings.Default.showVerificationMessages) _form.Log(message, LogType.Console, false); if (Settings.Default.refreshOnJoin && !_form.pendingPlayers) { Thread thread = new Thread(new ThreadStart(_form.thread_Player)); thread.IsBackground = true; thread.Start(); } } else if (message.StartsWith("RCon admin #")) { // Admin login if (Settings.Default.showAdminMessages && message.EndsWith("logged in")) _form.Log(message, LogType.Console, false); else if (Settings.Default.showAdminChat) _form.Log(message, LogType.AdminChat, false); } else if (message.StartsWith("Failed to open") || message.StartsWith("Incompatible filter file")) { // Log errors if (Settings.Default.showLogErrors) _form.Log(message, LogType.Console, false); } // Scripts log else if (message.StartsWith("Scripts Log:")) { if (Settings.Default.showScriptsLog && !this.ShallFilter(message)) _form.Log(message, LogType.ScriptsLog, false); } // CreateVehicle log else if (message.StartsWith("CreateVehicle Log:")) { if (Settings.Default.showCreateVehicleLog && !this.ShallFilter(message)) _form.Log(message, LogType.CreateVehicleLog, false); } // DeleteVehicle log else if (message.StartsWith("DeleteVehicle Log:")) { if (Settings.Default.showDeleteVehicleLog && !this.ShallFilter(message)) _form.Log(message, LogType.DeleteVehicleLog, false); } // PublicVariable log else if (message.StartsWith("PublicVariable Log:")) { if (Settings.Default.showPublicVariableLog && !this.ShallFilter(message)) _form.Log(message, LogType.PublicVariableLog, false); } // PublicVariableVal log else if (message.StartsWith("PublicVariable Value Log:")) { if (Settings.Default.showPublicVariableValLog && !this.ShallFilter(message)) _form.Log(message, LogType.PublicVariableValLog, false); } // RemoteExec log else if (message.StartsWith("RemoteExec Log:")) { if (Settings.Default.showRemoteExecLog && !this.ShallFilter(message)) _form.Log(message, LogType.RemoteExecLog, false); } // RemoteControl log else if (message.StartsWith("RemoteControl Log:")) { if (Settings.Default.showRemoteControlLog && !this.ShallFilter(message)) _form.Log(message, LogType.RemoteControlLog, false); } // SetDamage log else if (message.StartsWith("SetDamage Log:")) { if (Settings.Default.showSetDamageLog && !this.ShallFilter(message)) _form.Log(message, LogType.SetDamageLog, false); } // SetVariable log else if (message.StartsWith("SetVariable Log:")) { if (Settings.Default.showSetVariableLog && !this.ShallFilter(message)) _form.Log(message, LogType.SetVariableLog, false); } // SetVariableVal log else if (message.StartsWith("SetVariable Value Log:")) { if (Settings.Default.showSetVariableValLog && !this.ShallFilter(message)) _form.Log(message, LogType.SetVariableValLog, false); } // SetPos log else if (message.StartsWith("SetPos Log:")) { if (Settings.Default.showSetPosLog && !this.ShallFilter(message)) _form.Log(message, LogType.SetPosLog, false); } // AddMagazineCargo log else if (message.StartsWith("AddMagazineCargo Log:")) { if (Settings.Default.showAddMagazineCargoLog && !this.ShallFilter(message)) _form.Log(message, LogType.AddMagazineCargoLog, false); } // AddWeaponCargo log else if (message.StartsWith("AddWeaponCargo Log:")) { if (Settings.Default.showAddWeaponCargoLog && !this.ShallFilter(message)) _form.Log(message, LogType.AddWeaponCargoLog, false); } // AddBackpackCargo log else if (message.StartsWith("AddBackpackCargo Log:")) { if (Settings.Default.showAddBackpackCargoLog && !this.ShallFilter(message)) _form.Log(message, LogType.AddBackpackCargoLog, false); } // AttachTo log else if (message.StartsWith("AttachTo Log:")) { if (Settings.Default.showAttachToLog && !this.ShallFilter(message)) _form.Log(message, LogType.AttachToLog, false); } // MPEventHandler log else if (message.StartsWith("MPEventHandler Log:")) { if (Settings.Default.showMPEventHandlerLog && !this.ShallFilter(message)) _form.Log(message, LogType.MPEventHandlerLog, false); } // TeamSwitch log else if (message.StartsWith("TeamSwitch Log:")) { if (Settings.Default.showTeamSwitchLog && !this.ShallFilter(message)) _form.Log(message, LogType.TeamSwitchLog, false); } // SelectPlayer log else if (message.StartsWith("SelectPlayer Log:")) { if (Settings.Default.showSelectPlayerLog && !this.ShallFilter(message)) _form.Log(message, LogType.SelectPlayerLog, false); } // WaypointCondition log else if (message.StartsWith("WaypointCondition Log:")) { if (Settings.Default.showWaypointConditionLog && !this.ShallFilter(message)) _form.Log(message, LogType.WaypointConditionLog, false); } // WaypointStatement log else if (message.StartsWith("WaypointStatement Log:")) { if (Settings.Default.showWaypointStatementLog && !this.ShallFilter(message)) _form.Log(message, LogType.WaypointStatementLog, false); } else { if (_form != null) _form.Log("UNKNOWN: " + message, LogType.Debug, false); } } } } }
private void BattlEyeMessageReceived(BattlEyeMessageEventArgs args) { if (rconServerConsole) { string message = args.Message; if ( message.StartsWith("Player #") || message.StartsWith("Verified GUID (") ) { string msg = DateTime.Now.ToString("HH:mm:ss") + " BattlEye Server: " + message; AddLineQueueLine("server_console", msg); } } }
/* DUMP MESSAGE EVENT */ private void DumpMessage(BattlEyeMessageEventArgs args) { doDumpMessage(args.Message); }
private void OutputMessage(BattlEyeMessageEventArgs args) { this.Log.Info(args.Message); }
private void ParsePlayerList(BattlEyeMessageEventArgs args) { string[] players = args.Message.Split('\n'); lock (PlayerList) { PlayerList.Clear(); // players start on line 3, ends 1 before end for (int i = 3; i < players.Length - 1; i++) { string[] playerString = players[i].Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); PlayerInfo player = new PlayerInfo(); player.ID = int.Parse(playerString[0]); player.IP = playerString[1].Split(':')[0]; player.GUID = playerString[3].Replace("(OK)", ""); player.Name = string.Join(" ", playerString, 4, playerString.Length - 4).Replace(" (Lobby)", ""); PlayerList.Add(player.ID, player); Logging.WriteServerLine( String.Format("Got player: #{0} - {1} ({2})", player.ID, player.Name, player.IP), serverID.ToString()); } } }
private void MessageFromServerEvent(BattlEyeMessageEventArgs args) { //Logging.WriteFancyLine("SERVER {0}: {1}", serverID, args.Message); //return; //LastMessageRecieved = DateTime.Now; try { if (args.Message.Contains(") has been kicked by BattlEye: Global Ban #")) // Probably no good IP either! { string help = args.Message.Substring(args.Message.IndexOf('#') + 1); int ID = int.Parse(help.Split(' ')[0]); string name = ""; help = help.Substring(ID.ToString().Length + 1); name = help.Substring(0, help.IndexOf(" (")); PlayerInfo p = GetPlayerByName(name); _beClient.SendCommand("addban " + p.IP + " -1 Previous global ban"); _beClient.SendCommand(BattlEyeCommand.LoadBans); } else if (args.Message.StartsWith("Player #")) // Connect or disconnect! { // :27 BattlEye Server: Player #28 NeRo (212.37.167.4:2304) connected // :42 BattlEye Server: Player #57 johnjuanita disconnected string help = args.Message.Substring(args.Message.IndexOf('#') + 1); int ID = int.Parse(help.Split(' ')[0]); string name = ""; if (args.Message.EndsWith("disconnected")) { help = help.Substring(ID.ToString().Length + 1); name = help.Substring(0, help.LastIndexOf(" disconnected")); Logging.WriteServerLine( String.Format("Player #{0} - \"{1}\" disconnected from the server.", ID, name), serverID.ToString(), ConsoleColor.Gray); if (PlayerList.ContainsKey(ID)) { if (OnPlayerDisconnect != null) OnPlayerDisconnect(PlayerList[ID]); PlayerList.Remove(ID); } } else if (args.Message.EndsWith("connected")) { help = help.Substring(ID.ToString().Length + 1); name = help.Substring(0, help.LastIndexOf('(') - 1); //name = args.Message.Substring(args.Message.IndexOf('#') + 2 + ID.ToString().Length, args.Message.LastIndexOf('(') - 2); string IP = args.Message.Split('(')[1].Split(')')[0].Split(':')[0]; Logging.WriteServerLine(String.Format("New player connected: #{0} - {1} ({2})", ID, name, IP), serverID.ToString()); PlayerInfo p = new PlayerInfo(); p.ID = ID; p.Name = name; p.IP = IP; if (PlayerList.ContainsKey(ID)) PlayerList.Remove(ID); PlayerList.Add(ID, p); if (OnPlayerConnect != null) OnPlayerConnect(p); } } else if (args.Message.StartsWith("Verified GUID")) // There's our GUID! { // Verified GUID (3d22d90cf76ff44d6b5572d33605dbe5) of player #42 Harvey string help = args.Message.Substring(args.Message.IndexOf('#') + 1); int ID = int.Parse(help.Split(' ')[0]); string GUID = args.Message.Split('(')[1].Split(')')[0]; if (PlayerList.ContainsKey(ID)) { PlayerInfo player = PlayerList[ID]; player.GUID = GUID; //Logging.WriteFancyLine("#" + serverID + ": PLAYER GUID: " + ID + "," + GUID); Logging.WriteServerLine( String.Format("Got GUID for player #{0} - {1} ({2})", ID, player.Name, player.IP), serverID.ToString()); if (OnPlayerGUID != null) OnPlayerGUID(player); } } else if (args.Message.StartsWith("Players on server:")) // Player list result { ParsePlayerList(args); } else { } // Check for chat message int chatType = -1; if (args.Message.StartsWith("(Global)")) chatType = 0; else if (args.Message.StartsWith("(Side)")) chatType = 1; else if (args.Message.StartsWith("(Group)")) chatType = 3; else if (args.Message.StartsWith("(Vehicle)")) chatType = 4; else if (args.Message.StartsWith("(Direct)")) chatType = 5; if (chatType > -1) { string name = args.Message.Substring(0, args.Message.IndexOf(':')).Substring(args.Message.IndexOf(')') + 2); string message = args.Message.Substring(args.Message.IndexOf(':') + 2); PlayerInfo player = GetPlayerByName(name); //:28 BattlEye Server: (Direct) Emil: Where's the car? //string name = args.Message.Substring(args.Message.IndexOf(')') + 2, args.Message.IndexOf(':')); //string message = args.Message.Substring(args.Message.IndexOf(':') + 2); //Logging.WriteFancyLine("#" + serverID + ": <" + chatType + "> " + name + ": " + message); Logging.WriteServerLine(String.Format("<{0}> {1}: {2}", chatType, name, message), serverID.ToString()); if (player != null) { if (player.GUID == null) return; using (DatabaseClient dbClient = Program.DBManager.GetGlobalClient()) { dbClient.AddParameter("server_id", serverID); dbClient.AddParameter("guid", player.GUID); dbClient.AddParameter("name", player.Name); dbClient.AddParameter("ip", player.IP); dbClient.AddParameter("chat_type", chatType); dbClient.AddParameter("text", message); dbClient.ExecuteQuery( "INSERT INTO chatlog VALUES(@server_id,NOW(),@guid,@name,@ip,@chat_type,@text)"); } if (OnPlayerChat != null) OnPlayerChat(player, message, chatType); } if (message.StartsWith("/")) // Command? { string[] commandArguments = message.Split(' '); string command = commandArguments[0].ToLower().Replace("/", ""); switch (command) { case "testcmd": _beClient.SendCommand(BattlEyeCommand.Say, "-1 Test command by AWA!"); break; case "players": _beClient.SendCommand(BattlEyeCommand.Players); break; case "ts": _beClient.SendCommand(BattlEyeCommand.Say, player.ID + " The TeamSpeak address is ts.awkack.org:9990."); break; case "help": _beClient.SendCommand(BattlEyeCommand.Say, String.Format("{0} Available commands: ", player.ID)); _beClient.SendCommand(BattlEyeCommand.Say, String.Format("{0} /help - shows available commands", player.ID)); _beClient.SendCommand(BattlEyeCommand.Say, String.Format("{0} /ts - shows the teamspeak address", player.ID)); break; } } } } // Lack of this f*****g error handling has caused so much pain in my ass (error handled in BattleNET and disconnection) catch (Exception x) { Logging.WriteFancyLine( String.Format("Error in message, content: \"{0}\"\r\n{1}", args.Message, x.ToString()), ConsoleColor.Red); } // _beClient.SendCommand(BattlEyeCommand.Say, "-1 ... wants to be kicked!"); }