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