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

query_online_players

This commit is contained in:
grilledham 2018-12-01 10:49:14 +00:00
parent 762aaf83f1
commit 0a82e1b68e
2 changed files with 24 additions and 0 deletions

View File

@ -26,6 +26,7 @@ local data_get_all_tag = '[DATA-GET-ALL]'
local data_tracked_tag = '[DATA-TRACKED]'
local ban_sync_tag = '[BAN-SYNC]'
local unbanned_sync_tag = '[UNBANNED-SYNC]'
local query_players_tag = '[QUERY-PLAYERS]'
Public.raw_print = raw_print
@ -440,4 +441,25 @@ function Public.unban_non_sync(PlayerSpecification)
game.unban_player(PlayerSpecification)
end
--- Called be the web server to re sync which players are online.
function Public.query_online_players()
local message = {query_players_tag, '['}
for _, p in ipairs(game.connected_players) do
table.insert(message, '"')
local name = escape(p.name)
table.insert(message, name)
table.insert(message, '",')
end
if message[#message] == '",' then
message[#message] = '"'
end
table.insert(message, ']')
message = table.concat(message)
raw_print(message)
end
return Public

View File

@ -25,4 +25,6 @@ function ServerCommands.server_started()
script.raise_event(Server.events.on_server_started, {})
end
ServerCommands.query_online_players = Server.query_online_players
return ServerCommands