1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-24 03:47:58 +02:00

Merge pull request #12 from M3wM3w/master

update from main
This commit is contained in:
hanakocz 2020-06-17 03:49:56 +02:00 committed by GitHub
commit 38a721f8f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 107 additions and 37 deletions

View File

@ -5,43 +5,73 @@ local Event = require 'utils.event'
local function admin_only_message(str)
for _, player in pairs(game.connected_players) do
if player.admin == true then
player.print("Admins-only-message: " .. str, {r=0.88, g=0.88, b=0.88})
player.print('Admins-only-message: ' .. str, {r = 0.88, g = 0.88, b = 0.88})
end
end
end
local jail_messages = {
"You´re done bud!",
"Busted!"
'You´re done bud!',
'Busted!'
}
local function jail(target_player, source_player)
local source = source_player.name or 'Server'
local permission_group = game.permissions.get_group("prisoner")
local permission_group = game.permissions.get_group('prisoner')
if not permission_group then
permission_group = game.permissions.create_group("prisoner")
permission_group = game.permissions.create_group('prisoner')
for action_name, _ in pairs(defines.input_action) do
permission_group.set_allows_action(defines.input_action[action_name], false)
if permission_group then
permission_group.set_allows_action(defines.input_action[action_name], false)
end
end
if permission_group then
permission_group.set_allows_action(defines.input_action.write_to_console, true)
permission_group.set_allows_action(defines.input_action.gui_click, true)
permission_group.set_allows_action(defines.input_action.gui_selection_state_changed, true)
end
permission_group.set_allows_action(defines.input_action.write_to_console, true)
permission_group.set_allows_action(defines.input_action.gui_click, true)
permission_group.set_allows_action(defines.input_action.gui_selection_state_changed, true)
end
permission_group.add_player(target_player.name)
game.print(target_player.name .. " has been jailed. " .. jail_messages[math.random(1, #jail_messages)], { r=0.98, g=0.66, b=0.22})
admin_only_message(target_player.name .. " was jailed by " .. source)
local permission_group_players = permission_group.players
for k, v in pairs(permission_group_players) do
if target_player.name == v.name then
source_player.print(target_player.name .. ' is already jailed.', {r = 0.98, g = 0.66, b = 0.22})
return
end
end
if permission_group then
permission_group.add_player(target_player.name)
end
game.print(
target_player.name .. ' has been jailed. ' .. jail_messages[math.random(1, #jail_messages)],
{r = 0.98, g = 0.66, b = 0.22}
)
admin_only_message(target_player.name .. ' was jailed by ' .. source)
end
local freedom_messages = {
"Yaay!",
"Welcome back!"
'Yaay!',
'Welcome back!'
}
local function free(target_player, source_player)
local source = source_player.name or 'Server'
local permission_group = game.permissions.get_group("Default")
permission_group.add_player(target_player.name)
game.print(target_player.name .. " was set free from jail. " .. freedom_messages[math.random(1, #freedom_messages)], { r=0.98, g=0.66, b=0.22})
admin_only_message(source .. " set " .. target_player.name .. " free from jail")
local permission_group = game.permissions.get_group('Default')
local permission_group_players = permission_group.players
if permission_group and permission_group_players then
for k, v in pairs(permission_group_players) do
if target_player.name == v.name then
source_player.print(target_player.name .. ' is already free.', {r = 0.98, g = 0.66, b = 0.22})
return
end
end
end
if permission_group then
permission_group.add_player(target_player.name)
end
game.print(
target_player.name .. ' was set free from jail. ' .. freedom_messages[math.random(1, #freedom_messages)],
{r = 0.98, g = 0.66, b = 0.22}
)
admin_only_message(source .. ' set ' .. target_player.name .. ' free from jail')
end
commands.add_command(
@ -56,7 +86,9 @@ commands.add_command(
if player then
if player ~= nil then
p = player.print
if not total_time[player.name] then goto continue end
if not total_time[player.name] then
goto continue
end
if total_time[player.name] < 51900000 then
if not player.admin then
p("You're not admin nor are you trusted enough to run this command!", {r = 1, g = 0.5, b = 0.1})
@ -65,22 +97,33 @@ commands.add_command(
end
end
if cmd.parameter == nil then return end
if cmd.parameter == nil then
return
end
local target_player = game.players[cmd.parameter]
if target_player then
if target_player.name == player.name then player.print("You can't jail yourself!", {r = 1, g = 0.5, b = 0.1}) return end
if target_player.name == player.name then
player.print("You can't jail yourself!", {r = 1, g = 0.5, b = 0.1})
return
end
trusted[target_player.name] = false
jail(target_player, player)
Server.to_discord_bold(table.concat{'[Jailed] ' .. target_player.name .. ' has been jailed by ' .. player.name .. '!'})
Server.to_discord_bold(
table.concat {'[Jailed] ' .. target_player.name .. ' has been jailed by ' .. player.name .. '!'}
)
return
end
else
if cmd.parameter == nil then return end
if cmd.parameter == nil then
return
end
local target_player = game.players[cmd.parameter]
if target_player then
trusted[target_player.name] = false
jail(target_player, 'Server')
Server.to_discord_bold(table.concat{'[Jailed] ' .. target_player.name .. ' has been jailed by Server!'})
Server.to_discord_bold(
table.concat {'[Jailed] ' .. target_player.name .. ' has been jailed by Server!'}
)
return
end
end
@ -99,7 +142,9 @@ commands.add_command(
if player then
if player ~= nil then
p = player.print
if not total_time[player.name] then goto continue end
if not total_time[player.name] then
goto continue
end
if total_time[player.name] < 51900000 then
if not player.admin then
p("You're not admin nor are you trusted enough to run this command!", {r = 1, g = 0.5, b = 0.1})
@ -108,20 +153,31 @@ commands.add_command(
end
end
if cmd.parameter == nil then return end
if cmd.parameter == nil then
return
end
local target_player = game.players[cmd.parameter]
if target_player then
if target_player.name == player.name then player.print("You can't unjail yourself!", {r = 1, g = 0.5, b = 0.1}) return end
if target_player.name == player.name then
player.print("You can't unjail yourself!", {r = 1, g = 0.5, b = 0.1})
return
end
free(target_player, player)
Server.to_discord_bold(table.concat{'[Unjailed] ' .. target_player.name .. ' has been unjailed by ' .. player.name .. '!'})
Server.to_discord_bold(
table.concat {'[Unjailed] ' .. target_player.name .. ' has been unjailed by ' .. player.name .. '!'}
)
return
end
else
if cmd.parameter == nil then return end
if cmd.parameter == nil then
return
end
local target_player = game.players[cmd.parameter]
if target_player then
free(target_player, 'Server')
Server.to_discord_bold(table.concat{'[Unjailed] ' .. target_player.name .. ' has been unjailed by Server!'})
Server.to_discord_bold(
table.concat {'[Unjailed] ' .. target_player.name .. ' has been unjailed by Server!'}
)
return
end
end
@ -131,25 +187,31 @@ commands.add_command(
local function on_console_command(event)
local cmd = event.command
if not event.player_index then return end
if not event.player_index then
return
end
local player = game.players[event.player_index]
local reason = event.parameters
if not reason then return end
if not player.admin then return end
if not reason then
return
end
if not player.admin then
return
end
if cmd == 'ban' then
if player then
Server.to_banned_embed(table.concat{player.name .. ' banned ' .. reason})
Server.to_banned_embed(table.concat {player.name .. ' banned ' .. reason})
return
else
Server.to_banned_embed(table.concat{'Server banned ' .. reason})
Server.to_banned_embed(table.concat {'Server banned ' .. reason})
return
end
elseif cmd == 'unban' then
if player then
Server.to_banned_embed(table.concat{player.name .. ' unbanned ' .. reason})
Server.to_banned_embed(table.concat {player.name .. ' unbanned ' .. reason})
return
else
Server.to_banned_embed(table.concat{'Server unbanned ' .. reason})
Server.to_banned_embed(table.concat {'Server unbanned ' .. reason})
return
end
end

View File

@ -155,6 +155,14 @@ end
local function on_init()
game.forces.player.research_queue_enabled = true
game.permissions.get_group('Default').set_allows_action(
defines.input_action.flush_opened_entity_fluid,
false
)
game.permissions.get_group('Default').set_allows_action(
defines.input_action.flush_opened_entity_specific_fluid,
false
)
end
local loaded = _G.package.loaded