Changeset 62 for scripts


Ignore:
Timestamp:
Jul 5, 2014, 7:06:58 PM (10 years ago)
Author:
alloc
Message:

V21: Fixes #19, #20

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

Legend:

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

    r61 r62  
    1 Version: 20
    2 Release: 2014-06-20
     1Version: 21
     2Release: 2014-07-05
  • scripts/usr/local/lib/7dtd/monitor-log.sh

    r57 r62  
    1111INSTANCE=$1
    1212LOG=$(getInstancePath $INSTANCE)/output.log
     13CHATLOG=$(getInstancePath $INSTANCE)/chat.log
    1314
    1415timestamp() {
     
    1920        tel=$(telnetCommand $INSTANCE lp)
    2021        playerline=$(echo "$tel" | tr -d '\r' | grep "id=$2,")
    21         nickname=$(echo "$playerline" | sed -r 's/^.* id=[0-9]*, ([^,]*), pos=.*$/\1/')
     22        #nickname=$(echo "$playerline" | sed -r 's/^.* id=[0-9]*, ([^,]*), pos=.*$/\1/')
    2223        steamid=$(echo "$playerline" | sed -r 's/^.*, health=[0-9]*, ([0-9]*)$/\1/')
    2324       
     
    2627        fi
    2728
    28         logPlayerConnect $INSTANCE $2 $steamid $nickname
     29        logPlayerConnect $INSTANCE $2 $steamid $3
    2930
    3031        for H in $(getHooksFor playerConnect); do
    31                 $H $INSTANCE $1 $2 $nickname $steamid
     32                $H $INSTANCE $1 $2 $3 $steamid
    3233        done
    3334}
     
    3839        for H in $(getHooksFor playerDisconnect); do
    3940                $H $INSTANCE $1 $2 $NICKNAME $STEAMID
     41        done
     42}
     43
     44handleChat() {
     45        echo "$(timestamp): $1" >> $CHATLOG
     46       
     47        for H in $(getHooksFor chat); do
     48                $H $INSTANCE $1
    4049        done
    4150}
     
    6574                        handleConnect "$playerId" "$entityId" "$playerName"
    6675                        unset entityId playerId playerName unknown
    67                 fi
     76                else
    6877                if [ -n "$(echo "$line" | grep '^Removing player with id ')" ]; then
    6978                        playerId=$(expr "$line" : 'Removing player with id clientId=\([0-9]*\), entityId=[0-9]*$')
     
    7180                        handleDisconnect "$playerId" "$entityId"
    7281                        unset playerId entityId
     82                else
     83                if [ -n "$(echo "$line" | grep -E '^GMSG: .+')" ]; then
     84                        msg=$(expr "$line" : 'GMSG: \(.*\)$')
     85                        handleChat "$msg"
     86                        unset msg
     87                fi
     88                fi
    7389                fi
    7490        fi
Note: See TracChangeset for help on using the changeset viewer.