/downloadcommand [name] [Download URL]
or
/dlc [name] [Download URL]
What it does:
You can download uploaded commands via FTP or however (some uploads do not download properly such as Dropbox). This command will assume you've checked the command and that it has no errors, so it will basically download the command, add it to the "cmdautoload.txt" file, compile and load it so it's ready to use!
Example:
/dlc CmdDelete http://puu.sh/5R8FN.cs
Code:
- Code: Select all
using System;
using System.Threading;
using System.IO;
using System.Net;
namespace MCDzienny
{
public class CmdDownloadCommand : Command
{
public override string name { get { return "downloadcommand"; } }
public override string shortcut { get { return "dlc"; } }
public override string type { get { return "mod"; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
public override void Use(Player p, string message)
{
string[] a = message.Split(' ');
if (a.Length != 2)
{
Help(p);
return;
}
string name = "Cmd" + a[0] + ".cs"; // CmdTestCommand.cs
string cmdname = a[0]; // TestCommand (for cmdautoload).
try
{
using (WebClient web = new WebClient())
{
if (a[0].Substring(0, 4) != "http")
{
message = "http://" + a[1];
}
if (System.IO.File.Exists("extra/commands/source/" + name))
{
Player.SendMessage(p, "You already have a command with that name, please choose another name.");
return;
}
Player.SendMessage(p, "Downloading file from: &f" + a[0] + Server.DefaultColor + ", please wait.");
web.DownloadFile(a[1], "extra/commands/source/" + name);
}
Player.SendMessage(p, "Download complete. Command name :%3" + name);
File.AppendAllText("text/cmdautoload.txt", string.Format("{0}{1}", cmdname, Environment.NewLine));
Thread.Sleep(1000);
Command.all.Find("compile").Use(null, a[0]);
Player.SendMessage(p, "%bCompiled assuming it's okay.");
Thread.Sleep(2000);
Command.all.Find("cmdload").Use(null, a[0]);
Player.SendMessage(p, "%bLoaded assuming it's okay.");
}
catch
{
Player.SendMessage(p, "%cDownload failed.");
}
}
public override void Help(Player p)
{
Player.SendMessage(p, "/DownloadCommand (name for command) (URl)- Dowload Command.");
}
}
}
Reference:
This command was put together thanks to qpqpqpq123's Downloadmap command!
Moderators: Please remove my old /dlc posts