- Code: Select all
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using MCDzienny;
namespace MCDzienny
{
public class CmdChatFilter : Command
{
public override string name { get { return "cf"; } }
public override string shortcut { get { return ""; } }
public override string type { get { return ""; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
private static string Caps = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static int maxcaps = 5;
public override void Init()
{
Player.PlayerChatEvent += FilterChat;
}
private void FilterChat(Player p, ref string message, ref bool stopIt)
{
//Check for caps
int caps = 0;
string changedMessage = message;
foreach (char c in changedMessage)
{
foreach (char s in Caps)
{
if (c == s)
{
caps++;
}
}
}
string msg;
if (caps > maxcaps)
{
msg = changedMessage.ToLower();
}
else
{
msg = changedMessage;
}
//Check for bad words
string[] strBadWords = new string[] {
"duck",
"poo",
};
foreach (string badWord in strBadWords)
{
msg = msg.Replace(badWord, "***");
}
message = msg;
}
public override void Help(Player p)
{ }
public override void Use(Player p, string message)
{ }
}
}
The words duck and poo will be replaced by ***.
So if u write duck it will become ***
If u write ducks it will become ***s
Also, if a sentece has more then 5 capitical letters it will change everyone to lowercase.
U can change this in the top at maxcaps.
It's not perfect but it works.
U can't compile this in MCDzienny, u need windows c# studio. (its free)