Add fraction parsing
parent
84b19310b6
commit
5788f65ce5
|
@ -8,8 +8,10 @@ createScoreboard() {
|
||||||
FF=0
|
FF=0
|
||||||
DEATH=0
|
DEATH=0
|
||||||
RESPAWN=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')
|
ESC_NAME=$(echo "$NAME" | sed -r 's/[\[]+/\\[/g')
|
||||||
|
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
|
@ -27,9 +29,16 @@ createScoreboard() {
|
||||||
((RESPAWN++))
|
((RESPAWN++))
|
||||||
;;
|
;;
|
||||||
esac
|
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})
|
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
|
if [[ -z ${3} ]]; then
|
||||||
printf ",\n"
|
printf ",\n"
|
||||||
else
|
else
|
||||||
|
@ -56,11 +65,13 @@ while IFS='' read -r line || [[ -n "$line" ]]; do
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ $RES =~ [^[:space:]] && " ${PLAYERS[*]} " != *" $RES "* ]]; then
|
if [[ $RES != *"Error: No unit"* && $RES1 != *"Error: No unit"* ]]; then
|
||||||
PLAYERS+=("$RES")
|
if [[ $RES =~ [^[:space:]] && " ${PLAYERS[*]} " != *" $RES "* ]]; then
|
||||||
fi
|
PLAYERS+=("$RES")
|
||||||
if [[ $RES1 =~ [^[:space:]] && " ${PLAYERS[*]} " != *" $RES1 "* ]]; then
|
fi
|
||||||
PLAYERS+=("$RES1")
|
if [[ $RES1 =~ [^[:space:]] && " ${PLAYERS[*]} " != *" $RES1 "* ]]; then
|
||||||
|
PLAYERS+=("$RES1")
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done < ${FILE}
|
done < ${FILE}
|
||||||
|
|
Loading…
Reference in New Issue