Added query c

This commit is contained in:
Emily 2018-09-26 09:42:18 +02:00
parent 006fc2c369
commit 7655d8f2ad

View File

@ -51,13 +51,35 @@ def query_r():
return packet
def query_c():
packet_data = []
players_scores = get_players_scores()
packet_data.append(len(players_scores))
for name, value in players_scores.items():
packet_data.append([
len(name), name,
value
])
flat_packet_data = dataHelper.flatten(packet_data)
packet = struct.pack(b"<H" + b"c%dscI" * flat_packet_data[0]
% [len(x) for x in players_scores.keys()],
*flat_packet_data)
def get_online_players(): #TODO
return 0
def get_rules(): #TODO
return {"Rule name sample": "Rule value"}
def get_players_scores():
return {"Sunpy": 64, "username": 123}
RESPONSE = { #TODO: c, d & p (https://wiki.sa-mp.com/wiki/Query_Mechanism)
b"i": query_i,
b"r": query_r
b"r": query_r,
b"c": query_c
}