-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
70 lines (64 loc) · 2.08 KB
/
Copy pathinit.lua
File metadata and controls
70 lines (64 loc) · 2.08 KB
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
local check_time = tonumber(core.settings:get("anticheatf_check_time")) or 5 -- In secs
local suspected = {}
minetest.register_on_leaveplayer(function(name)
if suspected[name] ~= nil then
suspected[name] = nil
end
end)
local function check_fly(player)
local name = player:get_player_name()
local vel = player:get_player_velocity()
local pos = player:get_pos()
pos.y = pos.y - 2
if not minetest.check_player_privs(name, {fly = true}) then
if minetest.get_node(pos).name == "air" then
if vector.length(vel) > 3 then
if suspected[name] ~= nil then
suspected[name] = suspected[name] + 1
else
suspected[name] = 1
end
end
end
end
end
local function check_noclip(player)
local name = player:get_player_name()
local vel = player:get_player_velocity()
local pos = player:get_pos()
if not minetest.check_player_privs(name, {noclip = true}) then
if minetest.get_node(pos).name ~= "air" then
if vector.length(vel) > 3 then
if suspected[name] ~= nil then
suspected[name] = suspected[name] + 1
else
suspected[name] = 1
end
end
end
end
end
local timer = 0
local timer2 = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime
timer2 = timer2 + dtime
if timer >= check_time then
timer = 0
for _, player in ipairs(minetest.get_connected_players()) do
check_fly(player)
check_noclip(player)
local name = player:get_player_name()
if suspected[name] == 3 then
suspected[name] = 0
minetest.kick_player(name, "You was suspected of using cheats (AntiCheat)")
end
if timer2 >= 60 then
timer2 = 0
if suspected[name] ~= nil or suspected[name] ~= 0 then
suspected[name] = 0
end
end
end
end
end)