fiveserver
fiveserver copied to clipboard
Rankings in games
Unfortunately I don't have the skills to adapt it. The code to view the general ranking in the game has been reported on Evo-web. I leave link to the post:
https://evoweb.uk/threads/network-rankings-protocol.92544/
I tried the code by putting it in pes6.py, but it didn't work because it was written in python2. I leave it here for those who are able to adapt it in python3.
The first step is to create a file named rankings.php on your webserver and put this code inside the file
PHP:
general 11/11 2022-11-05 03:59:48 0,0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0,0,0 1,1,Prankster,100,550,500,1,49,198,998,1,4 2,1208,Prankster2,100,452,400,3,49,178,997,1,4 3,8701,Prankster3,100,434,380,5,49,165,887,1,4 4,1207,Prankster4,100,366,310,7,49,162,777,1,4 5,6612,Prankster5,100,358,300,9,49,156,567,1,2 6,3283,Prankster6,100,259,199,11,49,134,456,1,2 7,13859,Prankster7,100,262,200,13,49,150,345,1,3 8,8702,Prankster8,100,264,200,15,49,160,299,1,3 9,6530,Prankster9,100,266,200,17,49,162,280,1,3 10,5513,Prankster10,100,268,200,19,49,90,270,1,0 11,69,Prankster11,100,270,200,21,49,20,260,1,0'; ?>
To change the rankings shown ...
Each entry in the file is a ranking and the format is
1,1,Prankster,100,250,200,1,49,200,300,1,0
rank,players profile id,profile name, points, games, wins, draws, losses, streak record , rating, a value of 1, the division (4 means D1)
The table supports up to 100 players. To extend it you can change the
11/11 inside the file to 100/100
Of course remember to add more ranking lines to the file as well.
The second step is to edit your pes6.py file
(https://github.com/juce/fiveserver/blob/master/lib/fiveserver/protocol/pes6.py)
replace the following code which is already in pes6.py
Python:
def getWebServerList_2200(self, pkt):
self.sendZeros(0x2201,4)
#self.sendData(0x2202,data) #TODO
self.sendZeros(0x2203,4)
With my code instead
Python:
def getWebServerList_2200(self, pkt):
log.debug('pes6.getWebServerList_2200')
data = '%s%s%s%s%s%s%s%s' % (
'\x00',
'\x00',
'\x00',
'\x00',
'\x00',
'\x00',
'\x00',
'\x85')
try:
self.sendExplicitData(0x2201, 8, 7, data)
except:
log.msg('pes6.getWebServerList_2200, error while trying to send %s' % str(data))
url_length = 128
rank_urls = ['http://127.0.0.1/rankings.php' for u in range(7)]
rank_url_types = [0, 256, 512, 768, 1024, 1024, 1280, 1536]
data_length = (7 * (url_length + 2))
data = [0 for x in range(data_length)]
data = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s' % (
struct.pack('!H',rank_url_types[0]),
'%s%s' % (rank_urls[0],'\0'*(128-len(rank_urls[0]))),
struct.pack('!H',rank_url_types[1]),
'%s%s' % (rank_urls[1],'\0'*(128-len(rank_urls[1]))),
struct.pack('!H',rank_url_types[2]),
'%s%s' % (rank_urls[2],'\0'*(128-len(rank_urls[2]))),
struct.pack('!H',rank_url_types[3]),
'%s%s' % (rank_urls[3],'\0'*(128-len(rank_urls[3]))),
struct.pack('!H',rank_url_types[4]),
'%s%s' % (rank_urls[4],'\0'*(128-len(rank_urls[4]))),
struct.pack('!H',rank_url_types[5]),
'%s%s' % (rank_urls[5],'\0'*(128-len(rank_urls[5]))),
struct.pack('!H',rank_url_types[6]),
'%s%s' % (rank_urls[6],'\0'*(128-len(rank_urls[6]))))
log.debug('2202 data is: ' + str(data))
try:
self.sendData(0x2202,data)
except:
log.msg('pes6.getWebServerList_2200, Error while sending data to client')
try:
self.sendZeros(0x2203,4)
except:
log.msg('pes6.getWebServerList_2200, Error while sending data to client')
Remember to change "http://127.0.0.1/rankings.php" in the code to the location of your php file.
Licensed under Creative Commons 3.0
Remember this code is for python2 and it doesn't work on this python3 version. Therefore I leave it only for those who know how to adapt it. Video demo https://youtu.be/gxuE_DgLjcs
Argh.. The post "https://evoweb.uk/threads/network-rankings-protocol.92544/" seems moved or deleted.. Do you have a archive of this topic or the new link ?
Argh.. The post "https://evoweb.uk/threads/network-rankings-protocol.92544/" seems moved or deleted.. Do you have a archive of this topic or the new link ?
Hi, sorry for the late reply. The code is above, but it's in python2. Therefore it doesn't fit this which is written in python3. I asked for help here and also in various forums... But I didn't get any answers. I know for sure that in python2 it works. But I would like to have it for ours which is written in python3. But no one wants to adapt it. Sin. If you know anything, or can do anything, I hope you can remember me. I shared it here because I knew it would be lost.
Hello
Argh.. The post "https://evoweb.uk/threads/network-rankings-protocol.92544/" seems moved or deleted.. Do you have a archive of this topic or the new link ?
Hi, sorry for the late reply. The code is above, but it's in python2. Therefore it doesn't fit this which is written in python3. I asked for help here and also in various forums... But I didn't get any answers. I know for sure that in python2 it works. But I would like to have it for ours which is written in python3. But no one wants to adapt it. Sin. If you know anything, or can do anything, I hope you can remember me. I shared it here because I knew it would be lost.
Hi, I don't know how it's works on python cause i m working on java, but for display ranking i do like that:
- when you ask ranking from game, that ask database for query.
- the query is do by http post value: for example for general ranking post query is like that:
- type=6&division=5&from=0&records=100&pid=2&flag=0
- so you just need to make a php page who ask database with this fields
- and adapt it to display all data like " general 11/11 2022-11-05 03:59:48 0,0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0,0,0 1,1,Prankster,100,550,500,1,49,198,998,1,4 2,1208,Prankster2,100,452,400,3,49,178,997,1,4 3,8701,Prankster3,100,434,380,5,49,165,887,1,4 "
- for the number of player (11/11) just use count function from database query
- for the date use timestamp.
- For others value you have on all on database
- Don't forgive to use pid="your pid"
Good luck
Hello
Argh.. The post "https://evoweb.uk/threads/network-rankings-protocol.92544/" seems moved or deleted.. Do you have a archive of this topic or the new link ?
Hi, sorry for the late reply. The code is above, but it's in python2. Therefore it doesn't fit this which is written in python3. I asked for help here and also in various forums... But I didn't get any answers. I know for sure that in python2 it works. But I would like to have it for ours which is written in python3. But no one wants to adapt it. Sin. If you know anything, or can do anything, I hope you can remember me. I shared it here because I knew it would be lost.
Hi, I don't know how it's works on python cause i m working on java, but for display ranking i do like that:
- when you ask ranking from game, that ask database for query.
- the query is do by http post value: for example for general ranking post query is like that:
- type=6&division=5&from=0&records=100&pid=2&flag=0
- so you just need to make a php page who ask database with this fields
- and adapt it to display all data like " general 11/11 2022-11-05 03:59:48 0,0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0 0,0,0,0,0 1,1,Prankster,100,550,500,1,49,198,998,1,4 2,1208,Prankster2,100,452,400,3,49,178,997,1,4 3,8701,Prankster3,100,434,380,5,49,165,887,1,4 "
- for the number of player (11/11) just use count function from database query
- for the date use timestamp.
- For others value you have on all on database
- Don't forgive to use pid="your pid"
Good luck
That's exactly what the code I posted does... But being in python2, on the server written in python3 it doesn't work... Since the syntax has changed from python2 to 3. I hope someone with experience in python3 can help me. Anyway, thanks for your kind response❤️ I hope one day I can have the pleasure of trying yours in java😉