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.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
213.
214.
215. | #define PLUGINNAME "Don't say IPs by Pavulon"
#define VERSION "0.2"
#define AUTHOR "JGHG"
/*
Copyleft 2005
Plugin topic: http://www.amxmodx.org/forums/viewtopic.php?p=90172
Don't say IPs
=============
Messages like "hey join my server 213.34.231.23" are automatically blocked... and another message is printed instead. :-P
Or, you can choose to just ban violators by setting cvar ip_banviolators to 1 and ip_banminutes to how many minutes the violator should be banned. 0 is permanent, 5 is default.
/JGHG
VERSIONS
========
050204 0.1 First version
CREDITS
=======
Requested by lord_inuyasha88.
*/
#include <amxmodx>
#include <fakemeta>
#include <regex>
//#define PATTERN "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" // \b
//#define PATTERN "([0-9].*[\., ].*[0-9].*[\., ].*[0-9].*[\., ].*[0-9])"
#define PATTERN "([0-9].*[\., ].*[0-9].*[\., ].*[0-9].*[\., ].*[0-9])|(www\.)|(\.pl)|(\.com)|(\.ru)|(\.de)|(\.net)|(\.info)|(\.org)|(\.biz)|(\.nl)|(\.lt)|(\.eu)|(\.name)"
#define REASON "reklama IP"
#define CVAR_BANMINUTES "ip_banminutes"
#define CVAR_BANVIOLATORS "ip_banviolators"
#define CVAR_BANTIMES "ip_bantimes"
#define TEKST "Ale ten serwer jest zajebisty!"
// Globals below
new Regex:g_result
new g_returnvalue
new g_error[64]
new times[32]
new g_allArgs[1024]
new banuids[33]
new banname[33][32]
new const g_name[] = "name"
new /* const */ g_name_change[] = "#Cstrike_Name_Change"
new g_msgid_saytext
// Globals above
public plugin_init()
{
register_plugin(PLUGINNAME, VERSION, AUTHOR)
register_clcmd("say", "hook_say")
register_clcmd("say_team", "hook_say")
register_cvar(CVAR_BANVIOLATORS, "1")
register_cvar(CVAR_BANMINUTES, "30")
register_cvar(CVAR_BANTIMES, "3")
register_dictionary("admincmd.txt")
register_forward(FM_ClientUserInfoChanged, "forward_client_userinfochanged")
g_msgid_saytext = get_user_msgid("SayText")
}
public plugin_modules()
{
require_module("regex")
}
public forward_client_userinfochanged(id, buffer)
{
if (is_user_bot(id))
return PLUGIN_HANDLED
if (is_user_hltv(id))
{
server_print("Found HLTV")
return PLUGIN_HANDLED
}
if (!is_user_connected(id))
return FMRES_IGNORED
static name[32]
engfunc(EngFunc_InfoKeyValue, buffer, g_name, name, sizeof name - 1)
if (get_user_flags(id)&ADMIN_RESERVATION)
return FMRES_IGNORED
look4(name,id, 2)
return FMRES_SUPERCEDE
}
msg_name_change(id, /* const */ oldname[])
{
client_cmd(id,"name ^"%s^"",TEKST)
message_begin(MSG_BROADCAST, g_msgid_saytext)
write_byte(id)
write_string(g_name_change)
write_string(oldname)
write_string(TEKST)
message_end()
}
public hook_say(id, level, cid)
{
if (is_user_bot(id))
return PLUGIN_HANDLED
if (is_user_hltv(id))
{
server_print("Found HLTV")
return PLUGIN_HANDLED
}
if ( (get_user_flags(id)&ADMIN_RESERVATION) || !id )
return PLUGIN_CONTINUE
read_args(g_allArgs, 1023)
if (look4(g_allArgs,id, 1)==1)
return PLUGIN_HANDLED
return PLUGIN_CONTINUE
}
public look4(g_allArgs[],id, type)
{
g_result = regex_match(g_allArgs, PATTERN, g_returnvalue, g_error, 63, "i")
switch (g_result) {
case REGEX_MATCH_FAIL: {
log_amx("REGEX_MATCH_FAIL! %s", g_error)
return PLUGIN_CONTINUE
}
case REGEX_PATTERN_FAIL: {
log_amx("REGEX_PATTERN_FAIL! %s", g_error)
return PLUGIN_CONTINUE
}
case REGEX_NO_MATCH: {
return PLUGIN_CONTINUE
}
default: {
if (type==1) times[id]++
new authid[32]
get_user_authid(id, authid, 31)
new name[32]
get_user_name(id, name, 31)
if (get_cvar_num(CVAR_BANVIOLATORS)&×[id]>=get_cvar_num(CVAR_BANTIMES)
|| get_cvar_num(CVAR_BANVIOLATORS)&&type==2) {
banuids[id] = get_user_userid(id)
format(banname[id], 31, "%s", g_allArgs)
new minutesString[10]
get_cvar_string(CVAR_BANMINUTES, minutesString, 9)
new temp[64], banned[16], minutes = get_cvar_num(CVAR_BANMINUTES)
if (minutes)
format(temp, 63, "%L", id, "FOR_MIN", minutesString)
else
format(temp, 63, "%L", id, "PERM")
format(banned, 15, "%L", id, "BANNED")
log_amx("%s (%s), %s %s %s. This was written: ^"%s^"", name, authid, banned, temp, REASON, g_allArgs)
new userid[1]
userid[0] = id
set_task(0.1,"cmd_ban",id, userid, 1)
}
if (type==1)
{
client_print(0, print_chat, "%s: %s", name, TEKST)
server_cmd("amx_chat %s (%s): ^"%s^"", name, authid, g_allArgs)
regex_free(g_result)
return 1 // block msg
} else
if (type==2)
{
new username[32]
get_user_name(id, username, 31)
msg_name_change(id, username)
server_cmd("amx_chat %s (%s): ^"%s^"", username, authid, name)
}
}
}
return PLUGIN_CONTINUE
}
public cmd_ban(userid[])
{
new id = userid[0]
new username[32]
get_user_name(id, username, 31)
if (!equal(username, banname[id]))
{
new minutes = get_cvar_num(CVAR_BANMINUTES)
server_cmd("amx_ban %d #%d %s", minutes, banuids[id], REASON)
} else
set_task(1.0,"cmd_ban",id, userid, 1)
}
public client_connect(id)
{
times[id]=0
format(banname[id], 32, "")
}
public client_disconnect(id)
{
times[id]=0
format(banname[id], 32, "")
} |