From 3807552b55f750811d6df424ac7ece2adf375c1a Mon Sep 17 00:00:00 2001 From: Marcus Whybrow Date: Thu, 24 May 2012 08:14:09 +0100 Subject: [PATCH] Implemented "server connected" command. --- msm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/msm b/msm index 75f6539..8a1140b 100755 --- a/msm +++ b/msm @@ -862,6 +862,26 @@ server_backup() { echo "Done." } +# Lists the players currently connected to a server +# $1: The ID of the server +server_connected() { + if server_is_running $1; then + local line=$(server_eval_and_get_line $1 "list" "Connected players:") + + # Cuts the start off the line, and the last three (invisible) + # characters from the end. + local players=${line:46:(-3)} + + if [ -z "$players" ]; then + echo "No players are connected." + else + echo "$players" + fi + else + echo "Server \"${server_name[$id]}\" is stopped. No users are connected." + fi +} + ### Main Functions @@ -1297,6 +1317,7 @@ main() { fi ;; connected) + server_connected $1 ;; worlds) case "$3" in