Add minor anticheat fixes

This commit is contained in:
kay27 2021-12-17 03:19:24 +04:00
parent 9d77c22c4f
commit 21f305e33a
1 changed files with 174 additions and 173 deletions

View File

@ -1,5 +1,5 @@
local flights_kick_threshold = 10 local flights_kick_threshold = 10
local suffocations_threshold = 1 local suffocations_kick_threshold = 1
local after = minetest.after local after = minetest.after
local get_connected_players = minetest.get_connected_players local get_connected_players = minetest.get_connected_players
@ -140,9 +140,9 @@ minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack
player_head_pos.y = player_head_pos.y + 1.5 player_head_pos.y = player_head_pos.y + 1.5
local player_head_distance = distance(pos, player_head_pos) local player_head_distance = distance(pos, player_head_pos)
if player_head_distance < 0.7 then if player_head_distance < 0.7 then
after(0.05, function() after(0.05, function(node)
set_node(pos, oldnode) set_node(pos, node)
end) end, oldnode)
is_choker = true is_choker = true
break break
end end
@ -154,16 +154,17 @@ minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack
local data = joined_players[name] local data = joined_players[name]
if not data then if not data then
joined_players[name].suffocations = 1 joined_players[name].suffocations = 1
data = joined_players[name]
else else
if not data.suffocations then if not data.suffocations then
data.suffocations = 1 data.suffocations = 1
else else
data.suffocations = data.suffocations + 1 data.suffocations = data.suffocations + 1
if data.suffocations >= suffocations_threshold then
kick_player(name, "choker")
end
end end
end end
if data.suffocations >= suffocations_kick_threshold then
kick_player(name, "choker")
end
end) end)
minetest.register_on_joinplayer(update_player) minetest.register_on_joinplayer(update_player)