1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-22 03:38:48 +02:00
ComfyFactorio/antigrief.lua

48 lines
1.8 KiB
Lua
Raw Normal View History

local event = require 'utils.event'
local function on_marked_for_deconstruction(event)
local player = game.players[event.player_index]
2018-09-23 03:17:31 +02:00
if player.admin == true then return end
local playtime = player.online_time
if global.player_totals then
if global.player_totals[player.name] then
playtime = player.online_time + global.player_totals[player.name][1]
end
end
if playtime < 1296000 then
event.entity.cancel_deconstruction(game.players[event.player_index].force.name)
2018-09-23 03:17:31 +02:00
player.print("You have not grown accustomed to this technology yet.", { r=0.22, g=0.99, b=0.99})
end
end
2018-09-23 03:17:31 +02:00
local function on_player_ammo_inventory_changed(event)
local player = game.players[event.player_index]
2018-09-23 03:17:31 +02:00
if player.admin == true then return end
local playtime = player.online_time
if global.player_totals then
if global.player_totals[player.name] then
playtime = player.online_time + global.player_totals[player.name][1]
end
2018-09-23 03:17:31 +02:00
end
if playtime < 1296000 then
2018-09-23 03:17:31 +02:00
local nukes = player.remove_item({name="atomic-bomb", count=1000})
if nukes > 0 then
player.surface.spill_item_stack(player.position, {name = "atomic-bomb", count = nukes}, false)
player.print("You have not grown accustomed to this technology yet.", { r=0.22, g=0.99, b=0.99})
end
end
end
local function on_console_command(event)
if event.command ~= "silent-command" then return end
local player = game.players[event.player_index]
for _, p in pairs(game.connected_players) do
if p.admin == true and p.name ~= player.name then
p.print(player.name .. " did a silent-command: " .. event.parameters, { r=0.22, g=0.99, b=0.99})
end
end
end
2018-09-23 03:17:31 +02:00
event.add(defines.events.on_console_command, on_console_command)
event.add(defines.events.on_player_ammo_inventory_changed, on_player_ammo_inventory_changed)
event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)