ENG Text (Click to View)
RUS Text (Click to View)
Source code
PHP Code:
using System;
using Addon;
using System.IO;
using System.Collections.Generic;
namespace SC
{
public class BlockChat : CPlugin
{
string Chat = "plugins\\chatblocked.txt";
string Chat2;
public override void OnServerLoad()
{
ServerPrint("BlockerChat by S3VDIT0");
Chat2 = GetServerCFG("ServerControl", "BannedChatPlayerMess", "^2 !");
}
public override ChatType OnSay(string Message, ServerClient Client)
{
string[] parsed = Message.Split(null as char[], StringSplitOptions.RemoveEmptyEntries);
if (BlockedXUIDs(Client) == Client.XUID)
{
TellClient(Client.ClientNum, Chat2, true);
return ChatType.ChatNone;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (Message.StartsWith("!block") || Message.StartsWith("!b"))
{
if (parsed.Length > 1)
{
ServerClient client = findClient(parsed[1]);
if (client != null)
{
ServerClient client2 = findClient(parsed[1]);
using (StreamWriter writer = new StreamWriter(Chat, true))
{
writer.WriteLine(client2.XUID.ToLower());
}
String block = GetServerCFG("ServerControl", "SayCB", "^2 ^7<playername> ^2 !");
block = block.Replace("<playername>", client2.Name);
ServerSay(block, true);
return ChatType.ChatNone;
}
if (client == null)
{
TellClient(Client.ClientNum, "^1 !", true);
return ChatType.ChatNone;
}
}
else
{
TellClient(Client.ClientNum, "^7: ^2!block/!b ^7<playername>", true);
}
return ChatType.ChatNone;
}
/////////////////////////////////////////////////////////////////////////////////////////
return ChatType.ChatContinue;
}
public string BlockedXUIDs(ServerClient Client)
{
List<string> XUID = new List<string>(File.ReadAllLines(Chat));
for (int i = 0; i < XUID.Count; i++)
{
string line = XUID[i];
string CX = XUID[i];
if (CX == Client.XUID)
{
return CX;
}
}
return null;
}
//FindClient
public ServerClient findClient(String clientName)
{
clientName = clientName.Trim();
int clientCount = 0;
ServerClient client = null;
List<ServerClient> clientList = GetClients();
foreach (ServerClient currClient in clientList)
{
if (0 <= currClient.Name.IndexOf(clientName, StringComparison.InvariantCultureIgnoreCase))
{
client = currClient;
clientCount++;
}
}
if (clientCount > 1)
{
return null;
}
else if (clientCount == 1)
{
return client;
}
return null;
}
}
}
Credits:
@S3VDIT0 - Made the plugin
@frst_ - Special thanks