Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using PlayerIOClient;
- namespace ConsoleApplication1
- {
- class Program
- {
- static string[] mods = { };
- static string[] admins = { };
- static string[] kings = { };
- static int tele = 0;
- static int telec = 0;
- static Dictionary<int, string> players = new Dictionary<int, string>();
- static Connection con;
- static string title;
- static void Main(string[] args)
- {
- Console.WriteLine(" [DB3] Different55's Blocking Blocks Bot");
- Console.WriteLine("Time for some configuration.");
- Console.WriteLine("Please enter your email:");
- var email = Console.ReadLine();
- Console.WriteLine("Ok, now enter your password.");
- var pass = Console.ReadLine();
- Console.WriteLine("Enter the room ID of the world you want to enter.");
- Console.WriteLine("When you hit Share Level, it's the bunch of random letters at the end. Copy that and paste it here");
- Console.WriteLine("To paste it, right click the CMD icon in the top left of this window, go down to Edit and click Paste");
- var roomid = Console.ReadLine();
- Console.WriteLine("Enter the names of the mods you want, separated by an enter. Type \"#end#\" when you've entered all your mods");
- Console.WriteLine("Mods automatically gain edit rights, but are not able to use owner commands.");
- var lastresponse = "different55";
- var i = 0;
- var end = false;
- while (end == false)
- {
- if (lastreponse == "#end#")
- {
- end = true;
- }
- mods[i] = lastresponse;
- i = i + 1;
- lastresponse = Console.ReadLine();
- }
- Console.WriteLine("Enter the names of the admins you want, separated by an enter. Type \"#end#\" when you've entered all your admins");
- Console.WriteLine("Admins can do everything you can.");
- lastresponse = "different55";
- i = 0;
- while (lastresponse != "#end#")
- {
- admins[i] = lastresponse;
- i = i + 1;
- lastresponse = Console.ReadLine();
- }
- Console.WriteLine("Would you like people to be able to teleport at all? (Y/N)");
- var lastchoice = Console.ReadLine();
- if (lastchoice.StartsWith("Y") || lastchoice.StartsWith("y"))
- {
- tele = 1;
- Console.WriteLine("Would you like teleportation to be limited to kings, mods, and admins? (Y/N)");
- lastchoice = Console.ReadLine();
- if (lastchoice.StartsWith("Y") || lastchoice.StartsWith("y"))
- {
- telec = 1;
- }
- }
- Console.Clear();
- Console.WriteLine("Connecting...");
- connect(email, pass, roomid);
- Console.ReadLine();
- }
- static void connect(string email, string pass, string roomid)
- {
- PlayerIO.QuickConnect.SimpleConnect("blocking-blocks-u4zmkxjugu0ap8xqbymw", email, pass,
- delegate(Client c)
- {
- Console.WriteLine("Connected to game.");
- c.Multiplayer.JoinRoom(roomid, null,
- delegate(Connection con)
- {
- Console.WriteLine("Connecting to room...");
- con.Send("botinit");
- con.Send("init2");
- con.OnMessage += new MessageReceivedEventHandler(con_OnMessage);
- },
- delegate(PlayerIOError error)
- {
- Console.WriteLine(error);
- });
- },
- delegate(PlayerIOError error)
- {
- Console.WriteLine(error);
- });
- }
- static void con_OnMessage(object sender, PlayerIOClient.Message m)
- {
- switch (m.Type)
- {
- case "init":
- title = m.GetString(1);
- Console.WriteLine("Connected to " + m.GetString(1) + " by " + m.GetString(0));
- Console.WriteLine("World has been played " + m.GetString(2) + " times");
- players.Add(m.GetInt(4), m.GetString(7));
- break;
- case "say":
- // EVERYONE COMMANDS
- if (m.GetString(1).StartsWith(".tele"))
- {
- if (tele == 1 || admins.Contains(players[m.GetInt(0)]) || mods.Contains(players[m.GetInt(0)]))
- {
- if (telec == 1)
- {
- if (kings.Contains(players[m.GetInt(0)]) || admins.Contains(players[m.GetInt(0)]) || mods.Contains(players[m.GetInt(0)]))
- {
- string[] words = m.GetString(1).Split(' ');
- con.Send("say", "/tele " + players[m.GetInt(0)] + words[1] + " " + words[2]);
- }
- }
- else if (telec == 0)
- {
- string[] words = m.GetString(1).Split(' ');
- con.Send("say", "/tele " + players[m.GetInt(0)] + words[1] + " " + words[2]);
- }
- }
- }
- if (admins.Contains(players[m.GetInt(0)]) || mods.Contains(players[m.GetInt(0)]))
- { // MOD COMMANDS
- }
- else if (admins.Contains(players[m.GetInt(0)]))
- { // ADMIN COMMANDS
- if (m.GetString(1).StartsWith(".edit"))
- {
- string[] words = m.GetString(1).Split(' ');
- con.Send("say", "/giveedit " + words[1]);
- }
- else if (m.GetString(1).StartsWith(".unedit"))
- {
- string[] words = m.GetString(1).Split(' ');
- con.Send("say", "/removeedit " + words[1]);
- }
- }
- break;
- case "add":
- try
- {
- players.Add(m.GetInt(0), m.GetString(1));
- Console.WriteLine(m.GetString(1) + " has joined.");
- con.Send("say", "/pm " + m.GetString(1) + " [DB3] Welcome to " + title);
- if (admins.Contains(m.GetString(1)) || mods.Contains(m.GetString(1)))
- {
- con.Send("say", "/giveedit " + m.GetString(1));
- }
- }
- catch
- {
- }
- break;
- case "left":
- try
- {
- Console.WriteLine(players[m.GetInt(0)] + " has left.");
- players.Remove(m.GetInt(0));
- }
- catch
- {
- }
- break;
- case "k":
- try
- {
- Console.WriteLine(players[m.GetInt(0)] + " has obtained the crown.");
- con.Send("say", players[m.GetInt(0)] + " has won!");
- kings[m.GetInt(0)] = players[m.GetInt(0)];
- if (telec == 1)
- {
- con.Send("say", "/pm " + players[m.GetInt(0)] + " You may now use .tele X Y to teleport.");
- }
- }
- catch
- {
- }
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement