Advertisement
Different55

DB3

Feb 2nd, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using PlayerIOClient;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Program
  10.     {
  11.         static string[] mods = { };
  12.         static string[] admins = { };
  13.         static string[] kings = { };
  14.         static int tele = 0;
  15.         static int telec = 0;
  16.         static Dictionary<int, string> players = new Dictionary<int, string>();
  17.         static Connection con;
  18.         static string title;
  19.         static void Main(string[] args)
  20.         {
  21.             Console.WriteLine("     [DB3] Different55's Blocking Blocks Bot");
  22.             Console.WriteLine("Time for some configuration.");
  23.             Console.WriteLine("Please enter your email:");
  24.             var email = Console.ReadLine();
  25.             Console.WriteLine("Ok, now enter your password.");
  26.             var pass = Console.ReadLine();
  27.  
  28.             Console.WriteLine("Enter the room ID of the world you want to enter.");
  29.             Console.WriteLine("When you hit Share Level, it's the bunch of random letters at the end. Copy that and paste it here");
  30.             Console.WriteLine("To paste it, right click the CMD icon in the top left of this window, go down to Edit and click Paste");
  31.             var roomid = Console.ReadLine();
  32.             Console.WriteLine("Enter the names of the mods you want, separated by an enter. Type \"#end#\" when you've entered all your mods");
  33.             Console.WriteLine("Mods automatically gain edit rights, but are not able to use owner commands.");
  34.             var lastresponse = "different55";
  35.             var i = 0;
  36.             var end = false;
  37.             while (end == false)
  38.             {
  39.                 if (lastreponse == "#end#")
  40.                 {
  41.                     end = true;
  42.                 }
  43.                 mods[i] = lastresponse;
  44.                 i = i + 1;
  45.                 lastresponse = Console.ReadLine();
  46.             }
  47.             Console.WriteLine("Enter the names of the admins you want, separated by an enter. Type \"#end#\" when you've entered all your admins");
  48.             Console.WriteLine("Admins can do everything you can.");
  49.             lastresponse = "different55";
  50.             i = 0;
  51.             while (lastresponse != "#end#")
  52.             {
  53.                 admins[i] = lastresponse;
  54.                 i = i + 1;
  55.                 lastresponse = Console.ReadLine();
  56.             }
  57.             Console.WriteLine("Would you like people to be able to teleport at all? (Y/N)");
  58.             var lastchoice = Console.ReadLine();
  59.             if (lastchoice.StartsWith("Y") || lastchoice.StartsWith("y"))
  60.             {
  61.                 tele = 1;
  62.                 Console.WriteLine("Would you like teleportation to be limited to kings, mods, and admins? (Y/N)");
  63.                 lastchoice = Console.ReadLine();
  64.                 if (lastchoice.StartsWith("Y") || lastchoice.StartsWith("y"))
  65.                 {
  66.                     telec = 1;
  67.                 }
  68.             }
  69.  
  70.             Console.Clear();
  71.             Console.WriteLine("Connecting...");
  72.             connect(email, pass, roomid);
  73.             Console.ReadLine();
  74.         }
  75.         static void connect(string email, string pass, string roomid)
  76.         {
  77.             PlayerIO.QuickConnect.SimpleConnect("blocking-blocks-u4zmkxjugu0ap8xqbymw", email, pass,
  78.                 delegate(Client c)
  79.                 {
  80.                     Console.WriteLine("Connected to game.");
  81.                     c.Multiplayer.JoinRoom(roomid, null,
  82.                         delegate(Connection con)
  83.                         {
  84.                             Console.WriteLine("Connecting to room...");
  85.                             con.Send("botinit");
  86.                             con.Send("init2");
  87.                             con.OnMessage += new MessageReceivedEventHandler(con_OnMessage);
  88.                         },
  89.                         delegate(PlayerIOError error)
  90.                         {
  91.                             Console.WriteLine(error);
  92.                         });
  93.                 },
  94.                 delegate(PlayerIOError error)
  95.                 {
  96.                     Console.WriteLine(error);
  97.                 });
  98.  
  99.         }
  100.  
  101.         static void con_OnMessage(object sender, PlayerIOClient.Message m)
  102.         {
  103.             switch (m.Type)
  104.             {
  105.                 case "init":
  106.                     title = m.GetString(1);
  107.                     Console.WriteLine("Connected to " + m.GetString(1) + " by " + m.GetString(0));
  108.                     Console.WriteLine("World has been played " + m.GetString(2) + " times");
  109.                     players.Add(m.GetInt(4), m.GetString(7));
  110.                 break;
  111.                 case "say":
  112.                     // EVERYONE COMMANDS
  113.                     if (m.GetString(1).StartsWith(".tele"))
  114.                     {
  115.                         if (tele == 1 || admins.Contains(players[m.GetInt(0)]) || mods.Contains(players[m.GetInt(0)]))
  116.                         {
  117.                             if (telec == 1)
  118.                             {
  119.                                 if (kings.Contains(players[m.GetInt(0)]) || admins.Contains(players[m.GetInt(0)]) || mods.Contains(players[m.GetInt(0)]))
  120.                                 {
  121.                                     string[] words = m.GetString(1).Split(' ');
  122.                                     con.Send("say", "/tele " + players[m.GetInt(0)] + words[1] + " " + words[2]);
  123.                                 }
  124.                             }
  125.                             else if (telec == 0)
  126.                             {
  127.                                string[] words = m.GetString(1).Split(' ');
  128.                                 con.Send("say", "/tele " + players[m.GetInt(0)] + words[1] + " " + words[2]);
  129.                             }
  130.                         }
  131.                     }
  132.  
  133.                     if (admins.Contains(players[m.GetInt(0)]) || mods.Contains(players[m.GetInt(0)]))
  134.                     { // MOD COMMANDS
  135.                     }
  136.                     else if (admins.Contains(players[m.GetInt(0)]))
  137.                     { // ADMIN COMMANDS
  138.                         if (m.GetString(1).StartsWith(".edit"))
  139.                         {
  140.                             string[] words = m.GetString(1).Split(' ');
  141.                             con.Send("say", "/giveedit " + words[1]);
  142.                         }
  143.                         else if (m.GetString(1).StartsWith(".unedit"))
  144.                         {
  145.                             string[] words = m.GetString(1).Split(' ');
  146.                             con.Send("say", "/removeedit " + words[1]);
  147.  
  148.                         }
  149.                     }
  150.                 break;
  151.                 case "add":
  152.                     try
  153.                     {
  154.                         players.Add(m.GetInt(0), m.GetString(1));
  155.                         Console.WriteLine(m.GetString(1) + " has joined.");
  156.                         con.Send("say", "/pm " + m.GetString(1) + " [DB3] Welcome to " + title);
  157.                         if (admins.Contains(m.GetString(1)) || mods.Contains(m.GetString(1)))
  158.                         {
  159.                             con.Send("say", "/giveedit " + m.GetString(1));
  160.                         }
  161.                     }
  162.                     catch
  163.                     {
  164.  
  165.                     }
  166.                 break;
  167.                 case "left":
  168.                     try
  169.                     {
  170.                         Console.WriteLine(players[m.GetInt(0)] + " has left.");
  171.                         players.Remove(m.GetInt(0));
  172.                     }
  173.                     catch
  174.                     {
  175.  
  176.                     }
  177.                 break;
  178.                 case "k":
  179.                     try
  180.                     {
  181.                         Console.WriteLine(players[m.GetInt(0)] + " has obtained the crown.");
  182.                         con.Send("say", players[m.GetInt(0)] + " has won!");
  183.                         kings[m.GetInt(0)] = players[m.GetInt(0)];
  184.                         if (telec == 1)
  185.                         {
  186.                             con.Send("say", "/pm " + players[m.GetInt(0)] + " You may now use .tele X Y to teleport.");
  187.                         }
  188.                     }
  189.                     catch
  190.                     {
  191.                     }
  192.                 break;
  193.  
  194.             }
  195.         }
  196.     }
  197. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement