Advertisement
xfrogman43

Basic Connection

Mar 27th, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.24 KB | None | 0 0
  1.         public Client client;
  2.         public Connection conn;
  3.         public bool iscon;
  4.         public Dictionary<int, string> players = new Dictionary<int, string>();
  5. /*^^^ Put these after
  6. "public partial class Form1 : Form
  7.     {"*/
  8.  
  9. //this goes in button
  10.             if (!iscon)
  11.             {
  12.                 client = PlayerIO.QuickConnect.SimpleConnect("everybody-edits-su9rn58o40itdbnw69plyw", "email", "pw", null);
  13.                 conn = client.Multiplayer.CreateJoinRoom("worldID", "Everybodyedits" + client.BigDB.Load("config", "config")["version"], true, new Dictionary<string, string>(), new Dictionary<string, string>());
  14.                 conn.Send("init");
  15.                 conn.OnMessage += new MessageReceivedEventHandler(onmessage);
  16.                 iscon = true;
  17.             }
  18.             else
  19.             {
  20.                 conn.Disconnect();
  21.                 iscon = false;
  22.             }
  23. //until here
  24.  
  25. //goes outside button
  26.         #region Cases
  27.         public void onmessage(object o, PlayerIOClient.Message m)
  28.         {
  29.             Invoke(new EventHandler(delegate
  30.             {
  31.                 switch (m.Type)
  32.                 {
  33.                     #region Init
  34.                     case "init":
  35.                         {
  36.                             conn.Send("init2");
  37.                             conn.Send("god", true);//gives bot god mode
  38.                         }
  39.                         break;
  40.                     #endregion
  41.                     #region Add
  42.                     case "add":
  43.                         {
  44.                             if (!players.ContainsKey(m.GetInt(0)))
  45.                             {
  46.                                 players.Add(m.GetInt(0), m.GetString(1));
  47.                             }
  48.                         }
  49.                         break;
  50.                     #endregion
  51.                     #region Left
  52.                     case "left":
  53.                         {
  54.                             if (players.ContainsKey(m.GetInt(0)))
  55.                             {
  56.                                 players.Remove(m.GetInt(0));
  57.                             }
  58.                         }
  59.                         break;
  60.                     #endregion
  61.                 }
  62.             }));
  63.         }
  64.         #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement