Anzu 12 Posted September 11, 2011 Hello, I'm experimenting with some different MP scripts and was wondering if it's possible to determine or check a player's BattlEye GUID from within a SQF script? Right now, I'm checking player IDs in a script by using this code: _uid = getPlayerUID _unit; if ( _uid = "1234567" ) then ... I'd much rather have this condition check the players BattlEye GUID since the player IDs are so easily spoofable. Is there a GUID equivalent to getPlayerUID ? Any helpful hints would be much appreciated :-) Share this post Link to post Share on other sites
nuxil 2 Posted September 11, 2011 sorry. no vanilla commands or functions lets you do that. however there is a way. but it involves making your own rcon running on the server. paste the players list to clippboard then from script copy from clippboard. alot of work just to get the guid.. Share this post Link to post Share on other sites
gossamersolid 155 Posted September 11, 2011 Ah this should be a request for A3 at least. I'd love a command to grab GUID instead. Share this post Link to post Share on other sites
nuxil 2 Posted September 11, 2011 i guess its also possible to use make some app tail the serverlog file as the guid gets stored ther. then by some regexpression get the wanted data. then post it on the clippboard. but hey. still alot of work getting the guid. Share this post Link to post Share on other sites
eddieck 10 Posted September 11, 2011 i guess its also possible to use make some app tail the serverlog file as the guid gets stored ther. then by some regexpression get the wanted data. then post it on the clippboard. but hey. still alot of work getting the guid. You probably could create a "guids" folder and have an external script write the GUIDs to files. And then it'd be something like: _guid = loadFile format ["guids/%1", name player]; This has the benefit of being cross-platform as well (the clipboard functions are Windows-only AFAIK - not that I'd want to run a GUI on a server). Also, it's better than writing to one file since it avoids the issue of parsing the file from within ArmA. If there is enough interest in this, I'll consider doing something like this. Share this post Link to post Share on other sites
Anzu 12 Posted September 11, 2011 (edited) Thanks for all the responses guys. Giving me some ideas... You probably could create a "guids" folder and have an external script write the GUIDs to files. And then it'd be something like: _guid = loadFile format ["guids/%1", name player]; This has the benefit of being cross-platform as well (the clipboard functions are Windows-only AFAIK - not that I'd want to run a GUI on a server). Also, it's better than writing to one file since it avoids the issue of parsing the file from within ArmA. If there is enough interest in this, I'll consider doing something like this. This sounds like a great solution for me since I run on a linux server with no GUI. A bash script would parse the log for player's GUIDs, then write them to files. Then your above code would read those GUID files from the SQF script. I'm going to try some things with this, if I get anywhere I'll post back here my results. Thanks again, great ideas! :D Oh and yes I agree, this would be an awesome feature to have for Arma 3 scripters ^_^ Edited September 11, 2011 by Anzu Share this post Link to post Share on other sites
eddieck 10 Posted September 12, 2011 This sounds like a great solution for me since I run on a linux server with no GUI. A bash script would parse the log for player's GUIDs, then write them to files. Then your above code would read those GUID files from the SQF script. I'm going to try some things with this, if I get anywhere I'll post back here my results. Glad to see more Linux server admins around. :) Another thing to remember is that the built-in logger only updates the file every X minutes. For this purpose, you'll probably want real-time logging, so your best bet would be to use Bash IO redirection to redirect STDOUT to a file (and disable the built-in logger). If you're using start-stop-daemon in an init script, you can create a separate launcher script for this. I do this not only for real-time logging, but also for automatic restarts: #!/bin/bash # ArmA 2: OA server launcher - restarts server after shutdown/crash NAME=$1 shift sudo -u $NAME /opt/arma2oa/bin/arma2oaserver $@ > /var/opt/arma2oa/log/$NAME.log # Restart server (init script is called so it can rotate logs) /etc/init.d/arma2oaserver-$NAME force-reload exit 0 I also write the launcher PID to a file. If the server is stopped using the init script, the launcher is killed first to avoid an auto-restart. I strongly recommend setting up something for automatic restarts anyways, since script kiddies can easily shut the server down. (It also provides a facility for your administrators to hard restart easily, just by using the shutdown button.) Share this post Link to post Share on other sites
nuxil 2 Posted September 12, 2011 (edited) You probably could create a "guids" folder and have an external script write the GUIDs to files. And then it'd be something like: _guid = loadFile format ["guids/%1", name player]; This has the benefit of being cross-platform as well (the clipboard functions are Windows-only AFAIK - not that I'd want to run a GUI on a server). Also, it's better than writing to one file since it avoids the issue of parsing the file from within ArmA. If there is enough interest in this, I'll consider doing something like this. that would work as long as ther is no player with som weird name [*.().*]†♥\/ uber killer you might want to consider using the pid as a referance to the guid instead. Edited September 12, 2011 by nuxil Share this post Link to post Share on other sites
eddieck 10 Posted September 12, 2011 that would work as long as ther is no player with som weird name [*.().*]†♥\/ uber killeryou might want to consider using the pid as a referance to the guid instead. Yeah, I was thinking about that as well. PID is probably the way to go. Share this post Link to post Share on other sites
$able 2 Posted September 12, 2011 I'd love a command to grab GUID instead. Noted. I hope we can add support for that soon. Share this post Link to post Share on other sites
Anzu 12 Posted September 14, 2011 (edited) Okay I've been experimenting with some ways I can get the GUIDs, IPs, and player names from the logs. And I've come up with this... I start my arma server with a command like: #!/bin/bash cd /home/user/arma2 # Rotate net.log if it exists [ -w net.log ] && mv net.log logs/net.log.$(date +%m-%d-%Y_%H%M).txt || echo "No net.log file to rotate" nohup ./server -name=myprofile -config=myconfig.cfg -netlog -BEpath=mypath > logs/$(date +%m-%d-%Y_%H%M).txt 2> logs/$(date +%m-%d-%Y_%H%M)err.txt & exit then I came up with this script to parse the GUIDs, IPs, and player names from the latest log file: #!/bin/bash # Set path where "arma2" folder is USERDIR=/home/user # Set filename of latest log file FILENAME=$(ls -tr1 --hide=*err* /home/user/arma2/logs | tail -n 1) # Set full path name of that logfile FULLNAME=$(find /home/user/arma2/logs | grep $FILENAME | grep -vw net.log) PLAYER0FILE=$USERDIR/arma2/logs/players/player0 GUID0FILE=$USERDIR/arma2/logs/guids/guid0 IP0FILE=$USERDIR/arma2/logs/ips/ip0 PLAYER1FILE=$USERDIR/arma2/logs/players/player1 GUID1FILE=$USERDIR/arma2/logs/guids/guid1 IP1FILE=$USERDIR/arma2/logs/ips/ip1 PLAYER2FILE=$USERDIR/arma2/logs/players/player2 GUID2FILE=$USERDIR/arma2/logs/guids/guid2 IP2FILE=$USERDIR/arma2/logs/ips/ip2 PLAYER3FILE=$USERDIR/arma2/logs/players/player3 GUID3FILE=$USERDIR/arma2/logs/guids/guid3 IP3FILE=$USERDIR/arma2/logs/ips/ip3 PLAYER4FILE=$USERDIR/arma2/logs/players/player4 GUID4FILE=$USERDIR/arma2/logs/guids/guid4 IP4FILE=$USERDIR/arma2/logs/ips/ip4 PLAYER5FILE=$USERDIR/arma2/logs/players/player5 GUID5FILE=$USERDIR/arma2/logs/guids/guid5 IP5FILE=$USERDIR/arma2/logs/ips/ip5 function getdiscname { # show name of last player to disconnect DISCONNECT=$(tac $FULLNAME | grep --max-count=1 " disconnected.") echo -n $DISCONNECT | sed 's/Player /&\n/;s/.*\n//;s/ disconnected/\n&/;s/\n.*//' } # Find last player to disconnect, # and if their GUID, IP, and player name were stored in the files # then clear those files PLAYERDISC=$(getdiscname) CUR_PLAYER0=$(cat $PLAYER0FILE) CUR_PLAYER1=$(cat $PLAYER1FILE) CUR_PLAYER2=$(cat $PLAYER2FILE) CUR_PLAYER3=$(cat $PLAYER3FILE) CUR_PLAYER4=$(cat $PLAYER4FILE) CUR_PLAYER5=$(cat $PLAYER5FILE) if [ "$PLAYERDISC" == "$CUR_PLAYER0" ] ; then echo "" > $PLAYER0FILE echo "" > $GUID0FILE echo "" > $IP0FILE fi if [ "$PLAYERDISC" == "$CUR_PLAYER1" ] ; then echo "" > $PLAYER1FILE echo "" > $GUID1FILE echo "" > $IP1FILE fi if [ "$PLAYERDISC" == "$CUR_PLAYER2" ] ; then echo "" > $PLAYER2FILE echo "" > $GUID2FILE echo "" > $IP2FILE fi if [ "$PLAYERDISC" == "$CUR_PLAYER3" ] ; then echo "" > $PLAYER3FILE echo "" > $GUID3FILE echo "" > $IP3FILE fi if [ "$PLAYERDISC" == "$CUR_PLAYER4" ] ; then echo "" > $PLAYER4FILE echo "" > $GUID4FILE echo "" > $IP4FILE fi if [ "$PLAYERDISC" == "$CUR_PLAYER5" ] ; then echo "" > $PLAYER5FILE echo "" > $GUID5FILE echo "" > $IP5FILE fi # Get line with most recent Player #0 PLAYER0=$(tac $FULLNAME | grep "Player #0" | grep "GUID:" | grep --max-count=1 "BattlEye Server:") if [ -n "$PLAYER0" ] ; then # Get GUID from player 0 GUID0=$(echo $PLAYER0 | grep -o '[0-9a-f]\{32\}') # Get IP from player 0 IP0=$(echo $PLAYER0 | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}') # Get name from player 0 # Note: this grabs the text between the strings "Player #xx " and " (xxx.xxx.xxx.xxx" # Since the format of the log file is "Player #13 Big Bad Joe (1.2.3.4:2304)" # this will grab the name between the player number and their IP address PLAYER0=$(echo $PLAYER0 | sed 's/Player #[0-9]\{1,2\}[[:space:]]/&\n/;s/.*\n//;s/[[:space:]]([0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}/\n&/;s/\n.*//') #) # Write GUID and IP to their respective files echo -n $GUID0 > $GUID0FILE echo -n $IP0 > $IP0FILE echo -n $PLAYER0 > $PLAYER0FILE fi PLAYER1=$(tac $FULLNAME | grep "Player #1" | grep "GUID:" | grep --max-count=1 "BattlEye Server:") if [ -n "$PLAYER1" ] ; then GUID1=$(echo $PLAYER1 | grep -o '[0-9a-f]\{32\}') IP1=$(echo $PLAYER1 | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}') PLAYER1=$(echo $PLAYER1 | sed 's/Player #[0-9]\{1,2\}[[:space:]]/&\n/;s/.*\n//;s/[[:space:]]([0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}/\n&/;s/\n.*//') #) echo -n $GUID1 > $GUID1FILE echo -n $IP1 > $IP1FILE echo -n $PLAYER1 > $PLAYER1FILE fi PLAYER2=$(tac $FULLNAME | grep "Player #2" | grep "GUID:" | grep --max-count=1 "BattlEye Server:") if [ -n "$PLAYER2" ] ; then GUID2=$(echo $PLAYER2 | grep -o '[0-9a-f]\{32\}') IP2=$(echo $PLAYER2 | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}') PLAYER2=$(echo $PLAYER2 | sed 's/Player #[0-9]\{1,2\}[[:space:]]/&\n/;s/.*\n//;s/[[:space:]]([0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}/\n&/;s/\n.*//') #) echo -n $GUID2 > $GUID2FILE echo -n $IP2 > $IP2FILE echo -n $PLAYER2 > $PLAYER2FILE fi PLAYER3=$(tac $FULLNAME | grep "Player #3" | grep "GUID:" | grep --max-count=1 "BattlEye Server:") if [ -n "$PLAYER3" ] ; then GUID3=$(echo $PLAYER3 | grep -o '[0-9a-f]\{32\}') IP3=$(echo $PLAYER3 | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}') PLAYER3=$(echo $PLAYER3 | sed 's/Player #[0-9]\{1,2\}[[:space:]]/&\n/;s/.*\n//;s/[[:space:]]([0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}/\n&/;s/\n.*//') #) echo -n $GUID3 > $GUID3FILE echo -n $IP3 > $IP3FILE echo -n $PLAYER3 > $PLAYER3FILE fi PLAYER4=$(tac $FULLNAME | grep "Player #4" | grep "GUID:" | grep --max-count=1 "BattlEye Server:") if [ -n "$PLAYER4" ] ; then GUID4=$(echo $PLAYER4 | grep -o '[0-9a-f]\{32\}') IP4=$(echo $PLAYER4 | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}') PLAYER4=$(echo $PLAYER4 | sed 's/Player #[0-9]\{1,2\}[[:space:]]/&\n/;s/.*\n//;s/[[:space:]]([0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}/\n&/;s/\n.*//') #) echo -n $GUID4 > $GUID4FILE echo -n $IP4 > $IP4FILE echo -n $PLAYER4 > $PLAYER4FILE fi PLAYER5=$(tac $FULLNAME | grep "Player #5" | grep "GUID:" | grep --max-count=1 "BattlEye Server:") if [ -n "$PLAYER5" ] ; then GUID5=$(echo $PLAYER5 | grep -o '[0-9a-f]\{32\}') IP5=$(echo $PLAYER5 | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}') PLAYER5=$(echo $PLAYER5 | sed 's/Player #[0-9]\{1,2\}[[:space:]]/&\n/;s/.*\n//;s/[[:space:]]([0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}/\n&/;s/\n.*//') #) echo -n $GUID5 > $GUID5FILE echo -n $IP5 > $IP5FILE echo -n $PLAYER5 > $PLAYER5FILE fi exit so far, i'm just getting the GUID, IP, and player name for the first 5 players. just to see if its working. the script will record GUIDs, IPs, and player names to their own separate files as the players connect. it also clears the files for the players who have disconnected. UPDATE: I havn't thoroughly tested this script, but I'm not sure it's clearing the disconnected players correctly. If anyone has any suggestions I'd appreciate it :) Edited March 17, 2012 by Anzu Updated my code Share this post Link to post Share on other sites