Command Does:
Well when you find a rule breaker you'll want to warn him A.S.A.P well, this warn command does that. Say you're rule 1 is "Do not flood Lava Homes" and Jerry10 over here floods them. You want to get him out of the house, And warn him. Now thats a bit hard to do at the same time. But with this warn command it sends player back to spawn and warns the player for rule 1. So you warnned him, this is what the warn will say: "Jerry10 was warned for:Do not flood Lava Homes" and sends him back to the spawn. Convenient huh?
Code:
- Code: Select all
using System;
namespace MCDzienny
{
public class CmdWarn : Command
{
public override string name { get { return "warn"; } }
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.Builder; } }
public override void Use(Player p, string message)
{
string reason = message.Substring(message.IndexOf(' ') + 1).Trim();
if (message == "")
{
Help(p);
return;
}
Player who = Player.Find(message.Split(' ')[0]);
// Makes sure the player is online and valid.
if (who == null)
{
Player.SendMessage(p, "Player not found!");
return;
}
// Code here makes it so you cannot warn your-self.
if (who == p)
{
Player.SendMessage(p, "Cannot warn yourself.");
return;
}
// Check the rank.
if (p != null && p.group.Permission < who.group.Permission)
{
Player.SendMessage(p, "Cannot warn someone higher than you.");
return;
}
// Your reason.
if (message.Split(' ').Length == 1)
{
Player.SendMessage(p, "You need add a valid rule.");
}
else
{
if (reason == "1")
{
Player.GlobalMessage(who.color + who.PublicName + Server.DefaultColor + " was warned: " + c.white + "1. EDIT ONLY THIS PART ADD REASON HERE");
Command.all.Find("spawn").Use(who, "");
}
else if (reason == "2")
{
Player.GlobalMessage(who.color + who.PublicName + Server.DefaultColor + " was warned: " + c.white + "2. EDIT ONLY THIS PART ADD REASON HERE");
Command.all.Find("spawn").Use(who, "");
}
else if (reason == "3")
{
Player.GlobalMessage(who.color + who.PublicName + Server.DefaultColor + " was warned: " + c.white + "3. EDIT ONLY THIS PART ADD REASON HERE");
Command.all.Find("spawn").Use(who, "");
}
else if (reason == "4")
{
Player.GlobalMessage(who.color + who.PublicName + Server.DefaultColor + " was warned: " + c.white + "4. EDIT ONLY THIS PART ADD REASON HERE");
Command.all.Find("spawn").Use(who, "");
}
else if (reason == "5")
{
Player.GlobalMessage(who.color + who.PublicName + Server.DefaultColor + " was warned: " + c.white + "5. DoEDIT ONLY THIS PART ADD REASON HERE");
Command.all.Find("spawn").Use(who, "");
}
else if (reason == "6")
{
Player.GlobalMessage(who.color + who.PublicName + Server.DefaultColor + " was warned: " + c.white + "6. EDIT ONLY THIS PART ADD REASON HERE");
Command.all.Find("spawn").Use(who, "");
}
else if (reason == "7")
{
Player.GlobalMessage(who.color + who.PublicName + Server.DefaultColor + " was warned: " + c.white + "7. EDIT ONLY THIS PART ADD REASON HERE.");
Command.all.Find("spawn").Use(who, "");
}
else
{
Player.SendMessage(p, "Invalid rule.");
}
}
}
public override void Help(Player p)
{
Player.SendMessage(p, "/warn <player> [rule] - Warns a player for [rule] then sends them back to spawn. Example, /warn bob 2");
}
}
}
The defaut number of reasons is 7. If you must add more, Add this under the "else" in reason 7:
- Code: Select all
if (reason == "REASONNUMBER")
{
Player.GlobalMessage(who.color + who.PublicName + Server.DefaultColor + " was warned: " + c.white + "8. EDIT ONLY THIS PART ADD REASON HERE.");
Command.all.Find("spawn").Use(who, "");
}
else
If you have any problems with this let me know. I have a free week and i am able to fix it and get right back to you.