Add fraction parsing
parent
84b19310b6
commit
5788f65ce5
|
@ -8,8 +8,10 @@ createScoreboard() {
|
|||
FF=0
|
||||
DEATH=0
|
||||
RESPAWN=0
|
||||
FLAG=0
|
||||
FRACTION=
|
||||
|
||||
#escape '[' -> somehow escapes all special chars, lol?
|
||||
#escape '[' -> somehow escapes all special chars, hah?
|
||||
ESC_NAME=$(echo "$NAME" | sed -r 's/[\[]+/\\[/g')
|
||||
|
||||
while IFS= read -r line; do
|
||||
|
@ -27,9 +29,16 @@ createScoreboard() {
|
|||
((RESPAWN++))
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ -z ${FRACTION} && ( "$line" == *${ESC_NAME}[" "]\(WEST\)* || "$line" == *${ESC_NAME}[" "]\(NATO\)* ) ]]; then
|
||||
FRACTION="BLUFOR"
|
||||
fi
|
||||
if [[ -z ${FRACTION} && ( "$line" == *${ESC_NAME}[" "]\(EAST\)* || "$line" == *${ESC_NAME}[" "]\(CSAT\)* ) ]]; then
|
||||
FRACTION="OPFOR"
|
||||
fi
|
||||
done < <(grep -- "${ESC_NAME}" ${FILE})
|
||||
|
||||
printf "\t{\"name\":\"$NAME\", \"kill\":${KILL}, \"ff\":${FF}, \"death\":${DEATH}, \"respawn\":${RESPAWN}}"
|
||||
printf "\t{\"name\":\"$NAME\", \"fraction\":\"$FRACTION\", \"kill\":${KILL}, \"friendlyFire\":${FF}, \"death\":${DEATH}, \"respawn\":${RESPAWN}}, \"flagTouch\":${FLAG}} "
|
||||
if [[ -z ${3} ]]; then
|
||||
printf ",\n"
|
||||
else
|
||||
|
@ -56,11 +65,13 @@ while IFS='' read -r line || [[ -n "$line" ]]; do
|
|||
;;
|
||||
esac
|
||||
|
||||
if [[ $RES =~ [^[:space:]] && " ${PLAYERS[*]} " != *" $RES "* ]]; then
|
||||
PLAYERS+=("$RES")
|
||||
fi
|
||||
if [[ $RES1 =~ [^[:space:]] && " ${PLAYERS[*]} " != *" $RES1 "* ]]; then
|
||||
PLAYERS+=("$RES1")
|
||||
if [[ $RES != *"Error: No unit"* && $RES1 != *"Error: No unit"* ]]; then
|
||||
if [[ $RES =~ [^[:space:]] && " ${PLAYERS[*]} " != *" $RES "* ]]; then
|
||||
PLAYERS+=("$RES")
|
||||
fi
|
||||
if [[ $RES1 =~ [^[:space:]] && " ${PLAYERS[*]} " != *" $RES1 "* ]]; then
|
||||
PLAYERS+=("$RES1")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done < ${FILE}
|
||||
|
|
Loading…
Reference in New Issue