Community forums
scan for online players
- seppl
- OFFLINE
- 9 POSTS
- 0 LIKES
-
29 Feb 2016 14:20
I wrote a little python3 script to scan for online users on your server.
Just take a look at the code it is not too hard to understand.
Just take a look at the code it is not too hard to understand.
- seppl
- OFFLINE
- 9 POSTS
- 0 LIKES
-
29 Feb 2016 14:21
#!/usr/bin/python3
import urllib.request as req
def scan_for_id(url,id):
f = req.urlopen(url)
text = f.read()
text = text.decode("utf-8")
return "playerdbid="+id in text
def scan_for_alias_by_id(url,id):
f = req.urlopen(url)
text = f.read()
text = text.decode("utf-8")
if( "playerdbid="+id in text):
textlines = text.split("\n")
for lineno,line in enumerate(textlines):
if("playerdbid="+id in line):
next_line = textlines[lineno + 1]
return next_line[:next_line.index("<")].strip()
return ""
if __name__ == "__main__":
import os, time
PLID = "24031"
PL_NAME = "seppl" # the usual name
MY_ADDR = "your email here"
__SEND_EMAIL = False
if __SEND_EMAIL:
while(1):
if(scan_for_id("http://drunknoobs.com/game-server",PLID)):
f = open("urt_sent.tx","w")
f.write("player '{}' is online (ID: {})\n".format(PL_NAME,PLID))
f.close()
os.system("mail {} < urt_sent.tx".format(MY_ADDR))
os.unlink("urt_sent.tx")
time.sleep(60)
else:
print(scan_for_id("http://drunknoobs.com/game-server",PLID))
print(scan_for_alias_by_id("http://drunknoobs.com/game-server",PLID))
- JonnyUK
- OFFLINE
- Founder
- 358 POSTS
- 43 LIKES
-
29 Feb 2016 14:24
What is the purpose of this? We already have code that does this (Your code parses our code for the information)
- seppl
- OFFLINE
- 9 POSTS
- 0 LIKES
-
29 Feb 2016 14:25 | Last edit: 29 Feb 2016 14:28
I know. it is a frontend for your private machine.
So you are notified, if one of your friends is online.
Btw: currently your webserver does not display the online players. (I do not know why) so it does not work.
So you are notified, if one of your friends is online.
Btw: currently your webserver does not display the online players. (I do not know why) so it does not work.
- Mazfer
- OFFLINE
- Web Manager
- 562 POSTS
- 50 LIKES
“Just because you aren't paranoid doesn't mean they aren't after you.”
- web techy on DN / www.rsgraphics.fi
29 Feb 2016 14:59 | Last edit: 29 Feb 2016 15:01
The script that shows the online players is called in from another server, so if that server is down then online players or banned players are not shown. If the other server is up, then it works fine.
You cant expect something to work if the connection between two servers is interrupted or down. That's like expecting to be able to access the internet without a connection.
You cant expect something to work if the connection between two servers is interrupted or down. That's like expecting to be able to access the internet without a connection.