he compile him but when I type /addlava he give me error
- Code: Select all
/*
Auto-generated command skeleton class.
Use this as a basis for custom commands implemented via the MCDzienny scripting framework.
File and class should be named a specific way. For example, /update is named 'CmdUpdate.cs' for the file, and 'CmdUpdate' for the class.
*/
// Add any other using statements you need up here, of course.
// As a note, MCDzienny is designed for .NET 3.5.
using System;
using System.IO;
namespace MCDzienny
{
public class CmdAddlava : Command
{
// The command's name, in all lowercase. What you'll be putting behind the slash when using it.
public override string name { get { return "addlava"; } }
// Command's shortcut (please take care not to use an existing one, or you may have issues.
public override string shortcut { get { return ""; } }
// Determines which submenu the command displays in under /help.
public override string type { get { return "other"; } }
// Determines whether or not this command can be used in a museum. Block/map altering commands should be made false to avoid errors.
public override bool museumUsable { get { return false; } }
// Determines the command's default rank. Valid values are:
// LevelPermission.Nobody, LevelPermission.Banned, LevelPermission.Guest
// LevelPermission.Builder, LevelPermission.AdvBuilder, LevelPermission.Operator, LevelPermission.Admin
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
// This is where the magic happens, naturally.
// p is the player object for the player executing the command. message is everything after the command invocation itself.
public override void Use(Player p, string message)
{
string a = System.IO.Directory.GetCurrentDirectory();
Player.SendMessage(p, a + ":" + p.level.name);
//copy
string[] lines= new string[int.MaxValue];
System.IO.StreamReader file =
new System.IO.StreamReader(a + @"\lava\maps.txt");
string line;
int count = 0;
while ((line = file.ReadLine()) != null)
{
lines[count] = line;
count++;
}
Array.Resize(ref lines, count);
File.WriteAllLines(a + @"\lava\maps.txt", lines);
copy(a + @"\lava\maps", a + @"\levels", p.level.name + ".cfg.txt");
copy(a + @"\lava\maps", a + @"\levels", p.level.name + ".lvl");
using (var writer = File.AppendText(a + @"\lava\maps.txt"))
{
writer.WriteLine( "<Map name=" + @"""" + p.level.name + @"""" + " phase1=" + @"""" + 0 + @"""" + " phase2=" + @"""" + "0" + @"""" + " author=" + @""""+p.name + @"""" + ">" );
writer.WriteLine("<Source block=" + @"""" + " ahl" + @"""" + " x=" + @"""" + "39" + @"""" + " y=" + @"""" + "62" + @"""" + " z=" + @"""" + "39" + @"""" + " type=" + @"""" + " delay=" + @"""" + "0" + @"""" + " /> ");
writer.WriteLine("</Map>");
writer.WriteLine("</Maps>");
}
}
public static void copy(string targetPath, string sourcePath, string fileName)
{
// Use Path class to manipulate file and directory paths.
string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
string destFile = System.IO.Path.Combine(targetPath, fileName);
// To copy a folder's contents to a new location:
// Create a new target folder, if necessary.
if (!System.IO.Directory.Exists(targetPath))
{
System.IO.Directory.CreateDirectory(targetPath);
}
// To copy a file to another location and
// overwrite the destination file if it already exists.
System.IO.File.Copy(sourceFile, destFile, true);
// To copy all the files in one directory to another directory.
// Get the files in the source folder. (To recursively iterate through
// all subfolders under the current directory, see
// "How to: Iterate Through a Directory Tree.")
// Note: Check for target path was performed previously
// in this code example.
if (System.IO.Directory.Exists(sourcePath))
{
string[] files = System.IO.Directory.GetFiles(sourcePath);
// Copy the files and overwrite destination files if they already exist.
foreach (string s in files)
{
// Use static Path methods to extract only the file name from the path.
fileName = System.IO.Path.GetFileName(s);
destFile = System.IO.Path.Combine(targetPath, fileName);
System.IO.File.Copy(s, destFile, true);
}
}
}
// This one controls what happens when you use /help [commandname].
public override void Help(Player p)
{
Player.SendMessage(p, "/addlava - Does stuff. Example command.");
}
}
}