Spoiler:
/*
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;
namespace MCDzienny
{
public class CmdWarn : 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 "warn"; } }
// 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 resone = "You Know Why";
string[] mess = message.Split(' ');
if (p == null) { Player.SendMessage(p, "This command can only be used in-game!"); return; }
if (message == "") { Help(p); return; }
if (mess.Length >= 2)
{
resone = mess[1];
for (int i = 2; i < mess.Length; i++)
{
resone = resone + " " + mess[i];
}
}
Player who = Player.Find(mess[0]);
if (who == null)
{
Player.SendMessage(p, "Could not find player specified!");
return;
}
if (who.group.Permission >= p.group.Permission)
{
Player.GlobalChat(p, p.color + p.name + " " + Server.DefaultColor + "tried to Warn " + who.color + who.name + " " + Server.DefaultColor + "but failed!", false);
return;
}
try
{
if (!who.ExtraData.ContainsKey("warn"))
{
who.ExtraData.Add("warn", 0);
}
else
{
who.ExtraData["warn"] = (int)who.ExtraData["warn"] + 1;
}
if ((int)who.ExtraData["warn"] == 1)
{
Player.GlobalChat(p, p.color + p.name + Server.DefaultColor + " Warnd " + who.color + who.name + " %4 because: " + resone);
Player.GlobalChat(p, who.color + who.name + Server.DefaultColor + " more 2 times and you kick");
}
else
{
if ((int)who.ExtraData["warn"] == 2)
{
Player.GlobalChat(p, p.color + p.name + Server.DefaultColor + " Warnd " + who.color + who.name + " %4 because: " + resone);
Player.GlobalChat(p, who.color + who.name + Server.DefaultColor + " more 1 times and you kick");
}
else
{
Player.GlobalChat(p, p.color + p.name + Server.DefaultColor + " Warnd " + who.color + who.name + " %4 because: " + resone);
Player.GlobalChat(p, who.color + who.name + Server.DefaultColor + " is kick");
Command.all.Find("kick").Use(p, who.name);
who.ExtraData["warn"] = 0;
}
}
}
catch
{
}
}
// This one controls what happens when you use /help [commandname].
public override void Help(Player p)
{
Player.SendMessage(p, "/warn - Warn someone");
}
}
}
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;
namespace MCDzienny
{
public class CmdWarn : 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 "warn"; } }
// 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 resone = "You Know Why";
string[] mess = message.Split(' ');
if (p == null) { Player.SendMessage(p, "This command can only be used in-game!"); return; }
if (message == "") { Help(p); return; }
if (mess.Length >= 2)
{
resone = mess[1];
for (int i = 2; i < mess.Length; i++)
{
resone = resone + " " + mess[i];
}
}
Player who = Player.Find(mess[0]);
if (who == null)
{
Player.SendMessage(p, "Could not find player specified!");
return;
}
if (who.group.Permission >= p.group.Permission)
{
Player.GlobalChat(p, p.color + p.name + " " + Server.DefaultColor + "tried to Warn " + who.color + who.name + " " + Server.DefaultColor + "but failed!", false);
return;
}
try
{
if (!who.ExtraData.ContainsKey("warn"))
{
who.ExtraData.Add("warn", 0);
}
else
{
who.ExtraData["warn"] = (int)who.ExtraData["warn"] + 1;
}
if ((int)who.ExtraData["warn"] == 1)
{
Player.GlobalChat(p, p.color + p.name + Server.DefaultColor + " Warnd " + who.color + who.name + " %4 because: " + resone);
Player.GlobalChat(p, who.color + who.name + Server.DefaultColor + " more 2 times and you kick");
}
else
{
if ((int)who.ExtraData["warn"] == 2)
{
Player.GlobalChat(p, p.color + p.name + Server.DefaultColor + " Warnd " + who.color + who.name + " %4 because: " + resone);
Player.GlobalChat(p, who.color + who.name + Server.DefaultColor + " more 1 times and you kick");
}
else
{
Player.GlobalChat(p, p.color + p.name + Server.DefaultColor + " Warnd " + who.color + who.name + " %4 because: " + resone);
Player.GlobalChat(p, who.color + who.name + Server.DefaultColor + " is kick");
Command.all.Find("kick").Use(p, who.name);
who.ExtraData["warn"] = 0;
}
}
}
catch
{
}
}
// This one controls what happens when you use /help [commandname].
public override void Help(Player p)
{
Player.SendMessage(p, "/warn - Warn someone");
}
}
}
that kick someone when I use this 3 times but it need be is times