1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-10 10:00:00 +02:00

Merge pull request #1141 from grilledham/player_leave_reason

Add player leave reasons
This commit is contained in:
grilledham 2021-01-02 12:18:42 +00:00 committed by GitHub
commit e093b92dc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 1 deletions

View File

@ -918,6 +918,21 @@ stds.factorio_defines = {
}
}
},
disconnect_reason = {
fields = {
'quit',
'dropped',
'reconnect',
'wrong_input',
'desync_limit_reached',
'cannot_keep_up',
'afk',
'kicked',
'kicked_and_deleted',
'banned',
'switching_servers'
}
},
difficulty = {
fields = {
'easy',

View File

@ -777,13 +777,28 @@ Event.add(defines.events.on_player_joined_game, function(event)
raw_print(player_join_tag .. player.name)
end)
local leave_reason_map = {
[defines.disconnect_reason.quit] = '',
[defines.disconnect_reason.dropped] = ' (Dropped)',
[defines.disconnect_reason.reconnect] = ' (Reconnect)',
[defines.disconnect_reason.wrong_input] = ' (Wrong input)',
[defines.disconnect_reason.desync_limit_reached] = ' (Desync limit reached)',
[defines.disconnect_reason.cannot_keep_up] = ' (Cannot keep up)',
[defines.disconnect_reason.afk] = ' (AFK)',
[defines.disconnect_reason.kicked] = ' (Kicked)',
[defines.disconnect_reason.kicked_and_deleted] = ' (Kicked)',
[defines.disconnect_reason.banned] = ' (Banned)',
[defines.disconnect_reason.switching_servers] = ' (Switching servers)'
}
Event.add(defines.events.on_player_left_game, function(event)
local player = game.get_player(event.player_index)
if not player then
return
end
raw_print(player_leave_tag .. player.name)
local reason = leave_reason_map[event.reason] or ''
raw_print(player_leave_tag .. player.name .. reason)
end)
Event.add(defines.events.on_player_died, function(event)