Implemented "server connected" command.

This commit is contained in:
Marcus Whybrow 2012-05-24 08:14:09 +01:00
parent 62aea7e759
commit 3807552b55

21
msm
View File

@ -862,6 +862,26 @@ server_backup() {
echo "Done." 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 ### Main Functions
@ -1297,6 +1317,7 @@ main() {
fi fi
;; ;;
connected) connected)
server_connected $1
;; ;;
worlds) worlds)
case "$3" in case "$3" in