Skip to content

Commit c199344

Browse files
Update codestyle for AntiFlood (#246)
* antiflood: update codestyle like in a whole project * antiflood: delete multi-lang for cvars * antiflood: update codestyle for cvars
1 parent ad461b6 commit c199344

File tree

2 files changed

+74
-97
lines changed

2 files changed

+74
-97
lines changed

cstrike/addons/amxmodx/data/lang/CA_AntiFlood.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,8 @@ CA_ANTIFLOOD_CHAT_PREFIX = ^1[^4AntiFlood^1]
44
CA_ANTIFLOOD_CHAT_STOP_FLOODING = ^1Stop ^3flooding.
55
CA_ANTIFLOOD_CHAT_EQUAL_MESSAGE = ^1Your message ^3is repeated! ^4Exercise your imagination.
66

7-
CA_ANTIFLOOD_CVAR_TIME = Time between messages^n0.0 - no limit
8-
CA_ANTIFLOOD_CVAR_EQUAL_MESSAGES = How many identical messages can be written in a row^n0 - no limit
9-
107
[ru]
118
CA_ANTIFLOOD_CHAT_PREFIX = ^1[^4AntiFlood^1]
129

1310
CA_ANTIFLOOD_CHAT_STOP_FLOODING = ^1Прекратите ^3флудить.
14-
CA_ANTIFLOOD_CHAT_EQUAL_MESSAGE = ^1Сообщение ^3повторяется! ^4Проявите фантазию.
15-
16-
CA_ANTIFLOOD_CVAR_TIME = Время между сообщениями^n0.0 - без ограничений
17-
CA_ANTIFLOOD_CVAR_EQUAL_MESSAGES = Сколько одинаковых сообщений можно написать подряд^n0 - без ограничений
11+
CA_ANTIFLOOD_CHAT_EQUAL_MESSAGE = ^1Сообщение ^3повторяется! ^4Проявите фантазию.
Lines changed: 73 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,104 @@
11
#include <amxmodx>
22
#include <ChatAdditions>
33

4-
#define GetCvarDesc(%0) fmt("%L", LANG_SERVER, %0)
4+
#pragma ctrlchar '\'
5+
#pragma tabsize 2
56

6-
new g_szOldMessage[MAX_PLAYERS + 1][CA_MAX_MESSAGE_SIZE];
7+
new g_OldMessage[MAX_PLAYERS + 1][CA_MAX_MESSAGE_SIZE]
78

8-
enum _:Cvars
9-
{
10-
Float:ca_anti_flood_time,
11-
ca_equal_messages
12-
};
13-
14-
new g_pCvarValue[Cvars];
9+
new Float: ca_anti_flood_time,
10+
ca_equal_messages
1511

16-
public stock const PluginName[] = "CA: Anti Flood";
17-
public stock const PluginVersion[] = CA_VERSION;
18-
public stock const PluginAuthor[] = "Nordic Warrior";
19-
public stock const PluginURL[] = "https://github.com/ChatAdditions";
20-
public stock const PluginDescription[] = "Antiflood for chat";
12+
public stock const PluginName[] = "CA: Anti Flood"
13+
public stock const PluginVersion[] = CA_VERSION
14+
public stock const PluginAuthor[] = "Nordic Warrior"
15+
public stock const PluginURL[] = "https://github.com/ChatAdditions"
16+
public stock const PluginDescription[] = "Antiflood for chat"
2117

22-
public plugin_init()
23-
{
24-
register_plugin(PluginName, PluginVersion, PluginAuthor);
18+
public plugin_init() {
19+
register_plugin(PluginName, PluginVersion, PluginAuthor)
2520

26-
register_dictionary("CA_AntiFlood.txt");
21+
register_dictionary("CA_AntiFlood.txt")
2722

28-
CreateCvars();
29-
AutoExecConfig(true, "CA_AntiFlood", "ChatAdditions");
23+
CreateCVars()
24+
AutoExecConfig(true, "CA_AntiFlood", "ChatAdditions")
3025
}
3126

32-
public plugin_cfg()
33-
{
34-
if(find_plugin_byfile("antiflood.amxx") != INVALID_PLUGIN_ID)
35-
{
36-
log_amx("Default plugin <antiflood.amxx> was found. Stopped.");
37-
pause("acd", "antiflood.amxx");
38-
}
27+
public plugin_cfg() {
28+
if(find_plugin_byfile("antiflood.amxx") != INVALID_PLUGIN_ID) {
29+
log_amx("Default plugin <antiflood.amxx> was found. Stopped.")
30+
pause("acd", "antiflood.amxx")
31+
}
3932
}
4033

41-
public CA_Client_Say(id, const szMessage[])
42-
{
43-
return CheckMessage(id, szMessage);
34+
public CA_Client_Say(id, const message[]) {
35+
return CheckMessage(id, message)
4436
}
4537

46-
public CA_Client_SayTeam(id, const szMessage[])
47-
{
48-
return CheckMessage(id, szMessage);
38+
public CA_Client_SayTeam(id, const message[]) {
39+
return CheckMessage(id, message)
4940
}
5041

51-
CheckMessage(id, const szMessage[])
52-
{
53-
if(szMessage[0] == '/')
54-
{
55-
return CA_CONTINUE;
56-
}
42+
CheckMessage(id, const message[]) {
43+
if(message[0] == '/') {
44+
return CA_CONTINUE;
45+
}
5746

58-
static Float:flNextMessage[MAX_PLAYERS + 1];
59-
static iEqualMessage[MAX_PLAYERS + 1];
47+
static Float:nextMessage[MAX_PLAYERS + 1]
48+
static equalMessage[MAX_PLAYERS + 1]
6049

61-
new Float:flNextSay = get_gametime();
50+
new Float:nextSay = get_gametime()
6251

63-
if(flNextMessage[id] > flNextSay)
64-
{
65-
client_print_color(id, print_team_red, "%L %L", id, "CA_ANTIFLOOD_CHAT_PREFIX", id, "CA_ANTIFLOOD_CHAT_STOP_FLOODING");
66-
flNextMessage[id] = flNextSay + g_pCvarValue[ca_anti_flood_time];
52+
if(nextMessage[id] > nextSay) {
53+
client_print_color(id, print_team_red, "%L %L", id, "CA_ANTIFLOOD_CHAT_PREFIX", id, "CA_ANTIFLOOD_CHAT_STOP_FLOODING")
54+
nextMessage[id] = nextSay + ca_anti_flood_time
6755

68-
return CA_SUPERCEDE;
69-
}
56+
return CA_SUPERCEDE
57+
}
7058

71-
if(strcmp(szMessage, g_szOldMessage[id], true) == 0)
72-
{
73-
if(++iEqualMessage[id] >= g_pCvarValue[ca_equal_messages])
74-
{
75-
client_print_color(id, print_team_red, "%L %L", id, "CA_ANTIFLOOD_CHAT_PREFIX", id, "CA_ANTIFLOOD_CHAT_EQUAL_MESSAGE");
59+
if(strcmp(message, g_OldMessage[id], true) == 0) {
60+
if(++equalMessage[id] >= ca_equal_messages) {
61+
client_print_color(id, print_team_red, "%L %L", id, "CA_ANTIFLOOD_CHAT_PREFIX", id, "CA_ANTIFLOOD_CHAT_EQUAL_MESSAGE")
7662

77-
return CA_SUPERCEDE;
78-
}
79-
}
80-
else
81-
{
82-
iEqualMessage[id] = 0;
63+
return CA_SUPERCEDE
8364
}
65+
}
66+
else {
67+
equalMessage[id] = 0
68+
}
8469

85-
flNextMessage[id] = flNextSay + g_pCvarValue[ca_anti_flood_time];
86-
copy(g_szOldMessage[id], charsmax(g_szOldMessage[]), szMessage);
70+
nextMessage[id] = nextSay + ca_anti_flood_time
71+
copy(g_OldMessage[id], charsmax(g_OldMessage[]), message)
8772

88-
return CA_CONTINUE;
73+
return CA_CONTINUE
8974
}
9075

91-
public client_disconnected(id)
92-
{
93-
g_szOldMessage[id][0] = EOS;
76+
public client_disconnected(id) {
77+
g_OldMessage[id][0] = EOS
9478
}
9579

96-
CreateCvars()
97-
{
98-
bind_pcvar_float(
99-
create_cvar(
100-
.name = "ca_anti_flood_time",
101-
.string = "0.75",
102-
.description = GetCvarDesc("CA_ANTIFLOOD_CVAR_TIME"),
103-
.has_min = true,
104-
.min_val = 0.0
105-
),
106-
107-
g_pCvarValue[ca_anti_flood_time]
108-
);
109-
110-
bind_pcvar_num(
111-
create_cvar(
112-
.name = "ca_equal_messages",
113-
.string = "2",
114-
.description = GetCvarDesc("CA_ANTIFLOOD_CVAR_EQUAL_MESSAGES"),
115-
.has_min = true,
116-
.min_val = 0.0
117-
),
118-
119-
g_pCvarValue[ca_equal_messages]
120-
);
80+
CreateCVars() {
81+
bind_pcvar_float(
82+
create_cvar(
83+
.name = "ca_anti_flood_time",
84+
.string = "0.75",
85+
.description = "Time between messages\n 0.0 - no limit",
86+
.has_min = true,
87+
.min_val = 0.0
88+
),
89+
90+
ca_anti_flood_time
91+
)
92+
93+
bind_pcvar_num(
94+
create_cvar(
95+
.name = "ca_equal_messages",
96+
.string = "2",
97+
.description = "How many identical messages can be written in a row\n 0 - no limit",
98+
.has_min = true,
99+
.min_val = 0.0
100+
),
101+
102+
ca_equal_messages
103+
)
121104
}

0 commit comments

Comments
 (0)