1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-12 02:28:02 +02:00

implemented auto kick/ban

This commit is contained in:
Maik Wild 2017-12-25 23:00:24 +01:00
parent 53765632ea
commit 4a47033955

View File

@ -1,7 +1,11 @@
function allowed_to_nuke(player) function allowed_to_nuke(player)
if type(player) == "table" then
return player.admin or is_mod(player.name) or is_regular(player.name) or ((player.online_time / 216000) > global.scenario.config.nuke_min_time_hours) return player.admin or is_mod(player.name) or is_regular(player.name) or ((player.online_time / 216000) > global.scenario.config.nuke_min_time_hours)
elseif type(player) == "number" or type(player) == string then
return allowed_to_nuke(game.players[player])
end
end end
@ -23,7 +27,7 @@ local function on_player_deconstructed_area(event)
--Make them think they arent noticed --Make them think they arent noticed
print_except(player.name .. " tried to deconstruct something, but instead deconstructed himself.", player) print_except(player.name .. " tried to deconstruct something, but instead deconstructed himself.", player)
player.print("Only regulars can mark things for deconstruction.") player.print("Only regulars can mark things for deconstruction, if you want to deconstruct something you may ask an admin to promote you.")
player.character.health = 0 player.character.health = 0
local entities = player.surface.find_entities_filtered{area = event.area, force = player.force} local entities = player.surface.find_entities_filtered{area = event.area, force = player.force}
@ -44,6 +48,8 @@ end
global.on_player_mined_item_enabled = true global.on_player_mined_item_enabled = true
global.on_player_mined_item_init = true global.on_player_mined_item_init = true
--Never knew the debug code made it into the codebase lol
local function on_player_mined_item(event) local function on_player_mined_item(event)
log_on_player_mined_entity("nuke_control.on_player_mined_item: entry", event) log_on_player_mined_entity("nuke_control.on_player_mined_item: entry", event)
if global.on_player_mined_item_enabled then if global.on_player_mined_item_enabled then
@ -68,14 +74,25 @@ local function on_player_mined_item(event)
log_on_player_mined_entity("nuke_control.on_player_mined_item: exit", event) log_on_player_mined_entity("nuke_control.on_player_mined_item: exit", event)
end end
local function on_research_finished(event) global.players_warned = {}
if event.research.name == "artillery" then local function on_capsule_used(event)
game.print("Griefers are why we can't have nice things. Artillery targeting remote disabled.") local player = game.players[event.player_index]
game.forces.player.recipes["artillery-targeting-remote"].enabled = false if (not allowed_to_nuke(player)) then
local area = {{event.position.x-5, event.position.y-5}, {event.position.x+5, event.position.y+5}}
local count = player.surface.count_entities_filtered{force=player.force, area=area}
if count > 4 then
if global.players_warned[event.player_index] then
game.ban_player(player, string.format("Automagically banned because: damaged %i entities with %s. If you want to contest this ban please visit redmew.com/discord", count, event.item.name))
else
global.players_warned[event.player_index] = true
game.kick_player(player, string.format("Damaged %i entities with %s -Antigrief", count, event.item.name))
end
end
end end
end end
Event.register(defines.events.on_player_ammo_inventory_changed, ammo_changed) Event.register(defines.events.on_player_ammo_inventory_changed, ammo_changed)
Event.register(defines.events.on_player_deconstructed_area, on_player_deconstructed_area) Event.register(defines.events.on_player_deconstructed_area, on_player_deconstructed_area)
--Event.register(defines.events.on_player_mined_entity, on_player_mined_item) --Event.register(defines.events.on_player_mined_entity, on_player_mined_item)
Event.register(defines.events.on_research_finished, on_research_finished) Event.register(defines.events.on_player_used_capsule, on_capsule_used)