Advertisement
Fastmapler

EEDigBot

Jun 14th, 2015
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.31 KB | None | 0 0
  1.  public static Connection conn;
  2.         public static Client client;
  3.         public static List<string> names = new List<string>();
  4.         public static Dictionary<int, string> users = new Dictionary<int, string>();
  5.         public static Random ran = new Random();
  6.  
  7.         public static string rotCode;
  8.         public static bool hascode;
  9.         public static bool connected;
  10.         public static string username;
  11.         public static int health;
  12.         public static int playerX;
  13.         public static int playerY;
  14.  
  15.         public class block
  16.         {
  17.             public int layer { get; set; }
  18.             public int x { get; set; }
  19.             public int y { get; set; }
  20.             public int bid { get; set; }
  21.         }
  22.         public static List<block> blockL = new List<block>();
  23.         public static int[, ,] blocks = new int[2, 400, 650];
  24.         public Form1()
  25.         {
  26.             InitializeComponent();
  27.         }
  28.  
  29.         private void Form1_Load(object sender, EventArgs e)
  30.         {
  31.  
  32.         }
  33.  
  34.         private void JoinWorld_Click(object sender, EventArgs e)
  35.         {
  36.             if (!connected)
  37.             {
  38.                 try
  39.                 {
  40.                     client = PlayerIO.QuickConnect.SimpleConnect("everybody-edits-su9rn58o40itdbnw69plyw", emailInput.Text, passInput.Text, null);
  41.                     conn = client.Multiplayer.JoinRoom(wldInput.Text, null);
  42.                     conn.OnMessage += OnMessage;
  43.                     conn.Send("init");
  44.                     Console.Read();
  45.                     System.Threading.Thread.Sleep(2000);
  46.                     conn.Send("say", "[???] Connected!");
  47.                     System.Threading.Thread.Sleep(750);
  48.                     conn.Send("access", codeInput.Text);
  49.                 }
  50.                 catch (PlayerIOError oops)
  51.                 {
  52.                     Console.WriteLine("Error! " + oops);
  53.                     Console.Beep(1000 , 1000);
  54.                 }
  55.             }
  56.             else
  57.             {
  58.                 conn.Send("say", "[???] Disconnecting!");
  59.                connected = false;
  60.                conn.Disconnect();
  61.             }
  62.         }
  63.  
  64.         static void OnMessage(object sender, PlayerIOClient.Message m)
  65.         {
  66.             if (m.Type == "init")
  67.             {
  68.                 connected = true;
  69.                 conn.Send("init2");
  70.                 rotCode = Rot13.Derot(m.GetString(5));
  71.             }
  72.  
  73.             if (m.Type == "access")
  74.             {
  75.                 hascode = true;
  76.                 conn.Send("say", "[???] Code achived!");
  77.             }
  78.  
  79.             if (m.Type == "add")
  80.             {
  81.                 names.Add(m.GetString(1));
  82.                 users.Add(m.GetInt(0), m.GetString(1));
  83.             }
  84.             if (m.Type == "left")
  85.             {
  86.                 users.Remove(m.GetInt(0));
  87.             }
  88.             if (m.Type == "m")
  89.             {
  90.                 int userid = m.GetInt(0);
  91.                 int playerX = m.GetInt(1) / 16;
  92.                 int playerY = m.GetInt(2) / 16;
  93.                 int hor = m.GetInt(7);
  94.                 int ver = m.GetInt(8);
  95.                // conn.Send("say", userid + ", " + playerX + ", " + playerY + ", " + hor + ", " + ver + ", " + (playerX + hor) + ", " +(playerY + ver)); //Decommentfy if you want to see stats in game.
  96.                 if (blocks[0, playerX + hor, playerY + ver] == 16) //This does not work, regardless of the specified block being near you.
  97.                 {
  98.                    /* System.Threading.Thread.Sleep(750);
  99.                     conn.Send("say", "Found the block." + blocks[0, playerX + hor, playerY + ver]);
  100.                     System.Threading.Thread.Sleep(750); */
  101.                     conn.Send(rotCode, 0, playerX + hor, playerY + ver, 4);
  102.                 }
  103.             }
  104.             if (m.Type == "say")
  105.             {
  106.                 if (users.ContainsKey(m.GetInt(0)))
  107.                 {
  108.                     string username = users[m.GetInt(0)];
  109.  
  110.                     if (m.GetString(1) == "!help")
  111.                     {
  112.                         conn.Send("say", "/pm " + username + "[???] This is WIP. More will come soon.");
  113.                     }
  114.                 }
  115.             }
  116.         }
  117.  
  118.         public void getMapData(PlayerIOClient.Message m)
  119.         {
  120.             int w = m.GetInt(12);
  121.             int h = m.GetInt(13);
  122.             uint c = m.Count;
  123.             uint kc = 17;
  124.             while (kc < m.Count)
  125.             {
  126.                 try
  127.                 {
  128.                     if (m.GetString(kc) == "ws")
  129.                         break;
  130.                 }
  131.                 catch { }
  132.                 kc++;
  133.             }
  134.             kc++;
  135.  
  136.             while (kc < c)
  137.             {
  138.                 try
  139.                 {
  140.                     if (m.GetString(kc) == "we")
  141.                         break;
  142.                 }
  143.                 catch { }
  144.                 int blockid = m.GetInt(kc);
  145.                 int layer = m.GetInt(kc + 1);
  146.                 byte[] bytearray1 = m.GetByteArray(kc + 2);
  147.                 byte[] bytearray2 = m.GetByteArray(kc + 3);
  148.                 int bytelen = bytearray1.Length;
  149.                 for (int n = 0; n < bytelen; n += 2)
  150.                 {
  151.                     int x = Convert.ToInt32(bytearray1[n] << 8 | bytearray1[n + 1]);
  152.                     int y = Convert.ToInt32(bytearray2[n] << 8 | bytearray2[n + 1]);
  153.                     blocks[layer, x, y] = blockid;
  154.                     blockL.Add(new block { layer = layer, x = x, y = y, bid = blockid/*, health = health ~What does this do?~*/ });
  155.                 }
  156.                 switch (blockid)
  157.                 {
  158.                     case 242:
  159.                     case 381:
  160.                         kc += 7;
  161.                         break;
  162.                     case 43:
  163.                     case 165:
  164.                     case 77:
  165.                     case 83:
  166.                     case 361:
  167.                     case 374:
  168.                     case 375:
  169.                     case 376:
  170.                     case 377:
  171.                     case 378:
  172.                     case 379:
  173.                     case 380:
  174.                     case 385:
  175.                     case 1000:
  176.                         kc += 5;
  177.                         break;
  178.                     default:
  179.                         kc += 4;
  180.                         break;
  181.                 }
  182.             }
  183.         }
  184.         public class Rot13
  185.         {
  186.             public static string Derot(string code)
  187.             {
  188.                 char[] array = code.ToCharArray();
  189.  
  190.                 for (int i = 0; i < array.Length; i++)
  191.                 {
  192.                     int number = (int)array[i];
  193.  
  194.                     if (number >= 'a' && number <= 'z')
  195.                     {
  196.                         if (number > 'm')
  197.                             number -= 13;
  198.                         else
  199.                             number += 13;
  200.                     }
  201.                     else if (number >= 'A' && number <= 'Z')
  202.                     {
  203.                         if (number > 'M')
  204.                             number -= 13;
  205.                         else
  206.                             number += 13;
  207.                     }
  208.  
  209.                     array[i] = (char)number;
  210.                 }
  211.  
  212.                 return new string(array);
  213.             }
  214.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement