include sourcemod include regex public Plugin myinfo name ipblocker au

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <sourcemod>
#include <regex>
public Plugin:myinfo =
{
name = "ipblocker",
author = "ExoIT",
description = "",
version = "1.0.0",
url = "http://..."
};
new Handle:h_Pattern = INVALID_HANDLE;
new bool:warnings[MAXPLAYERS+1];
public OnPluginStart()
{
RegConsoleCmd("say", SayCallBack);
RegConsoleCmd("say_team", SayCallBack);
h_Pattern = CompileRegex("([0-9]{1,3})[.|,]([0-9]{1,3})[.|,]([0-9]{1,3})[.|,]([0-9]{1,3})[:]?([0-9]{1,5})?");
}
public Action:SayCallBack(client, args)
{
decl String:message[128];
GetCmdArgString(message, sizeof(message));
TrimString(message);
ReplaceString(message, sizeof(message), " ", "");
if(MatchRegex(h_Pattern, message) > 0)
{
if(warnings[client])
BanClient(client, 3600, BANFLAG_AUTHID, "Реклама", "Вы были забанены за рекламу");
warnings[client] = true;
PrintToChat(client, "[SM] На сервере реклама запрещена! (последнее предупреждение)");
return Plugin_Handled;
}
return Plugin_Continue;
}
public OnClientDisconnect_Post(client)
{
warnings[client] = false;
}