Post by Anatoly on Apr 20, 2017 18:17:07 GMT 2
namespace EEBot
{
class Program
{
public static Client _client;
public static Connection _connection;
public static string roomid = "roomid";
static void Main(string[] args)
{
PlayerIO.QuickConnect.SimpleConnect("eers-2-open-alpha-dq1cyz1b3ku5j7q16ej6vw", "email", "password", null, loginSuccess, loginFail);
Console.ReadKey();
}
static void loginSuccess(Client client)
{
_client = client;
Console.WriteLine("Logged in!");
client.Multiplayer.CreateJoinRoom(roomid, roomid.StartsWith("BW") ? "Beta" : "Everybodyedits" + client.BigDB.Load("config", "config")["version"], true, null, null, connectionSuccess, connectionFail);
}
static void loginFail(PlayerIOError error)
{
Console.WriteLine("Can't login, reason: " + error.Message);
}
static void connectionSuccess(Connection con)
{
_connection = con;
Console.WriteLine("Connected!");
con.Send("init");
con.OnMessage += Con_OnMessage;
}
private static void Con_OnMessage(object sender,PlayerIOClient.Message m)
{
switch (m.Type)
{
case "init":
_connection.Send("init2");
break;
case "init2":
Console.WriteLine("Joined the room!");
break;
case "c":
_connection.Send("b", 0, m.GetInt(3), m.GetInt(4), 100);
//Console.WriteLine("Coin (" + m.GetInt(3) + ", " + m.GetInt(4) + ") placed!");
break;
}
}
static void connectionFail(PlayerIOError error)
{
Console.WriteLine("Can't connect, reason: " + error.Message);
}
}
}
That's the basic code in EE to connect. I have replaced some arguments, to make code running you need roomid, email, password to be replaced.
That's what the Console outputs:
Logged in!
Can't login, reason: Object reference not set to an instance of an object.
I guess the error is in line 25:
client.Multiplayer.CreateJoinRoom(roomid, roomid.StartsWith("BW") ? "Beta" : "Everybodyedits" + client.BigDB.Load("config", "config")["version"], true, null, null, connectionSuccess, connectionFail);
We just need to know what to replace instead of Everybodyedits?