- Timestamp:
- Nov 14, 2023, 5:44:17 PM (14 months ago)
- Location:
- scripts/usr/local/lib/7dtd
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
scripts/usr/local/lib/7dtd/monitor-log.sh
r344 r482 37 37 local entityId="$1" 38 38 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" 42 43 43 logPlayerConnect $INSTANCE "$entityId" "$name" "$ steamId" "$ip" "$ownerId"44 logPlayerConnect $INSTANCE "$entityId" "$name" "$platformId" "$crossId" "$ip" "$ownerId" 44 45 45 46 for H in $(getHooksFor playerConnect $INSTANCE); do 46 $H $INSTANCE "$entityId" "$name" "$ steamId" "$ip" "$ownerId"47 $H $INSTANCE "$entityId" "$name" "$platformId" "$ip" "$ownerId" "$crossId" 47 48 done 48 49 } 49 50 50 51 handleDisconnect() { 51 local playerId="$1" 52 local entityId="$2" 52 local entityId="$1" 53 53 54 54 logPlayerDisconnect $INSTANCE "$entityId" 55 55 56 56 for H in $(getHooksFor playerDisconnect $INSTANCE); do 57 $H $INSTANCE "$ playerId" "$entityId" "$NICKNAME" "$STEAMID"57 $H $INSTANCE "$entityId" "$NICKNAME" "$PLATFORMID" "$IP" "$OWNERID" "$CROSSID" 58 58 done 59 59 } … … 61 61 handlePlayerSpawnedInWorld() { 62 62 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" 68 69 69 70 for H in $(getHooksFor playerSpawned $INSTANCE); do 70 $H $INSTANCE "$entityId" "$pla yerId" "$ownerId" "$playerName" "$reason" "$position"71 $H $INSTANCE "$entityId" "$platformId" "$ownerId" "$playerName" "$reason" "$position" "$crossId" 71 72 done 72 73 } … … 135 136 while read line ; do 136 137 if [ -n "$line" ]; then 137 #Player connected, entityid=1278, name=termo2, steamid=76561197997439820, steamOwner=76561197997439820, ip=178.203.27.140138 #Player connected, entityid=1278, name=termo2, pltfmid=Steam_76561197997439820, crossid=EOS_eab...421, steamOwner=Steam_76561197997439820, ip=178.203.27.140 138 139 #Player connected, entityid=[0-9]*, name=.*, steamid=[0-9]*, steamOwner=[0-9]*, ip=[a-fA-F:0-9.]*$ 139 140 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.]*\)$') 145 147 sleep 1 146 handleConnect "$entityId" "$playerName" "$ steamId" "$ip" "$steamOwner"147 unset entityId playerName steamId steamOwner ip148 handleConnect "$entityId" "$playerName" "$platformId" "$crossId" "$ip" "$steamOwner" 149 unset entityId playerName platformId crossId steamOwner ip 148 150 #Player disconnected: EntityID=[0-9]*, PlayerID='[0-9]*', OwnerID='[0-9]*', PlayerName='.*'$ 149 151 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='.*' 155 156 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 164 166 #GMSG: .*$ 165 167 elif [ -n "$(echo "$line" | grep -E '^GMSG: .+')" ]; then … … 169 171 #Chat (from '<steamid>', entity id '<entityid>', to '<targettype>'): '<senderchatname>': <msg> 170 172 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 '.*'): '.*': \(.*\)$") 176 178 handleChat "$name" "$msg" "$steamId" "$entityId" "$targetType" 177 179 unset name msg steamId entityId targetType -
scripts/usr/local/lib/7dtd/playerlog.sh
r294 r482 54 54 local ENTITYID="$2" 55 55 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" 59 60 60 echo "$(timestamp) +++ $ENTITYID $NICKNAME $ STEAMID $IP $OWNERID" >> "$PLAYERSLOG"61 echo "$(timestamp) +++ $ENTITYID $NICKNAME $PLATFORMID $CROSSID $IP $OWNERID" >> "$PLAYERSLOG" 61 62 62 63 createPlayerList 63 64 64 XPATHBASE="/Players/Player[@ steamid='$STEAMID']"65 XPATHBASE="/Players/Player[@platformid='$PLATFORMID']" 65 66 66 if [ -z $($XMLSTARLET sel -t -v "$XPATHBASE/@ steamid" "$PLAYERSXML") ]; then67 if [ -z $($XMLSTARLET sel -t -v "$XPATHBASE/@platformid" "$PLAYERSXML") ]; then 67 68 $XMLSTARLET ed -L \ 68 69 -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" \ 70 72 -i "$XPATHBASE" -t attr -n "nick" -v "$NICKNAME" \ 71 73 -i "$XPATHBASE" -t attr -n "playtime" -v "0" \ … … 104 106 105 107 if [ -f $PLAYERSXML ]; then 106 if [ ! -z $($XMLSTARLET sel -t -v "$XPATHBASE/@ steamid" "$PLAYERSXML") ]; then108 if [ ! -z $($XMLSTARLET sel -t -v "$XPATHBASE/@platformid" "$PLAYERSXML") ]; then 107 109 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") 109 114 LOGINTIME=$($XMLSTARLET sel -t -v "$XPATHBASE/@lastlogin" "$PLAYERSXML") 110 115 PLAYTIME=$($XMLSTARLET sel -t -v "$XPATHBASE/@playtime" "$PLAYERSXML") … … 118 123 fi 119 124 120 echo "$(timestamp) --- $ENTITYID $NICKNAME $ STEAMID" >> "$PLAYERSLOG"125 echo "$(timestamp) --- $ENTITYID $NICKNAME $PLATFORMID $CROSSID" >> "$PLAYERSLOG" 121 126 } 122 127
Note:
See TracChangeset
for help on using the changeset viewer.