Jump to content
ziellos2k

BattleNET - C# library and client for the BattlEye protocol

Recommended Posts

Just wanted to say thanks for creating this, has made creating my OA Server tools alot easier. You should consider putting up a thread about the project on BI Forums too, I just barely found it through github :)

You're free to do so yourself. ;)

  • Like 1

Share this post


Link to post
Share on other sites

Great work Sawyer, having one problem: Getting disconnected (Failed to login) when trying to login. Password is definitely admin(rcon) password, as set in the config. Am using Bliss server versions: 1.62.97771 and 1.7.2.6.

Have tried in my own code and using the supplied BattleNET Client.exe

Any help would be great, I am trying to create an automated system and send messages to the occupants in the server..

Share this post


Link to post
Share on other sites

Hello, I would like to let you know this works fine in Linux, MacOSX and Windows using mono.

Anyone know how can I ban someone? Only way I managed to ban someone right now is by typing the command manually "ban "+player.playerNumber, but the message i put after it doesnt get displayed (or saved for that matter)

Share this post


Link to post
Share on other sites

ban [player #] [time in minutes] [reason]

Edited by Sawyer
  • Like 1

Share this post


Link to post
Share on other sites

Player # is the number on the player list by the way, not the GUID or the Player ID.

Took me some time to figure this out...

  • Like 1

Share this post


Link to post
Share on other sites

Has anyone used this lib to create a simple command line tool for issuing a single command and exiting? Something you'd call with something like:

tool.exe -p aasdf -i 123.123.123.123:2302 -c 'say -1 blah blah'

or

tool.exe -p aasdf -i 123.123.123.123:2302 -c 'players'

which would just dump the list of players to stdout and exit?

Edited by Hohlraum

Share this post


Link to post
Share on other sites

Has anyone used this lib to create a simple command line tool for issuing a single command and exiting? Something you'd call with something like:

tool.exe -p aasdf -i 123.123.123.123:2302 -c 'say -1 blah blah'

or

tool.exe -p aasdf -i 123.123.123.123:2302 -c 'players'

which would just dump the list of players to stdout and exit?

I will probably include something like this in the next version of DaRT.

Output will be to a file for now which you can specifiy in the parameters.

Of course, GUI won't start if startup parameters are specified.

Edited by DomiStyle

Share this post


Link to post
Share on other sites

Has anyone used this lib to create a simple command line tool for issuing a single command and exiting? Something you'd call with something like:

tool.exe -p aasdf -i 123.123.123.123:2302 -c 'say -1 blah blah'

or

tool.exe -p aasdf -i 123.123.123.123:2302 -c 'players'

which would just dump the list of players to stdout and exit?

I actually did this while I was running my server on linux. I used it to notify users about restarts in a simple bash script. Unfortunately the lib itself doesn't know whether a message has been send and received so you would need to check in your own app the output by the server.


send(msg);
while(!serverout.Contains(msg)) {
sleep(2000);
send(msg);
}
// exit

or something like that. :)

Share this post


Link to post
Share on other sites

Hi,

I've been using your project for some time now in my little programming projects, thanks a lot for the effort put into it! I doubt it's an issue on your end, but when the server is busy, it doesn't seem to catch all logs. How do I know this, chat doesn't seem to get through at all. Gotcha Antihack is having the same issue, but I'm not sure if they use your library for their data. I'm starting to think it's a Battleye issue, but perhaps you've experienced this before.

I'm in the process of making a command line interface for use inside the server (request server info, request time till restart, maybe vote kick, etc.), but it's pretty worthless if the chat commands don't get through.

Thanks once again for your effort!

Share this post


Link to post
Share on other sites

Are you talking about the server not sending player login messages to the connected RCon client (BattlEye -> BattleNET)? If so, this is indeed not a problem with BattleNET but with BattlEye. When the server is under (heavy) load it will start dropping packets (which UDP doesn't handle unfortunately) while probably showing a yellow or red chain in game.

Data being sent by BattleNET towards the game server (BattleNET -> BattlEye) will probably be dropped as well when it's under (heavy) load. I'm planning to look at this soonish but for now please refer to my previous post. :)

EDIT: You can track progress on the latter issue @ https://github.com/ziellos2k/BattleNET/issues/9 :)

Edited by ziellos2k

Share this post


Link to post
Share on other sites

Thanks for the reply,

Yesterday evening chat messages sometimes had a delay of 50 minutes before being received by Gotcha (and my program using your library). I'm not talking about login messages, but actual *chat* messages. When the server gets to about ~10 players, it seems to drop all kinds of packages, not just chat messages. But the funny thing is that the chat does seem to get through, sometimes with a very long delay.

Share this post


Link to post
Share on other sites

Hey I'm using your API to develop a small RCon tool, built-in to my database manager.

I'm struggling with fetching the player list.

I can execute the commands etc.

But it's taking the message received from the server and transferring it into a variable.

It'd be great if someone could point me in the right direction with this.

EDIT: Managed to get the text into a string, now I need to convert this into something a DataGrid will show :|

Edited by Sutoko

Share this post


Link to post
Share on other sites

Hmm that's odd. Can you try and see what happens when you're using the official RCon client? -> http://battleye.com/...oads/BERCon.exe

I found what was causing the massive delay, it had to do with me logging every setVariable and setVariableVar function. It probably caused a massive overflow of data (and long log files), which in turn caused the delay. Switching those two spammers off solved the issue, chat messages are received near instant now!

Share this post


Link to post
Share on other sites

EDIT: Managed to get the text into a string, now I need to convert this into something a DataGrid will show :|

Use regular expressions -> http://www.dotnetperls.com/regex

I found what was causing the massive delay, it had to do with me logging every setVariable and setVariableVar function. It probably caused a massive overflow of data (and long log files), which in turn caused the delay. Switching those two spammers off solved the issue, chat messages are received near instant now!

Glad you got it fixed. :)

Edited by ziellos2k

Share this post


Link to post
Share on other sites

Hey I'm using your API to develop a small RCon tool, built-in to my database manager.

I'm struggling with fetching the player list.

I can execute the commands etc.

But it's taking the message received from the server and transferring it into a variable.

It'd be great if someone could point me in the right direction with this.

EDIT: Managed to get the text into a string, now I need to convert this into something a DataGrid will show :|

Hi,

This is how I solved that (it's rather ugly and I hate regex's, so here goes:)

In your "HandleMessage" event function:


String timeMessage = DateTime.Now.ToString("hh:mm:ss") + " - " + args.Message.Trim();
int tryParse = 0;
// If this is the message for players
if (Int32.TryParse(split[2], out tryParse)) {
bMessage = new SurvivorMessage(timeMessage);
}

The BattleyeMessage and SurvivorMessage classes looks like this:



public class BattleyeMessage {

public String rawMessage { get; set; }
public String time { get; set; }

public BattleyeMessage(String raw) {
String[] split = raw.Split(' ');
this.time = split[0];
this.rawMessage = raw;
}
}


public class SurvivorMessage : BattleyeMessage {

public int number { get; set; }
public String ip { get; set; }
public String port { get; set; }
public int ping { get; set; }
public String guid { get; set; }
public String username { get; set; }

public SurvivorMessage(String raw)
: base(raw) {
String[] split = raw.Split(new char[1]{' '}, StringSplitOptions.RemoveEmptyEntries);
this.number = Int32.Parse(split[2]);
this.ip = split[3].Split(':')[0];
this.port = split[3].Split(':')[1];

this.ping = Int32.Parse(split[4]);
this.guid = split[5];

// Some usernames contain spaces .. bastards
for (int i = 6; i < split.Length; i++) {
this.username += split[i] + " ";
}
// Remove trailing space
this.username = this.username.Trim();
}
}

This should probably give you an idea of how you should solve this problem.

Edited by Wotuu

Share this post


Link to post
Share on other sites

I'd say, go with regex. It takes a some time to get used to but it's quite useful. You'd probably be able to do all that in the above post with pretty much a single line of code. :)

Share this post


Link to post
Share on other sites

It's no coincidence that pretty much all modern programming languages come with regex support built in. Pretty much the "go to" for any kind of text parsing/processing.

Share this post


Link to post
Share on other sites

It's not necessary at all to use regex for such a simple task.

A much simpler solution is to create a StringReader and split each line like this:


String[] items = line.Split(new char[] { ' ' }, 5, StringSplitOptions.RemoveEmptyEntries);

You can then grab each item by increasing the index, for example:


String name = items[4];

Of course, both solutions are possible.

Share this post


Link to post
Share on other sites

Small update. Might break your current implementation due to the removal of the interface crap. Simply replace IBattleNET with BattlEyeClient. :)

Share this post


Link to post
Share on other sites

Yeah I know Regex's are probably a better solution, but I couldn't be arsed :].

Share this post


Link to post
Share on other sites

Small update. Might break your current implementation due to the removal of the interface crap. Simply replace IBattleNET with BattlEyeClient. :)

Grr. :( ;)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×