Changeset 71 for scripts


Ignore:
Timestamp:
Jul 12, 2014, 4:09:13 PM (10 years ago)
Author:
alloc
Message:

v.29: Another fix for player logging

Location:
scripts/usr/local/lib/7dtd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • scripts/usr/local/lib/7dtd/VERSION

    r70 r71  
    1 Version: 28
     1Version: 29
    22Release: 2014-07-12
  • scripts/usr/local/lib/7dtd/playerlog.sh

    r67 r71  
    1010# Create empty player list if not existing
    1111createPlayerList() {
    12         if [ ! -f $PLAYERSXML ]; then
     12        if [ ! -f "$PLAYERSXML" ]; then
     13                echo "<Players/>" > $PLAYERSXML
     14        fi
     15        if [ -z "$(cat $PLAYERSXML)" ]; then
    1316                echo "<Players/>" > $PLAYERSXML
    1417        fi
     
    2023        $XMLSTARLET ed -L \
    2124                -u "/Players/Player/@online" -v "false" \
    22                 $PLAYERSXML
     25                "$PLAYERSXML"
    2326}
    2427
     
    3437        NICKNAME="$4"
    3538
    36         echo "$(timestamp) +++ $ENTITYID $NICKNAME $STEAMID" >> $PLAYERSLOG
     39        echo "$(timestamp) +++ $ENTITYID $NICKNAME $STEAMID" >> "$PLAYERSLOG"
    3740
    3841        createPlayerList
     
    4043        XPATHBASE="/Players/Player[@steamid='$STEAMID']"
    4144
    42         if [ -z $($XMLSTARLET sel -t -v "$XPATHBASE/@steamid" $PLAYERSXML) ]; then
     45        if [ -z $($XMLSTARLET sel -t -v "$XPATHBASE/@steamid" "$PLAYERSXML") ]; then
    4346                $XMLSTARLET ed -L \
    4447                        -s "/Players" -t elem -n "Player" -v "" \
     
    5053                        -i "$XPATHBASE" -t attr -n "online" -v "true" \
    5154                        -i "$XPATHBASE" -t attr -n "entityid" -v "$ENTITYID" \
    52                         $PLAYERSXML
     55                        "$PLAYERSXML"
    5356        else
    54                 LOGINS=$($XMLSTARLET sel -t -v "$XPATHBASE/@logins" $PLAYERSXML)
     57                LOGINS=$($XMLSTARLET sel -t -v "$XPATHBASE/@logins" "$PLAYERSXML")
    5558                (( LOGINS++ ))
    5659                $XMLSTARLET ed -L \
     
    5962                        -u "$XPATHBASE/@entityid" -v "$ENTITYID" \
    6063                        -u "$XPATHBASE/@logins" -v "$LOGINS" \
    61                         $PLAYERSXML
     64                        "$PLAYERSXML"
    6265        fi
    6366}
     
    7578
    7679        if [ -f $PLAYERSXML ]; then
    77                 if [ ! -z $($XMLSTARLET sel -t -v "$XPATHBASE/@steamid" $PLAYERSXML) ]; then
    78                         NICKNAME=$($XMLSTARLET sel -t -v "$XPATHBASE/@nick" $PLAYERSXML)
    79                         STEAMID=$($XMLSTARLET sel -t -v "$XPATHBASE/@steamid" $PLAYERSXML)
    80                         LOGINTIME=$($XMLSTARLET sel -t -v "$XPATHBASE/@lastlogin" $PLAYERSXML)
    81                         PLAYTIME=$($XMLSTARLET sel -t -v "$XPATHBASE/@playtime" $PLAYERSXML)
     80                if [ ! -z $($XMLSTARLET sel -t -v "$XPATHBASE/@steamid" "$PLAYERSXML") ]; then
     81                        NICKNAME=$($XMLSTARLET sel -t -v "$XPATHBASE/@nick" "$PLAYERSXML")
     82                        STEAMID=$($XMLSTARLET sel -t -v "$XPATHBASE/@steamid" "$PLAYERSXML")
     83                        LOGINTIME=$($XMLSTARLET sel -t -v "$XPATHBASE/@lastlogin" "$PLAYERSXML")
     84                        PLAYTIME=$($XMLSTARLET sel -t -v "$XPATHBASE/@playtime" "$PLAYERSXML")
    8285                        NOW=$(date '+%s')
    8386                        PLAYTIME=$(( PLAYTIME + NOW - LOGINTIME ))
     
    8588                                -u "$XPATHBASE/@playtime" -v "$PLAYTIME" \
    8689                                -u "$XPATHBASE/@online" -v "false" \
    87                                 $PLAYERSXML
     90                                "$PLAYERSXML"
    8891                fi
    8992        fi
    9093
    91         echo "$(timestamp) --- $ENTITYID $NICKNAME $STEAMID" >> $PLAYERSLOG
     94        echo "$(timestamp) --- $ENTITYID $NICKNAME $STEAMID" >> "$PLAYERSLOG"
    9295}
    9396
Note: See TracChangeset for help on using the changeset viewer.