Here is an example on how to use it: /dlc test www.test.com/test.cs
That will download the test.cs and put in in the commands folder named "Cmdtest.cs" to be ready to be compiled.
- Code: Select all
using System;
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";
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);
}
catch
{
Player.SendMessage(p, "%cDownload failed.");
}
}
public override void Help(Player p)
{
Player.SendMessage(p, "/DownloadCommand (name for command) (URl)- Dowload Command.");
}
}
}