04-10-2012, 00:19
(04-10-2012, 00:04)masterbob Wrote:I hope this is what you needed. It should workSpoiler (Click to View)PHP Code:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Addon;
namespace ClassLibrary1
{
public class Class1 : CPlugin
{
string file = "forbidden.txt";//located in the call of duty modern warfare 3 folder
List<string> fwords = new List<string>();
public override void OnServerLoad()
{
try
{
ServerPrint("Forbidden Names: ");
refreshwords();
}
catch { ServerPrint(file + " not found"); }
}
public override void OnPlayerConnect(ServerClient Client)
{
string[] cn = Client.Name.Split(' ');
foreach (string x in cn)
{
if (fwords.Contains(x))
ServerCommand("kick \"" + Client.Name+ "\" + HOMO");
}
}
public override ChatType OnSay(string Message, ServerClient Client)
{
string[] msg = Message.Split(' ');
try
{
if (msg[0] == "!add" && !fwords.Contains(msg[1]))
{
string old = ReadFile(file);
WriteFile(file, old + " " + msg[1]);
TellClient(Client.ClientNum, msg[1] + " added.", true);
refreshwords();
return ChatType.ChatNone;
}
if (msg[0] == "!show")
printwords();
} catch { ServerSay(file + " not found",true); }
return ChatType.ChatAll;
}
void refreshwords()
{
try
{
string[] words = ReadFile(file).Split(' ');
foreach (string x in words)
{
ServerPrint(x + "\n");
fwords.Add(x);
}
}catch{ ServerPrint(file + " not found"); }
}
void printwords()
{
ServerSay("Forbidden Names: ", true);
foreach (string x in fwords)
{
ServerSay(x,true);
}
}
public string ReadFile(String sFilename) //http://www.tsql.de/csharp/csharp_textdatei
{
string sContent = "";
if (File.Exists(sFilename))
{
StreamReader myFile = new StreamReader(sFilename, System.Text.Encoding.Default);
sContent = myFile.ReadToEnd();
myFile.Close();
}
return sContent;
}
public void WriteFile(String sFilename, String sLines) //http://www.tsql.de/csharp/csharp_textdatei
{
StreamWriter myFile = new StreamWriter(sFilename);
myFile.Write(sLines);
myFile.Close();
}
}
}
I appreciate that but I don't know the first thing about creating the .dll...