Skip to content

Commit

Permalink
Fixed for any size player id
Browse files Browse the repository at this point in the history
  • Loading branch information
Dashboy1998 committed Feb 21, 2024
1 parent ae35c3e commit 2ba2023
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions scripts/player_logging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ get_steamid(){

get_playername(){
local player_info="${1}"
echo "${player_info}" | sed -E 's/,[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]//g'
echo "${player_info}" | sed -E 's/,([0-9]+),[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]//g'
}

old_player_list=( )
while true; do
mapfile -t server_pids < <(pgrep PalServer-Linux)
if [ "${#server_pids[@]}" -ne 0 ]; then
# Player IDs are usally 9 digits however when a player joins for the first time for a given boot their ID is temporary 00000000 (8x zeros)
mapfile -t new_player_list < <( get_players_list | sed -E 's/,([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|00000000),([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])/,\2/g' )
# Player IDs are usally 9 or 10 digits however when a player joins for the first time for a given boot their ID is temporary 00000000 (8x zeros) while loading
# Player ID is also 00000000 (8x zeros) when in character creation
mapfile -t new_player_list < <( get_players_list | sed '/,00000000,[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/d' )
# No players
if [ "${#new_player_list[@]}" -gt 0 ] && [ "${#old_player_list[@]}" -gt 0 ]; then
mapfile -t players_change_list < <( comm -23 \
Expand Down

0 comments on commit 2ba2023

Please sign in to comment.