What's new?
V 2.1
+ Say "{house}" in a FreeBuild server and LeeBot will build a house for you! (This was part of a Challenge set by HelloWorldCool)
V 2.0
+ I've made a command work with updating now, you can check updates in-game.
+ Fixed bug where you send a blank message.
+ He know tells operators if a joined player is using ClassiCube.
Description
This is my Minecraft bot that I am working on and he will welcome players to the server and reply to certain messages!
So he has 3 commands:
1): /lb [message] -- This will make it look like your are talking as [LeeBot]
2): /lb spawn -- This just spawns a bot called [LeeBot] and it's only use is for a message reply shown below:
3): /lb update -- It will check for a new update and create a file with the link (Or just come back to this thread).
Message replies:
Die leebot! -- It will show a message foreplaying his death and removing his bot if it's present.
Hey / hello / hi leebot -- He will say Hello back.
What time is it? -- He will tell you your time.
What is the website? -- He will tell you my website.
I'm back -- He will welcome you back.
How are you leebot? -- He will tell you that he is fine.
snail (no caps) -- turns your message into a snail.
duck (no caps) -- turns your message into a duck.
More will be added upon request, so please ask away!
Version: 2.1
Spoiler:
- Code: Select all
//LeeBot v2.1 Made by LeeIzaZombie
using System.Threading;
using System;
using System.IO;
using System.Net;
namespace MCDzienny
#region Settings
{
public class CmdLeeBot : Command
{
public override string name { get { return "lb"; } }
public override string shortcut { get { return ""; } }
public override string type { get { return "mod"; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
private string path = "extra/leebot/builds/";
public override void Use(Player p, string message)
{
if (message == "spawn")
{
Command.all.Find("botadd").Use(p, "LeeBot");
}
if (message == "update")
{
if (!Directory.Exists("extra/leebot/updates/"))
{
Directory.CreateDirectory("extra/leebot/updates/");
}
try
{
using (WebClient web = new WebClient())
{
Player.SendMessage(p, "Checking for an update, please wait.");
web.DownloadFile("http://leeizazombie.cba.pl/leebot/v2part3.txt", "extra/leebot/updates/2part3.txt");
}
Player.SendMessage(p, "%aThere is an update available, the link will be in the file: /extra/leebot/updates/2part3.txt");
return;
}
catch
{
Player.SendMessage(p, "It seems you have the latest update! %bv2.1");
return;
}
}
else
{
Player.GlobalMessage(" %f[%bLeeBot%f]: " + message);
}
}
#endregion
#region Joined server
public override void Init()
{
if (!Directory.Exists("extra/leebot/builds"))
{
Directory.CreateDirectory("extra/leebot/builds");
}
Player.Joined += (object sender, PlayerEventArgs e) =>
{
if (e.Player.name == "Leebyrne115@gmail.com" || e.Player.name == "LeeIzaZombie" || e.Player.name == "LeeIzaZombie+")
{
e.Player.PublicName = "%8[%7LeeIzaZombie%8]%f";
Thread.Sleep(3000);
Player.GlobalMessage("%f[%bLeeBot%f]: Lee, I renamed you :3");
if (e.Player.IsCpeSupported)
{
Player.GlobalMessageOps("%f[%bLeeBot%f]: %b" + e.Player.PublicName + "%f uses ClassiCube.");
}
}
else
{
Thread.Sleep(3000);
Player.GlobalMessage("%f[%bLeeBot%f]: Welcome to $server " + e.Player.color + e.Player.PublicName + "%f! :D");
if (e.Player.IsCpeSupported)
{
Player.GlobalMessageOps("%f[%bLeeBot%f]:%b " + e.Player.PublicName + "%f uses ClassiCube.");
}
}
};
Player.PlayerChatEvent += FilterChat;
}
#endregion
#region greetings
private void FilterChat(Player p, ref string message, ref bool stopIt)
{
string botCmd = message;
if (botCmd.ToLower().Contains("leebot") && botCmd.ToLower().Contains("hello"))
{
Player.GlobalMessage(p.color + p.PublicName + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is typing... ");
Thread.Sleep(2000);
stopIt = true;
Player.GlobalMessage("%f[%bLeeBot%f]: Hello there, " + p.color + p.PublicName + "%f!");
}
if (botCmd.ToLower().Contains("leebot") && botCmd.ToLower().Contains("hey"))
{
Player.GlobalMessage(p.color + p.PublicName + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is typing... ");
Thread.Sleep(2000);
stopIt = true;
Player.GlobalMessage("%f[%bLeeBot%f]: Hello there, " + p.color + p.PublicName + "%f!");
}
if (botCmd.ToLower().Contains("leebot") && botCmd.ToLower().Contains("hi"))
{
Player.GlobalMessage(p.color + p.name + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is typing... ");
Thread.Sleep(2000);
stopIt = true;
Player.GlobalMessage("%f[%bLeeBot%f]: Hello there, " + p.color + p.PublicName + "%f!");
}
if (botCmd.ToLower().Equals("leebot"))
{
Player.GlobalMessage(p.color + p.PublicName + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is typing... ");
Thread.Sleep(2000);
stopIt = true;
Player.GlobalMessage("%f[%bLeeBot%f]: What do you need?");
}
#endregion
#region I'm back
if (botCmd.ToLower().Contains("back") && botCmd.ToLower().Contains("i") && botCmd.ToLower().Contains("m"))
{
Player.GlobalMessage(p.color + p.PublicName + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is typing... ");
Thread.Sleep(2000);
stopIt = true;
Player.GlobalMessage("%f[%bLeeBot%f]: Welcome back, " + p.color + p.PublicName + "%f!");
}
#endregion
#region ^Build
if (botCmd.ToLower().Equals("{house}"))
{
if (Server.IsZombieModeOn())
{
stopIt = true;
Player.SendMessage(p, "%f[%bLeeBot%f]: %fYou cannot use this command in Zombie Survival.");
return;
}
if (!p.canBuild)
{
stopIt = true;
Player.SendMessage(p, "%f[%bLeeBot%f]: %fThis area cannot be built on by you :(");
return;
}
if (File.Exists(path + "house" + ".leebuild"))
{
stopIt = true;
temp temporary;
temporary.name = "house";
p.blockchangeObject = temporary;
Player.SendMessage(p, " %f[%bLeeBot%f]: Please place a block! :)");
p.ClearBlockchange();
p.Blockchange += new Player.BlockchangeEventHandler(create);
}
else
{
stopIt = true;
Player.SendMessage(p, "%f[%bLeeBot%f]: %fI lost my blueprints, please wait while I get them off the website!");
try
{
using (WebClient web = new WebClient())
{
Player.SendMessage(p, "%1Downloading file, please wait.");
web.DownloadFile("http://leeizazombie.cba.pl/leebot/House.LeeBuild", path + "house.leebuild");
}
Player.SendMessage(p, "%f[%bLeeBot%f]: %f Found them! While I quickly scan them, please try again! :)");
return;
}
catch
{
Player.SendMessage(p, "%cError: %fWebsite may be offline.");
return;
}
}
}
#endregion
#region Die LeeBot
if (botCmd.ToLower().Contains("leebot") && botCmd.ToLower().Contains("die"))
{
Player.GlobalMessage(p.color + p.PublicName + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is fuzzing... ");
Thread.Sleep(2000);
stopIt = true;
Player.GlobalMessage("%f%bLeeBot%f has died.");
try
{
Command.all.Find("botremove").Use(p, "LeeBot");
}
catch
{
}
Thread.Sleep(3000);
Player.GlobalMessage("*Strange noises appear.");
Thread.Sleep(1000);
Player.GlobalMessage("%f[%bLeeBot%f]: You cannot kill me!!");
}
#endregion
#region How are you?
if (botCmd.ToLower().Contains("how") && botCmd.ToLower().Contains("are") && botCmd.ToLower().Contains("you") && botCmd.ToLower().Contains("leebot"))
{
Player.GlobalMessage(p.color + p.PublicName + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is typing... ");
Thread.Sleep(2000);
stopIt = true;
Player.GlobalMessage("%f[%bLeeBot%f]: I'm fine! :D thanks for asking! and you?");
}
#endregion
#region What's the website?
if (botCmd.ToLower().Contains("what") && botCmd.ToLower().Contains("the") && botCmd.ToLower().Contains("website"))
{
Player.GlobalMessage(p.color + p.PublicName + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is typing... ");
Thread.Sleep(2000);
stopIt = true;
Player.GlobalMessage("%f[%bLeeBot%f]: LeeIzaZombie's website is www.leeizazombie.cba.pl");
}
#endregion
#region What's time is it?
if (botCmd.ToLower().Contains("what") && botCmd.ToLower().Contains("time") && botCmd.ToLower().Contains("is") && botCmd.ToLower().Contains("it"))
{
Player.GlobalMessage(p.color + p.PublicName + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is typing... ");
Thread.Sleep(500);
stopIt = true;
Player.GlobalMessage("%f[%bLeeBot%f]: The time is: %a$time");
}
#endregion
#region Others
if (botCmd.Equals("snail"))
{
message = "(half)x@";
}
if (botCmd.Equals("duck"))
{
message = "(female)_-";
}
}
#endregion
public override void Help(Player p)
{
Player.SendMessage(p, "LeeBot Chat: %b/lb (message)");
Player.SendMessage(p, "Spawn LeeBot: %b/lb spawn");
Player.SendMessage(p, "Say: {house} - Builds a house for you.");
Player.SendMessage(p, "To check for updates use: %b/lb update");
Player.SendMessage(p, "LeeBot Version %bV2.1");
}
public void create(Player p, ushort x, ushort y, ushort z, byte type)
{
temp temporary = (temp)p.blockchangeObject;
p.SendBlockchange(x, y, z, p.level.GetTile(x, y, z));
using (var sr = new StreamReader(path + temporary.name + ".leebuild"))
{
string line;
while ((line = sr.ReadLine()) != null)
{
p.level.Blockchange(p, (ushort)(Convert.ToUInt16(line.Split(' ')[0]) + x), (ushort)(Convert.ToUInt16(line.Split(' ')[1]) + y), (ushort)(Convert.ToUInt16(line.Split(' ')[2]) + z), Block.Parse(line.Split(' ')[3]));
}
}
p.ClearBlockchange();
Player.SendMessage(p, "%b" + temporary.name + " %7created");
}
struct temp
{
public string name;
}
}
}
Version: 2.0
Spoiler:
The code:
- Code: Select all
//LeeBot v2.0 Made by LeeIzaZombie
using System.Threading;
using System;
using System.IO;
using System.Net;
namespace MCDzienny
#region Settings
{
public class CmdLeeBot : Command
{
public override string name { get { return "lb"; } }
public override string shortcut { get { return ""; } }
public override string type { get { return "mod"; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public override void Use(Player p, string message)
{
if (message == "spawn")
{
Command.all.Find("botadd").Use(p, "LeeBot");
}
if (message == "update")
{
if (!Directory.Exists("extra/leebot/updates/"))
{
Directory.CreateDirectory("extra/leebot/updates/");
}
try
{
using (WebClient web = new WebClient())
{
Player.SendMessage(p, "Checking for an update, please wait.");
web.DownloadFile("http://leeizazombie.cba.pl/leebot/v2part2.txt", "extra/leebot/updates/2part2.txt");
}
Player.SendMessage(p, "%aThere is an update available, the link will be in the file: /extra/leebot/updates/2part2.txt");
return;
}
catch
{
Player.SendMessage(p, "It seems you have the latest update! %bv2.0");
return;
}
}
else
{
Player.GlobalMessage(" %f[%bLeeBot%f]: " + message);
}
}
#endregion
#region Joined server
public override void Init()
{
Player.Joined += (object sender, PlayerEventArgs e) =>
{
if (e.Player.name == "Leebyrne115@gmail.com" || e.Player.name == "LeeIzaZombie" || e.Player.name == "LeeIzaZombie+")
{
e.Player.PublicName = "%8[%7LeeIzaZombie%8]%f";
Thread.Sleep(3000);
Player.GlobalMessage("%f[%bLeeBot%f]: Lee, I renamed you :3");
if (e.Player.IsCpeSupported)
{
Player.GlobalMessageOps("%f[%bLeeBot%f]: %b" + e.Player.PublicName + "%f uses ClassiCube.");
}
}
else
{
Thread.Sleep(3000);
Player.GlobalMessage("%f[%bLeeBot%f]: Welcome to $server "+ e.Player.color + e.Player.PublicName + "%f! :D");
if (e.Player.IsCpeSupported)
{
Player.GlobalMessageOps("%f[%bLeeBot%f]:%b " + e.Player.PublicName + "%f uses ClassiCube.");
}
}
};
Player.PlayerChatEvent += FilterChat;
}
#endregion
#region greetings
private void FilterChat(Player p, ref string message, ref bool stopIt)
{
string botCmd = message;
if (botCmd.ToLower().Contains("leebot") && botCmd.ToLower().Contains("hello"))
{
Player.GlobalMessage(p.color + p.PublicName + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is typing... ");
Thread.Sleep(2000);
stopIt = true;
Player.GlobalMessage("%f[%bLeeBot%f]: Hello there, " + p.color + p.PublicName + "%f!");
}
if (botCmd.ToLower().Contains("leebot") && botCmd.ToLower().Contains("hey"))
{
Player.GlobalMessage(p.color + p.PublicName + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is typing... ");
Thread.Sleep(2000);
stopIt = true;
Player.GlobalMessage("%f[%bLeeBot%f]: Hello there, " + p.color + p.PublicName + "%f!");
}
if (botCmd.ToLower().Contains("leebot") && botCmd.ToLower().Contains("hi"))
{
Player.GlobalMessage(p.color + p.name + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is typing... ");
Thread.Sleep(2000);
stopIt = true;
Player.GlobalMessage("%f[%bLeeBot%f]: Hello there, " + p.color + p.PublicName + "%f!");
}
if (botCmd.ToLower().Equals("leebot"))
{
Player.GlobalMessage(p.color + p.PublicName + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is typing... ");
Thread.Sleep(2000);
stopIt = true;
Player.GlobalMessage("%f[%bLeeBot%f]: What do you need?");
}
#endregion
#region I'm back
if (botCmd.ToLower().Contains("back") && botCmd.ToLower().Contains("i") && botCmd.ToLower().Contains("m"))
{
Player.GlobalMessage(p.color + p.PublicName + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is typing... ");
Thread.Sleep(2000);
stopIt = true;
Player.GlobalMessage("%f[%bLeeBot%f]: Welcome back, " + p.color + p.PublicName + "%f!");
}
#endregion
#region Die LeeBot
if (botCmd.ToLower().Contains("leebot") && botCmd.ToLower().Contains("die"))
{
Player.GlobalMessage(p.color + p.PublicName + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is fuzzing... ");
Thread.Sleep(2000);
stopIt = true;
Player.GlobalMessage("%f%bLeeBot%f has died.");
try
{
Command.all.Find("botremove").Use(p, "LeeBot");
}
catch
{
}
Thread.Sleep(3000);
Player.GlobalMessage("*Strange noises appear.");
Thread.Sleep(1000);
Player.GlobalMessage("%f[%bLeeBot%f]: You cannot kill me!!");
}
#endregion
#region How are you?
if (botCmd.ToLower().Contains("how") && botCmd.ToLower().Contains("are") && botCmd.ToLower().Contains("you") && botCmd.ToLower().Contains("leebot"))
{
Player.GlobalMessage(p.color + p.PublicName + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is typing... ");
Thread.Sleep(2000);
stopIt = true;
Player.GlobalMessage("%f[%bLeeBot%f]: I'm fine! :D thanks for asking! and you?");
}
#endregion
#region What's the website?
if (botCmd.ToLower().Contains("what") && botCmd.ToLower().Contains("the") && botCmd.ToLower().Contains("website"))
{
Player.GlobalMessage(p.color + p.PublicName + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is typing... ");
Thread.Sleep(2000);
stopIt = true;
Player.GlobalMessage("%f[%bLeeBot%f]: LeeIzaZombie's website is www.leeizazombie.cba.pl");
}
#endregion
#region What's time is it?
if (botCmd.ToLower().Contains("what") && botCmd.ToLower().Contains("time") && botCmd.ToLower().Contains("is") && botCmd.ToLower().Contains("it"))
{
Player.GlobalMessage(p.color + p.PublicName + "%f: " + message);
Player.GlobalMessage(" %bLeeBot%f is typing... ");
Thread.Sleep(500);
stopIt = true;
Player.GlobalMessage("%f[%bLeeBot%f]: The time is: %a$time");
}
#endregion
#region Others
if (botCmd.Equals("snail"))
{
message = "(half)x@";
}
if (botCmd.Equals("duck"))
{
message = "(female)_-";
}
}
#endregion
public override void Help(Player p)
{
Player.SendMessage(p, "LeeBot Chat: %b/lb (message)");
Player.SendMessage(p, "Spawn LeeBot: %b/lb spawn");
Player.SendMessage(p, "To check for updates use: %b/lb update");
Player.SendMessage(p, "LeeBot Version %bV2.0");
}
}
}