-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathanticheat.sp
216 lines (175 loc) · 5.6 KB
/
anticheat.sp
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
216
#pragma semicolon 1
#pragma newdecls required
//sourcemod base
#include <sourcemod>
//plugin base
#include <kcf_core>
#include <kcf_bans>
// ...
#include <smutils>
#include <ins_supporter>
public Plugin myinfo =
{
name = "Anti Cheat",
author = "Kyle",
description = "<- description ->",
version = "1.0",
url = "https://www.kxnrl.com"
};
enum struct Data {
int m_Kills;
int m_Death;
int m_NadeKillStreak;
int m_NadeKillsTrack;
int m_TeamKillStreak;
int m_TeamKillsTrack;
int m_NoobSpawnTrack;
}
Data g_Client[MAXPLAYERS+1];
StringMap g_Queue;
public void OnPluginStart()
{
SMUitls_InitUserMessage();
SMUtils_SetChatPrefix("[{purple}魔法少女{white}]");
SMUtils_SetChatSpaces(" ");
HookEvent("player_spawn", Event_OnSpawn, EventHookMode_Post);
HookEvent("player_death", Event_OnDeath, EventHookMode_Post);
g_Queue = new StringMap();
}
public void OnClientConnected(int client)
{
g_Client[client].m_Kills = 0;
g_Client[client].m_Death = 0;
resetClient(client);
}
static void resetClient(int client)
{
g_Client[client].m_NadeKillStreak = 0;
g_Client[client].m_NadeKillsTrack = 0;
g_Client[client].m_TeamKillStreak = 0;
g_Client[client].m_TeamKillsTrack = 0;
g_Client[client].m_NoobSpawnTrack = GetTime();
}
public void Event_OnSpawn(Event e, const char[] name, bool db)
{
resetClient(GetClientOfUserId(e.GetInt("userid")));
}
public void Event_OnDeath(Event e, const char[] name, bool db)
{
int killer = GetClientOfUserId(e.GetInt("attacker"));
int victim = GetClientOfUserId(e.GetInt("userid"));
if (IsClientInQueue(killer))
return;
if (killer == victim)
return;
int currentTime = GetTime();
if (GetClientTeam(killer) == GetClientTeam(victim))
{
if (++g_Client[killer].m_TeamKillStreak < 2)
{
// ignore
g_Client[killer].m_TeamKillsTrack = currentTime;
return;
}
int diff = currentTime - g_Client[killer].m_TeamKillsTrack;
if (diff < 30)
{
//ForcePlayerSuicide(killer);
ChatAll("{red}%N{silver}因为恶意TK被放风筝并减少1点补给点...", killer);
SetEntProp(killer, Prop_Send, "m_nRecievedTokens", GetEntProp(killer, Prop_Send, "m_nRecievedTokens")-1);
CreateTimer(0.5, Timer_Kite, e.GetInt("attacker"), TIMER_REPEAT);
}
else if (diff < 15)
{
ChatAll("{red}%N{silver}因为恶意TK已被封禁...", killer);
KCF_Ban_BanClient(0, killer, 0, 120, "恶意TK队友");
}
// done;
g_Client[killer].m_TeamKillsTrack = currentTime;
return;
}
g_Client[victim].m_Death++;
char weapon[32];
e.GetString("weapon", weapon, 32);
// explosion
if (StrContains(weapon, "grenade", false) != -1 || StrContains(weapon, "rocket", false) != -1)
{
int diff = currentTime - g_Client[killer].m_NadeKillsTrack;
if (diff > 10)
{
// ignore
g_Client[killer].m_NadeKillsTrack = currentTime;
g_Client[killer].m_NadeKillStreak = 0;
return;
}
int time = currentTime - g_Client[victim].m_NoobSpawnTrack;
if (time > 15)
{
// ignore
g_Client[killer].m_NadeKillsTrack = currentTime;
return;
}
g_Client[killer].m_NadeKillStreak++;
if (g_Client[killer].m_NadeKillStreak >= 6)
{
ChatAll("{red}%N{silver}因为数据异常已被制裁60分钟...", killer);
KCF_Ban_BanClient(0, killer, 2, 60, "侦测到数据异常[0x0D]");
ClientEnqueue(killer, 60);
}
else if (g_Client[killer].m_NadeKillStreak >= 3)
{
ChatAll("{red}%N{silver}因为数据异常已被处死...", killer);
ForcePlayerSuicide(killer);
}
// done;
return;
}
g_Client[killer].m_Kills++;
if (g_Client[killer].m_Kills < 30)
return;
float kd = g_Client[killer].m_Kills / float(g_Client[killer].m_Death == 0 ? 1 : g_Client[killer].m_Death);
if (kd >= 10.0)
{
ChatAll("{red}%N{silver}因为数据异常已被制裁10080分钟...", killer);
KCF_Ban_BanClient(0, killer, 2, 10080, "侦测到数据异常[0x0A]");
ClientEnqueue(killer, 10080);
}
else if (kd >= 8.0)
{
ChatAll("{red}%N{silver}因为数据异常已被制裁1440分钟...", killer);
KCF_Ban_BanClient(0, killer, 2, 1440, "侦测到数据异常[0x0B]");
ClientEnqueue(killer, 1440);
}
else if (kd >= 6.0)
{
ChatAll("{red}%N{silver}因为数据异常已被制裁60分钟...", killer);
KCF_Ban_BanClient(0, killer, 2, 60, "侦测到数据异常[0x0C]");
ClientEnqueue(killer, 60);
}
}
public Action Timer_Kite(Handle timer, int userid)
{
int client = GetClientOfUserId(userid);
if (!client || !IsClientInGame(client) || !IsPlayerAlive(client))
return Plugin_Stop;
if (GetClientHealth(client) <= 2)
ForcePlayerSuicide(client);
else
SlapPlayer(client, 2, true);
return Plugin_Continue;
}
static bool IsClientInQueue(int client)
{
char authid[32];
GetClientAuthId(client, AuthId_SteamID64, authid, 32);
int value = -1;
if (!g_Queue.GetValue(authid, value))
return false;
return GetTime() <= value;
}
static bool ClientEnqueue(int client, int minutes)
{
char authid[32];
GetClientAuthId(client, AuthId_SteamID64, authid, 32);
return g_Queue.SetValue(authid, GetTime() + minutes * 60, true);
}