Changeset 482 for scripts


Ignore:
Timestamp:
Nov 14, 2023, 5:44:17 PM (12 months ago)
Author:
alloc
Message:

Scripts

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

Legend:

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

    r344 r482  
    3737        local entityId="$1"
    3838        local name="$2"
    39         local steamId="$3"
    40         local ip="$4"
    41         local ownerId="$5"
     39        local platformId="$3"
     40        local crossId="$4"
     41        local ip="$5"
     42        local ownerId="$6"
    4243       
    43         logPlayerConnect $INSTANCE "$entityId" "$name" "$steamId" "$ip" "$ownerId"
     44        logPlayerConnect $INSTANCE "$entityId" "$name" "$platformId" "$crossId" "$ip" "$ownerId"
    4445
    4546        for H in $(getHooksFor playerConnect $INSTANCE); do
    46                 $H $INSTANCE "$entityId" "$name" "$steamId" "$ip" "$ownerId"
     47                $H $INSTANCE "$entityId" "$name" "$platformId" "$ip" "$ownerId" "$crossId"
    4748        done
    4849}
    4950
    5051handleDisconnect() {
    51         local playerId="$1"
    52         local entityId="$2"
     52        local entityId="$1"
    5353
    5454        logPlayerDisconnect $INSTANCE "$entityId"
    5555
    5656        for H in $(getHooksFor playerDisconnect $INSTANCE); do
    57                 $H $INSTANCE "$playerId" "$entityId" "$NICKNAME" "$STEAMID"
     57                $H $INSTANCE "$entityId" "$NICKNAME" "$PLATFORMID" "$IP" "$OWNERID" "$CROSSID"
    5858        done
    5959}
     
    6161handlePlayerSpawnedInWorld() {
    6262        local entityId="$1"
    63         local playerId="$2"
    64         local ownerId="$3"
    65         local playerName="$4"
    66         local reason="$5"
    67         local position="$6"
     63        local platformId="$2"
     64        local crossId="$3"
     65        local ownerId="$4"
     66        local playerName="$5"
     67        local reason="$6"
     68        local position="$7"
    6869       
    6970        for H in $(getHooksFor playerSpawned $INSTANCE); do
    70                 $H $INSTANCE "$entityId" "$playerId" "$ownerId" "$playerName" "$reason" "$position"
     71                $H $INSTANCE "$entityId" "$platformId" "$ownerId" "$playerName" "$reason" "$position" "$crossId"
    7172        done
    7273}
     
    135136while read line ; do
    136137        if [ -n "$line" ]; then
    137                 #Player connected, entityid=1278, name=termo2, steamid=76561197997439820, steamOwner=76561197997439820, ip=178.203.27.140
     138                #Player connected, entityid=1278, name=termo2, pltfmid=Steam_76561197997439820, crossid=EOS_eab...421, steamOwner=Steam_76561197997439820, ip=178.203.27.140
    138139                #Player connected, entityid=[0-9]*, name=.*, steamid=[0-9]*, steamOwner=[0-9]*, ip=[a-fA-F:0-9.]*$
    139140                if [ -n "$(echo "$line" | grep '^Player connected,')" ]; then
    140                         entityId=$(expr "$line" : 'Player connected, entityid=\([0-9]*\), name=.*, steamid=[0-9]*, steamOwner=[0-9]*, ip=[a-fA-F:0-9.]*$')
    141                         playerName=$(expr "$line" : 'Player connected, entityid=[0-9]*, name=\(.*\), steamid=[0-9]*, steamOwner=[0-9]*, ip=[a-fA-F:0-9.]*$')
    142                         steamId=$(expr "$line" : 'Player connected, entityid=[0-9]*, name=.*, steamid=\([0-9]*\), steamOwner=[0-9]*, ip=[a-fA-F:0-9.]*$')
    143                         steamOwner=$(expr "$line" : 'Player connected, entityid=[0-9]*, name=.*, steamid=[0-9]*, steamOwner=\([0-9]*\), ip=[a-fA-F:0-9.]*$')
    144                         ip=$(expr "$line" : 'Player connected, entityid=[0-9]*, name=.*, steamid=[0-9]*, steamOwner=[0-9]*, ip=\([a-fA-F:0-9.]*\)$')
     141                        entityId=$(expr "$line" : 'Player connected, entityid=\([0-9]*\), name=.*, pltfmid=.*, crossid=.*, steamOwner=.*, ip=[a-fA-F:0-9.]*$')
     142                        playerName=$(expr "$line" : 'Player connected, entityid=[0-9]*, name=\(.*\), pltfmid=.*, crossid=.*, steamOwner=.*, ip=[a-fA-F:0-9.]*$')
     143                        platformId=$(expr "$line" : 'Player connected, entityid=[0-9]*, name=.*, pltfmid=\(.*\), crossid=.*, steamOwner=.*, ip=[a-fA-F:0-9.]*$')
     144                        crossId=$(expr "$line" : 'Player connected, entityid=[0-9]*, name=.*, pltfmid=.*, crossid=\(.*\), steamOwner=.*, ip=[a-fA-F:0-9.]*$')
     145                        steamOwner=$(expr "$line" : 'Player connected, entityid=[0-9]*, name=.*, pltfmid=.*, crossid=.*, steamOwner=\(.*\), ip=[a-fA-F:0-9.]*$')
     146                        ip=$(expr "$line" : 'Player connected, entityid=[0-9]*, name=.*, pltfmid=.*, crossid=.*, steamOwner=.*, ip=\([a-fA-F:0-9.]*\)$')
    145147                        sleep 1
    146                         handleConnect "$entityId" "$playerName" "$steamId" "$ip" "$steamOwner"
    147                         unset entityId playerName steamId steamOwner ip
     148                        handleConnect "$entityId" "$playerName" "$platformId" "$crossId" "$ip" "$steamOwner"
     149                        unset entityId playerName platformId crossId steamOwner ip
    148150                #Player disconnected: EntityID=[0-9]*, PlayerID='[0-9]*', OwnerID='[0-9]*', PlayerName='.*'$
    149151                elif [ -n "$(echo "$line" | grep '^Player disconnected: ')" ]; then
    150                         playerId=$(expr "$line" : "Player disconnected: EntityID=[0-9]*, PlayerID='\([0-9]*\)', OwnerID='[0-9]*', PlayerName='.*'$")
    151                         entityId=$(expr "$line" : "Player disconnected: EntityID=\([0-9]*\), PlayerID='[0-9]*', OwnerID='[0-9]*', PlayerName='.*'$")
    152                         handleDisconnect "$playerId" "$entityId"
    153                         unset playerId entityId
    154                 #PlayerSpawnedInWorld (reason: .+, position: [0-9]+, [0-9]+, [0-9]+): EntityID=[0-9]+, PlayerID='[0-9]+', OwnerID='[0-9]+', PlayerName='.*'
     152                        entityId=$(expr "$line" : "Player disconnected: EntityID=\(.*\), PltfmId='.*$")
     153                        handleDisconnect "$entityId"
     154                        unset entityId
     155                #PlayerSpawnedInWorld (reason: .*, position: .*, .*, .*): EntityID=.*, PltfmId='.*', CrossId='.*', OwnerID='.*', PlayerName='.*', ClientNumber='.*'
    155156                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
     157                        reason=$(expr "$line" : "PlayerSpawnedInWorld (reason: \(.*\), position: .*, .*, .*): EntityID=.*, PltfmId='.*', CrossId='.*', OwnerID='.*', PlayerName='.*', ClientNumber='.*'$")
     158                        position=$(expr "$line" : "PlayerSpawnedInWorld (reason: .*, position: \(.*, .*, .*\)): EntityID=.*, PltfmId='.*', CrossId='.*', OwnerID='.*', PlayerName='.*', ClientNumber='.*'$")
     159                        entityId=$(expr "$line" : "PlayerSpawnedInWorld (reason: .*, position: .*, .*, .*): EntityID=\(.*\), PltfmId='.*', CrossId='.*', OwnerID='.*', PlayerName='.*', ClientNumber='.*'$")
     160                        platformId=$(expr "$line" : "PlayerSpawnedInWorld (reason: .*, position: .*, .*, .*): EntityID=.*, PltfmId='\(.*\)', CrossId='.*', OwnerID='.*', PlayerName='.*', ClientNumber='.*'$")
     161                        crossId=$(expr "$line" : "PlayerSpawnedInWorld (reason: .*, position: .*, .*, .*): EntityID=.*, PltfmId='.*', CrossId='\(.*\)', OwnerID='.*', PlayerName='.*', ClientNumber='.*'$")
     162                        ownerId=$(expr "$line" : "PlayerSpawnedInWorld (reason: .*, position: .*, .*, .*): EntityID=.*, PltfmId='.*', CrossId='.*', OwnerID='\(.*\)', PlayerName='.*', ClientNumber='.*'$")
     163                        playerName=$(expr "$line" : "PlayerSpawnedInWorld (reason: .*, position: .*, .*, .*): EntityID=.*, PltfmId='.*', CrossId='.*', OwnerID='.*', PlayerName='\(.*\)', ClientNumber='.*'$")
     164                        handlePlayerSpawnedInWorld "$entityId" "$platformId" "$crossId" "$ownerId" "$playerName" "$reason" "$position"
     165                        unset reason position entityId platformId crossId ownerId playerName
    164166                #GMSG: .*$
    165167                elif [ -n "$(echo "$line" | grep -E '^GMSG: .+')" ]; then
     
    169171                #Chat (from '<steamid>', entity id '<entityid>', to '<targettype>'): '<senderchatname>': <msg>
    170172                elif [ -n "$(echo "$line" | grep -E '^Chat .+')" ]; then
    171                         steamId=$(expr "$line" : "Chat (from '\(.+\)', entity id '[0-9]+', to '[a-fA-F:0-9.]+'): '.*': .*$")
    172                         entityId=$(expr "$line" : "Chat (from '.+', entity id '\([0-9]+\)', to '[a-fA-F:0-9.]+'): '.*': .*$")
    173                         targetType=$(expr "$line" : "Chat (from '.+', entity id '[0-9]+', to '\([a-fA-F:0-9.]+\)'): '.*': .*$")
    174                         name=$(expr "$line" : "Chat (from '.+', entity id '[0-9]+', to '[a-fA-F:0-9.]+'): '\(.*\)': .*$")
    175                         msg=$(expr "$line" : "Chat (from '.+', entity id '[0-9]+', to '[a-fA-F:0-9.]+'): '.*': \(.*\)$")
     173                        steamId=$(expr "$line" : "Chat (from '\(.*\)', entity id '.*', to '.*'): '.*': .*$")
     174                        entityId=$(expr "$line" : "Chat (from '.*', entity id '\(.*\)', to '.*'): '.*': .*$")
     175                        targetType=$(expr "$line" : "Chat (from '.*', entity id '.*', to '\(.*\)'): '.*': .*$")
     176                        name=$(expr "$line" : "Chat (from '.*', entity id '.*', to '.*'): '\(.*\)': .*$")
     177                        msg=$(expr "$line" : "Chat (from '.*', entity id '.*', to '.*'): '.*': \(.*\)$")
    176178                        handleChat "$name" "$msg" "$steamId" "$entityId" "$targetType"
    177179                        unset name msg steamId entityId targetType
  • scripts/usr/local/lib/7dtd/playerlog.sh

    r294 r482  
    5454        local ENTITYID="$2"
    5555        local NICKNAME="$3"
    56         local STEAMID="$4"
    57         local IP="$5"
    58         local OWNERID="$6"
     56        local PLATFORMID="$4"
     57        local CROSSID="$5"
     58        local IP="$6"
     59        local OWNERID="$7"
    5960
    60         echo "$(timestamp) +++ $ENTITYID $NICKNAME $STEAMID $IP $OWNERID" >> "$PLAYERSLOG"
     61        echo "$(timestamp) +++ $ENTITYID $NICKNAME $PLATFORMID $CROSSID $IP $OWNERID" >> "$PLAYERSLOG"
    6162
    6263        createPlayerList
    6364       
    64         XPATHBASE="/Players/Player[@steamid='$STEAMID']"
     65        XPATHBASE="/Players/Player[@platformid='$PLATFORMID']"
    6566
    66         if [ -z $($XMLSTARLET sel -t -v "$XPATHBASE/@steamid" "$PLAYERSXML") ]; then
     67        if [ -z $($XMLSTARLET sel -t -v "$XPATHBASE/@platformid" "$PLAYERSXML") ]; then
    6768                $XMLSTARLET ed -L \
    6869                        -s "/Players" -t elem -n "Player" -v "" \
    69                         -i "/Players/Player[not(@steamid)]" -t attr -n "steamid" -v "$STEAMID" \
     70                        -i "/Players/Player[not(@platformid)]" -t attr -n "platformid" -v "$PLATFORMID" \
     71                        -i "$XPATHBASE" -t attr -n "crossid" -v "$CROSSID" \
    7072                        -i "$XPATHBASE" -t attr -n "nick" -v "$NICKNAME" \
    7173                        -i "$XPATHBASE" -t attr -n "playtime" -v "0" \
     
    104106
    105107        if [ -f $PLAYERSXML ]; then
    106                 if [ ! -z $($XMLSTARLET sel -t -v "$XPATHBASE/@steamid" "$PLAYERSXML") ]; then
     108                if [ ! -z $($XMLSTARLET sel -t -v "$XPATHBASE/@platformid" "$PLAYERSXML") ]; then
    107109                        NICKNAME=$($XMLSTARLET sel -t -v "$XPATHBASE/@nick" "$PLAYERSXML")
    108                         STEAMID=$($XMLSTARLET sel -t -v "$XPATHBASE/@steamid" "$PLAYERSXML")
     110                        PLATFORMID=$($XMLSTARLET sel -t -v "$XPATHBASE/@platformid" "$PLAYERSXML")
     111                        CROSSID=$($XMLSTARLET sel -t -v "$XPATHBASE/@crossid" "$PLAYERSXML")
     112                        IP=$($XMLSTARLET sel -t -v "$XPATHBASE/@lastIp" "$PLAYERSXML")
     113                        OWNERID=$($XMLSTARLET sel -t -v "$XPATHBASE/@steamOwner" "$PLAYERSXML")
    109114                        LOGINTIME=$($XMLSTARLET sel -t -v "$XPATHBASE/@lastlogin" "$PLAYERSXML")
    110115                        PLAYTIME=$($XMLSTARLET sel -t -v "$XPATHBASE/@playtime" "$PLAYERSXML")
     
    118123        fi
    119124
    120         echo "$(timestamp) --- $ENTITYID $NICKNAME $STEAMID" >> "$PLAYERSLOG"
     125        echo "$(timestamp) --- $ENTITYID $NICKNAME $PLATFORMID $CROSSID" >> "$PLAYERSLOG"
    121126}
    122127
Note: See TracChangeset for help on using the changeset viewer.