by Leeizazombie » 07 May 2014, 19:50
You've made quite a few mistakes, especially with the brackets. I suggest you look up some basics on coding in C# by reading a book or even YouTube.
Here's your command fixed and improved:- Code: Select all
using System;
using System.IO;
using System.Threading;
namespace MCDzienny
{
public class cmdXrules : Command
{
public override string name { get { return "xrules"; } }
public override string shortcut { get { return "xr"; } }
public override string type { get { return "other"; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public override void Use(Player p, string message)
{
if (File.Exists("/extra/Xrules.txt"))
{
string fileContent = File.ReadAllText("/extra/Xrules.txt");
if (fileContent.Length == 0)
{
Player.SendMessage(p, "The rules have not been entered yet!");
return;
}
Player.SendMessage(p, fileContent);
return;
}
else
{
File.Create("/extra/Xrules.txt");
Player.SendMessage(p, "The rules have not been entered yet!");
}
}
public override void Help(Player p)
{
Player.SendMessage(p, "/xrules - Displays the server rules.");
}
}
}
You've never declared the string: "fileContent", you have to say "string fileContent = "something";" or like I did in this case "string fileContent = File.ReadAllText("/extra/Xrules.txt");"
Please note that this will not read line for line and display like that in the server, that would be a bit more complex but I hope I helped you understand your errors with the fix.
Owner of:
LeeIzaZombie Freebuild and Lava Survival V2 (Shut Down and updated)
LeeIzaZombie Survival (Comming back soon)
Contact:
Skype: leeizazombie
IRC: irc.geekshed.net, #leeizazombie, #mcclassichosting