Ignore:
Timestamp:
Aug 7, 2017, 7:18:35 AM (7 years ago)
Author:
alloc
Message:

Scripts 109

File:
1 edited

Legend:

Unmodified
Added
Removed
  • scripts/usr/local/lib/7dtd/monitor-log.sh

    r298 r308  
    5656        for H in $(getHooksFor playerDisconnect $INSTANCE); do
    5757                $H $INSTANCE "$playerId" "$entityId" "$NICKNAME" "$STEAMID"
     58        done
     59}
     60
     61handlePlayerSpawnedInWorld() {
     62        local entityId="$1"
     63        local playerId="$2"
     64        local ownerId="$3"
     65        local playerName="$4"
     66        local reason="$5"
     67        local position="$6"
     68       
     69        for H in $(getHooksFor playerSpawned $INSTANCE); do
     70                $H $INSTANCE "$entityId" "$playerId" "$ownerId" "$playerName" "$reason" "$position"
    5871        done
    5972}
     
    133146                        handleConnect "$entityId" "$playerName" "$steamId" "$ip" "$steamOwner"
    134147                        unset entityId playerName steamId steamOwner ip
    135                 else
    136148                #Player disconnected: EntityID=[0-9]*, PlayerID='[0-9]*', OwnerID='[0-9]*', PlayerName='.*'$
    137                 if [ -n "$(echo "$line" | grep '^Player disconnected: ')" ]; then
     149                elif [ -n "$(echo "$line" | grep '^Player disconnected: ')" ]; then
    138150                        playerId=$(expr "$line" : "Player disconnected: EntityID=[0-9]*, PlayerID='\([0-9]*\)', OwnerID='[0-9]*', PlayerName='.*'$")
    139151                        entityId=$(expr "$line" : "Player disconnected: EntityID=\([0-9]*\), PlayerID='[0-9]*', OwnerID='[0-9]*', PlayerName='.*'$")
    140152                        handleDisconnect "$playerId" "$entityId"
    141153                        unset playerId entityId
    142                 else
     154                #PlayerSpawnedInWorld (reason: .+, position: [0-9]+, [0-9]+, [0-9]+): EntityID=[0-9]+, PlayerID='[0-9]+', OwnerID='[0-9]+', PlayerName='.*'
     155                elif [ -n "$(echo "$line" | grep '^PlayerSpawnedInWorld ')" ]; then
     156                        reason=$(expr "$line" : "PlayerSpawnedInWorld (reason: \(.+\), position: [0-9]+, [0-9]+, [0-9]+): EntityID=[0-9]+, PlayerID='[0-9]+', OwnerID='[0-9]+', PlayerName='.*'$")
     157                        position=$(expr "$line" : "PlayerSpawnedInWorld (reason: .+, position: \([0-9]+, [0-9]+, [0-9]+\)): EntityID=[0-9]+, PlayerID='[0-9]+', OwnerID='[0-9]+', PlayerName='.*'$")
     158                        entityId=$(expr "$line" : "PlayerSpawnedInWorld (reason: .+, position: [0-9]+, [0-9]+, [0-9]+): EntityID=\([0-9]+\), PlayerID='[0-9]+', OwnerID='[0-9]+', PlayerName='.*'$")
     159                        playerId=$(expr "$line" : "PlayerSpawnedInWorld (reason: .+, position: [0-9]+, [0-9]+, [0-9]+): EntityID=[0-9]+, PlayerID='\([0-9]+\)', OwnerID='[0-9]+', PlayerName='.*'$")
     160                        ownerId=$(expr "$line" : "PlayerSpawnedInWorld (reason: .+, position: [0-9]+, [0-9]+, [0-9]+): EntityID=[0-9]+, PlayerID='[0-9]+', OwnerID='\([0-9]+\)', PlayerName='.*'$")
     161                        playerName=$(expr "$line" : "PlayerSpawnedInWorld (reason: .+, position: [0-9]+, [0-9]+, [0-9]+): EntityID=[0-9]+, PlayerID='[0-9]+', OwnerID='[0-9]+', PlayerName='\(.*\)'$")
     162                        handlePlayerSpawnedInWorld "$entityId" "$playerId" "$ownerId" "$playerName" "$reason" "$position"
     163                        unset reason position entityId playerId ownerId playerName
    143164                #GMSG: .*$
    144                 if [ -n "$(echo "$line" | grep -E '^GMSG: .+')" ]; then
     165                elif [ -n "$(echo "$line" | grep -E '^GMSG: .+')" ]; then
    145166                        msg=$(expr "$line" : 'GMSG: \(.*\)$')
    146167                        handleGmsg "$msg"
    147168                        unset msg
    148                 else
    149169                #Chat: 'name': .*$
    150                 if [ -n "$(echo "$line" | grep -E '^Chat: .+')" ]; then
     170                elif [ -n "$(echo "$line" | grep -E '^Chat: .+')" ]; then
    151171                        name=$(expr "$line" : "Chat: '\(.*\)': .*$")
    152172                        msg=$(expr "$line" : "Chat: '.*': \(.*\)$")
    153173                        handleChat "$name" "$msg"
    154174                        unset name msg
    155                 else
    156175                #Executing command ".*" from client ".*"$
    157                 if [ -n "$(echo "$line" | grep '^Executing command '.*' from client')" ]; then
     176                elif [ -n "$(echo "$line" | grep '^Executing command '.*' from client')" ]; then
    158177                        cmd=$(expr "$line" : "Executing command '\(.*\)' from client .*$")
    159178                        nick=$(expr "$line" : "Executing command '.*' from client \(.*\)$")
    160179                        handleRemoteCommand "$cmd" "$nick"
    161180                        unset cmd nick
    162                 else
    163181                #Executing command ".*" by Telnet from .*$
    164                 if [ -n "$(echo "$line" | grep '^Executing command '.*' by Telnet from ')" ]; then
     182                elif [ -n "$(echo "$line" | grep '^Executing command '.*' by Telnet from ')" ]; then
    165183                        cmd=$(expr "$line" : "Executing command '\(.*\)' by Telnet from .*$")
    166184                        ip=$(expr "$line" : "Executing command '.*' by Telnet from \(.*\)$")
     
    168186                        unset cmd ip
    169187                fi
    170                 fi
    171                 fi
    172                 fi
    173                 fi
    174                 fi
    175188        fi
    176189done
Note: See TracChangeset for help on using the changeset viewer.