diff --git a/nuke_control.lua b/nuke_control.lua index a7e635ef..a6e0864e 100644 --- a/nuke_control.lua +++ b/nuke_control.lua @@ -1,7 +1,11 @@ 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) + elseif type(player) == "number" or type(player) == string then + return allowed_to_nuke(game.players[player]) + end end @@ -23,7 +27,7 @@ local function on_player_deconstructed_area(event) --Make them think they arent noticed 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 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_init = true + +--Never knew the debug code made it into the codebase lol local function on_player_mined_item(event) log_on_player_mined_entity("nuke_control.on_player_mined_item: entry", event) 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) end -local function on_research_finished(event) - if event.research.name == "artillery" then - game.print("Griefers are why we can't have nice things. Artillery targeting remote disabled.") - game.forces.player.recipes["artillery-targeting-remote"].enabled = false +global.players_warned = {} +local function on_capsule_used(event) + local player = game.players[event.player_index] + 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 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_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) +