def roll(casino_player : CasinoPlayer, message : str, player_id : str, sock): if message.startswith("!flip"): arguments = message.split(" ") if len(arguments) == 3: print(arguments) if arguments[2].isdigit(): if casino_player.balance > int(arguments[2]): if arguments[1] == "h" or arguments[1] == "t": coin = random.randint(0, 1) if coin == 1: pm = "flips a coin... it is {}. Looks like you won :gold: ".format(arguments[1]) casino_player.balance += int(arguments[2]) else: pm = "flips a coin... Looks like you lost :spasdead: ".format(arguments[1]) casino_player.balance -= int(arguments[2]) casino_player.save() else: pm = "first argument must be either h or t" else: pm = "insufficient funds" else: pm = "provide a number" else: pm = "flip a coin: !flip <prediction h/t> <number amount>" if casino_player.visibility: cmd = 'rawsay "{}" "{}"'.format(pm, "8421376") else: cmd = 'pm "{}" "{}" "{}"'.format(player_id, pm , "9090242") send_packet(sock, cmd, rcon_receive.command.value)
def handle_gift(event_id, message_string, sock): if event_id == rcon_event.chat_message.value: # parse the json js = json.loads(message_string) # if the server message is from a player if 'PlayerID' in js and js['PlayerID'] != '-1': if js['Message'].startswith("gift"): cmd = 'pm "{}" "{}" "{}"'.format( js['Name'], "provide a vice name, underscores ( _ ) for spaces, and a valid quantity ex [gift \"coyote and bird\" whiskey 2]", "8421376") m = re.search(r"gift \"(.+?)\" (\w+) (\w+)", js["Message"]) if m is not None: try: gifter = find_player(js["Name"]) giftee = find_player(m.group(1)) v = get_vice(m.group(2)) q = int(m.group(3)) enough_money = gifter.gift_vice(v.alias[0], q) if enough_money: if giftee.vices[v.v_id] + q <= v.cap: giftee.receive_gift_vice(v.alias[0], q) cmd = 'setvice "{}" "{}" "{}"'.format( giftee.name, v.v_id, giftee.vices[v.v_id]) else: cmd = 'pm "{}" "Could not gift vice: The recipient has too many of this vice" "{}"'.format( js['Name'], "8421376") except Exception as e: print(str(e)) cmd = 'pm "{}" "Could not gift vice" "{}"'.format( js['Name'], "8421376") send_packet(sock, cmd, rcon_receive.command.value)
def handle_player_join(event_id, message_string, sock): if event_id == rcon_event.player_connect.value: js = json.loads(message_string) send_packet( sock, 'rawsay "welcome to survival simulator, {}. Commands are !vices !start !restart" "{}"' .format(js['PlayerName'], color), rcon_receive.command.value)
def set_weaps(sock): for p in player_list: if not p.default: cmd = 'forceweap "{}" "{}" "{}" "{}" "false"'.format( p.name, p.weapon1, p.weapon2, p.nade) send_packet(sock, cmd, rcon_receive.command.value) time.sleep(0.1)
def handle_buy_quantity(event_id, message_string, sock): if event_id == rcon_event.chat_message.value: js = json.loads(message_string) if js['Message'].startswith("mvice"): cmd = 'pm "{}" "{}" "{}"'.format( js['Name'], "provide a vice name, underscores ( _ ) for spaces, and a valid quantity ex [vices whiskey 2]", "8421376") if len(js['Message'].split(" ")) > 2: vicename = js['Message'].split(" ")[1] vicequantity = js["Message"].split(" ")[2] vice = get_vice(vicename) if vice is not None and vicequantity.isnumeric(): p = find_player(js["Name"]) if p is not None: if p.buy_vice_quantity(vicename, int(vicequantity)): cmd = 'setvice "{}" "{}" "{}"'.format( p.name, vice.v_id, p.vices[vice.v_id]) else: cmd = 'pm "{}" "Insufficient funds, you have {} :gold: and it costs {} :gold: It could also be that you have reached the maximum allowed number of this vice! [{}]" "{}"'.format( js['Name'], p.balance, vice.cost * int(vicequantity), vice.cap, "8421376") else: cmd = 'pm "{}" "Please try again after this round" "8421376"'.format( js["Name"]) send_packet(sock, cmd, rcon_receive.command.value)
def check_balance(casino_player : CasinoPlayer, message : str, player_id : str, sock): if message.startswith("!balance"): pm = "Your balance is {}c. Use !pay to withdraw {}c".format(casino_player.balance, casino_player.daily) if casino_player.visibility: cmd = 'rawsay "{}" "{}"'.format(pm, "8421376") else: cmd = 'pm "{}" "{}" "{}"'.format(player_id, pm , "9090242") send_packet(sock, cmd, rcon_receive.command.value)
def pay(casino_player : CasinoPlayer, message : str, player_id : str, sock): if message.startswith("!pay"): msg = "Added your daily pay" casino_player.balance += casino_player.daily casino_player.daily = 0 casino_player.save() cmd = 'rawsay "{}" "{}"'.format(msg, "8421376") send_packet(sock, cmd, rcon_receive.command.value)
def on_packet(packet, user, to_server): if to_server and packet.name() == 'Handshake': ip, port = user.addr if ip in bans: packet = Packet("Disconnect", reason="No U") send_packet(packet, user, False) return [] return packet
def handle_chat_restart(event_id, message_string, sock): if event_id == rcon_event.chat_message.value: # parse the json js = json.loads(message_string) # if the server message is from a player if 'PlayerID' in js and js['PlayerID'] != '-1': if "!restart" == js["Message"]: send_packet(sock, 'setwave "{}"'.format(1), rcon_receive.command.value)
def get_visiblity(casino_player : CasinoPlayer, message : str, player_id : str, sock): if message.startswith("!visible"): if casino_player.visibility: pm = "public profile" else: pm = "private profile" pm += " !toggle to switch" cmd = 'pm "{}" "{}" "{}"'.format(player_id, pm, "9090242") send_packet(sock, cmd, rcon_receive.command.value)
def handle_debug_chat(event_id, message_string, sock, current_match): if event_id == rcon_event.chat_message.value: js = json.loads(message_string) if js['Message'].startswith("!debug") and ('coyote' in js['Name'] or 'nemo' in js['Name']): message = current_match.to_str() message += "current match: " + str(current_match) send_packet(sock, 'rawsay "{}" "{}"'.format(message, "8421376"), rcon_receive.command.value)
def handle_rcon_connect(event_id, message_string, sock, current_match): if event_id == rcon_event.request_data.value: js = json.loads(message_string) if int( js['CaseID'] ) == rcon_receive.request_match.value and js['RequestID'] == "initial": current_match = CurrentMatch(js['Map']) if int(js['Team1Score']) != 0 or int(js['Team2Score']) != 0: # Reset the score if it is not both zero send_packet(sock, "restartmap", rcon_receive.command.value)
def handle_chat_help(event_id, message_string, sock): if event_id == rcon_event.chat_message.value: # parse the json js = json.loads(message_string) # if the server message is from a player if 'PlayerID' in js and js['PlayerID'] != '-1': if "!help" == js["Message"]: send_packet( sock, 'rawsay "welcome to survival simulator, {}. Commands are !vices and !start" "{}"' .format(js['Name'], color), rcon_receive.command.value)
def toggle(casino_player : CasinoPlayer, message : str, player_id : str, sock): if message.startswith("!toggle"): if casino_player.visibility: pm = "Profile has been set to private" else: pm = "Profile has been set to public" casino_player.visibility = not casino_player.visibility casino_player.save() cmd = 'pm "{}" "{}" "{}"'.format(player_id, pm, "9090242") send_packet(sock, cmd, rcon_receive.command.value)
def on_packet(packet, user, to_server): if not to_server: return packet # ENTRY if packet.name() in ('Player position', 'Player position & look') and not check_acls(ENTRY, user): tell(user, "You are not allowed to enter here.", delay=0.2, lock=("acl-entry-lock",user)) new_stance = packet.data['stance'] - packet.data['y'] + user.position_old[1] packet.data['x'], packet.data['y'], packet.data['z'] = user.position_old packet.data['stance'] = new_stance back_packet = Packet() back_packet.ident = 0x0B # Player position back_packet.direction = SERVER_TO_CLIENT back_packet.data['x'] = packet.data['x'] back_packet.data['y'] = packet.data['y'] back_packet.data['z'] = packet.data['z'] back_packet.data['stance'] = packet.data['stance'] back_packet.data['on_ground'] = packet.data['on_ground'] send_packet(back_packet, user, False) return packet # MODIFY (block digging) if packet.name() == 'Player digging' and packet.data['status'] == 0: position = (packet.data['x'], packet.data['y'], packet.data['z']) if not check_acls(MODIFY, user, position): tell(user, "You are not allowed to dig here.") return [] # MODIFY/INTERACT (block placement) if packet.name() == 'Player block placement' and not all(packet.data[key] == -1 for key in ('x','y','z','direction')): position = add_direction((packet.data['x'], packet.data['y'], packet.data['z']), packet.data['direction']) if packet.data['slot']['id'] in INTERACT_IDS: if not check_acls(INTERACT, user, position): tell(user, "You are not allowed to interact with things here.") return [] else: if not check_acls(MODIFY, user, position): tell(user, "You are not allowed to place blocks here.") # For now, we tell the client that the block in the indicated direction is empty. # This should work almost all the time and is by far the easiest option. back_packet = Packet() back_packet.ident = 0x35 # Block change back_packet.direction = SERVER_TO_CLIENT back_packet.data['x'], back_packet.data['y'], back_packet.data['z'] = position back_packet.data['id'] = 0 back_packet.data['metadata'] = 0 send_packet(back_packet, user, False) # We also invalidate the packet rather than drop it, so the server auto-corrects the client's inventory packet.data['x'] += 100 return packet
def handle_balance(event_id, message_string, sock): if event_id == rcon_event.chat_message.value: js = json.loads(message_string) if js["Message"].startswith("balance"): p = find_player(js["Name"]) if p is not None: cmd = 'pm "{}" "You have {} :gold:" "{}"'.format( js['Name'], p.balance, "8421376") send_packet(sock, cmd, rcon_receive.command.value) else: cmd = 'pm "{}" "No Information" "{}"'.format( js['Name'], "8421376") send_packet(sock, cmd, rcon_receive.command.value)
def handle_request_rating(event_id, message_string, sock, current_match): if event_id == rcon_event.chat_message.value and current_match is not None: js = json.loads(message_string) print(js) if js['Message'].startswith('!elo'): print("hello world") message = "" if js['PlayerID'] == current_match.player_one.p_id: message = current_match.player_one.document.elo elif js['PlayerID'] == current_match.player_two.p_id: message = current_match.player_two.document.elo else: message = "Could not get elo" send_packet(sock, 'rawsay "{}" "{}"'.format(message, "8421376"), rcon_receive.command.value)
def handle_chat(event_id, message_string, sock): # if passed in event_id is a chat_message if event_id == rcon_event.chat_message.value: # parse the json js = json.loads(message_string) # if the server message is from a player if 'PlayerID' in js and js['PlayerID'] != '-1': if '!vices' == js["Message"]: cmd = "" for i in range(0, len(vices)): cmd = 'setvice "{}" "{}" "{}"'.format( js['Name'], i, vices[i]) send_packet(sock, cmd, rcon_receive.command.value) time.sleep(0.1) send_packet(sock, 'setlife "{}" "{}"'.format(js['Name'], 3500), rcon_receive.command.value)
def handle_get_names(event_id, message_string, sock, current_match): if event_id == rcon_event.chat_message.value: js = json.loads(message_string) if js['Message'].startswith("!names"): message = "" if current_match.player_one is not None: message += current_match.player_one.document.name else: message += "player one has no name. " if current_match.player_two is not None: message += current_match.player_two.document.name else: message += "player two has no name. " send_packet(sock, 'rawsay "{}" "{}"'.format(message, "8421376"), rcon_receive.command.value)
def get_help(casino_player : CasinoPlayer, message : str, player_id : str, sock): if message.startswith("!help"): arguments = message.split(" ") if len(arguments) == 2 and arguments[1] in ['flip', 'pay', 'balance', 'visible', 'toggle']: if arguments[1] == 'flip': pm = "Make a <guess> and flip a coin. You either lose or gain depending on your <amount>. [!flip <guess> <amount>]" if arguments[1] == 'pay': pm = "Transfer your earnings into your balance. Your earnings come from getting kills. [!pay]" if arguments[1] == 'balance': pm = "Check your balance [!balance]" if arguments[1] == 'visible': pm = "Check your visibility settings. Depending on your setting, Coysino will either pm you or display publicly" if arguments[1] == 'toggle': pm = "Toggles your visibility setting" else: pm = "Welcome to the Coysino. The commands are flip, pay, balance, visible, toggle. Do !help <command> for information on that command" cmd = 'rawsay "{}" "{}"'.format(pm, "8421376") send_packet(sock, cmd, rcon_receive.command.value)
def handle_check_price(event_id, message_string, sock): if event_id == rcon_event.chat_message.value: js = json.loads(message_string) if js['Message'].startswith("price"): cmd = 'pm "{}" "{}" "{}"'.format( js['Name'], "provide a vice or weapon name, use underscores ( _ ) for spaces", "8421376") vicename = js['Message'].split(" ")[1] vice = get_vice(vicename) if vice is not None: cmd = 'pm "{}" "Price is {} :gold: Cap is {}. Description: {}" "{}"'.format( js['Name'], str(vice.cost), str(vice.cap), vice_description[vice.v_id], "8421376") else: weapname = js['Message'].split(" ")[1] weap = get_weapon(weapname) if weap is not None: cmd = 'pm "{}" "Price is {} :gold: Weapon bonus is {}" "{}"'.format( js['Name'], str(weap.cost), str(weap.bonus), "8421376") send_packet(sock, cmd, rcon_receive.command.value)
def handle_buy_vice(event_id, message_string, sock): if event_id == rcon_event.chat_message.value: js = json.loads(message_string) if js['Message'].startswith("vice"): cmd = 'pm "{}" "{}" "{}"'.format( js['Name'], "provide a vice name, underscores ( _ ) for spaces", "8421376") if len(js['Message'].split(" ")) > 1: vicename = js['Message'].split(" ")[1] vice = get_vice(vicename) if vice is not None: p = find_player(js["Name"]) if p is not None: if p.buy_vice(vicename): cmd = 'setvice "{}" "{}" "{}"'.format( p.name, vice.v_id, p.vices[vice.v_id]) else: cmd = 'pm "{}" "Insufficient funds, you have {} :gold: and {} costs {} :gold:, It could also be that you have reached the maximum of this vice [{}]" "{}"'.format( js['Name'], p.balance, vice.alias[0], vice.cost, vice.cap, "8421376") else: cmd = 'pm "{}" "Please try again after this round" ""8421376""'.format( js["Name"]) send_packet(sock, cmd, rcon_receive.command.value)
def handle_chat(event_id, message_string, sock): # if passed in event_id is a chat_message if event_id == rcon_event.chat_message.value: # parse the json js = json.loads(message_string) # if the server message is from a player if 'PlayerID' in js and js['PlayerID'] != '-1': if js['Message'].startswith("buy"): if len(js['Message'].split(" ")) > 1: weapon = get_weapon(js['Message'].split(" ")[1]) if weapon is not None: p = find_player(js['Name']) if p is not None: if p.buy_weapon(js['Message'].split(" ")[1]): cmd = 'forceweap "{}" "{}" "{}" "{}" "false"'.format( js['Name'], p.weapon1, p.weapon2, p.nade) print(cmd) send_packet(sock, cmd, rcon_receive.command.value) else: cmd = 'pm "{}" "Insufficient funds, you have {} :gold: and it costs {} :gold:" "{}"'.format( js['Name'], p.balance, weapon.cost, "8421376") send_packet(sock, cmd, rcon_receive.command.value) else: cmd = 'pm "{}" "{}" "{}"'.format( js['Name'], "Not a valid weapon name, make sure to use underscores for spaces", "8421376") send_packet(sock, cmd, rcon_receive.command.value) else: cmd = 'pm "{}" "{}" "{}"'.format( js['Name'], "provide a weapon name, underscores ( _ ) for spaces", "8421376") send_packet(sock, cmd, rcon_receive.command.value)
def request_match(sock): send_packet(sock, '"abc" "cde"', rcon_receive.request_match.value) threading.Timer(10, request_match, (sock,)).start()
IN_ZONE = 5 # green OTHER_ZONE = 4 # yellow CONFLICT = 14 # red def wool_point(zone, user, (x,y,z)): block_metadata = None zones_here = zones.get_zones_at_point(user.dimension, (x,y,z)) if zones_here == [zone]: block_metadata = IN_ZONE elif zone in zones_here: block_metadata = CONFLICT elif zones_here: block_metadata = OTHER_ZONE if block_metadata is not None: packet = Packet('Block change', x=x, y=y, z=z, id=WOOL_ID, metadata=block_metadata) send_packet(packet, user, False) @ops_only def zonewool(message, user, name): user.morewool = name try: zone = zones.get_zones()[name] except KeyError: tell(user, "Bad zone name") return base = [int(axis) for axis in user.position] for x in range(base[0]-5, base[0]+5): for y in range(base[1]-10, base[1]): for z in range(base[2]-5, base[2]+5): wool_point(zone, user, (x,y,z))
def handle_match(event_id, message_string, sock): if event_id == rcon_event.tdm_switch_sides.value or event_id == rcon_event.match_end.value: player_list.clear() cmd = 'resetvicesall' send_packet(sock, cmd, rcon_receive.command.value)
def handle_join(event_id, message_string, sock): if event_id == rcon_event.player_connect.value: js = json.loads(message_string) cmd = 'pm "{}" "Commands: buy, balance, vice, price. You cannot use commands until you spawn so be patient" "{}"'.format( js['PlayerName'], "8421376") send_packet(sock, cmd, rcon_receive.command.value)
def start_parser(sock, cb, execute_heartbeat): #initialize some globals for network data reading #sock.recv() uses bytes so lets make them empty byte arrays buffer = b'' get_data = b'' data = b'' #these two are the delimiters for B-Man packets start_read = b'\xe2\x94\x90' #translates to ascii character "┐" end_read = b'\xe2\x94\x94' #translates to ascii character "└" timeout = 0 #used for timing out a bad connection while True: data = b'' #reset main data byte array try: #attempt to load bytes from the network #buffer size read per cycle set to 64k because YEET #set it to something lower if youre having network performance problems get_data = sock.recv(64000) except: get_data = b'' #return empty byte array is fail if get_data != b'': #if the byte array is not empty, load them into the current data buffer buffer += get_data while True: #a second while loop is needed to loop through the buffer to make sure all data is processed if buffer.find(end_read) != -1 and buffer.find( start_read ) != -1: #this if-else statement checks if the data buffer has the beginning delimiter and the end delimiter start_index = buffer.find( start_read ) #find the beginning byte position of the Boring Man packet end_index = buffer.find( end_read ) + 3 #find the ending byte position of the Boring Man packet and offset it to make sure its included (1 character string = 3 bytes) data = buffer[ start_index: end_index] #carve out the complete packet out of the data buffer and assign it to the 'data' variable for processing buffer = buffer[ end_index:] #take the complete packet out of the buffer so only the unused data is left so it can be used next cycle if data != b'': #make sure the data variable isn't empty data_info = struct.unpack_from( '<' + '3s' + 'h', data, 0 ) #read the beginning delimiter character, and then the JSON string size (in bytes) event_data = struct.unpack_from( '<' + '3s' + 'h' + 'h' + str(data_info[1]) + 's', data, 0 ) #read the beginning delimiter character, and then the JSON string size, then the event ID integer, then the JSON string itself using the size value from the line above data = b'' #reset the data variable event_id = event_data[2] #get the event ID number message_string = event_data[3].decode().strip( ) #get the JSON string and sanitize it message_string = message_string[: -1] #remove the ending delimiter character (└) #uncomment the print line below to see the event IDs received and the JSON data that comes with them # if event_id != "41" and display_packets: # print("EVENT ID: "+str(event_id)+" - JSON: "+str(message_string)) # #!!BELOW IS WHERE YOU SHOULD START PROCESSING THE GAME'S JSON DATA!! # if event_id == rcon_event.rcon_ping.value: #if the event is a ping #event ID for pinging. Boring Man will send each RCON client a ping event every few seconds, reply to it to keep your connection alive #use the 'rcon_receive.ping' enum for pinging, this tells the server its just a ping packet and to do nothing with it send_packet( sock, "1", rcon_receive.ping.value ) #i put a "1" string cuz sometimes game maker gets mad at empty strings execute_heartbeat() #this event ID is for logging in-game console messages in your python window # if event_id == rcon_event.log_message.value: # js = json.loads(message_string) # print(js['Message']) #load the JSON key 'Message' to get the log message # # if event_id == rcon_event.server_shutdown.value: #end the app if it receives a "server_shutdown" event print("Server disconnected") sys.exit() # #this a little example of a in-game chat command. type '!time' in the in-game chat window while this example is connected and see what happens! if event_id == rcon_event.chat_message.value: js = json.loads( message_string ) #message_string is the json string, so pass it through the json module timestamp = str(datetime.datetime.now().strftime( "%H:%M:%S")) #generate a time stamp if 'PlayerID' in js: id = int( js['PlayerID'] ) #get the player ID of the player who sent the message and make it an integer username = js[ 'Name'] #get the username of the player who sent the message chat = js[ 'Message'] #get the message text that was sent if id != -1: #ignore the message if it was sent by the server (ID will be -1) if chat.startswith( '!time' ): #check if the message starts with the command '!time' send_packet( sock, 'rawsay "Hello ' + str(username) + '! The time is ' + str(timestamp) + '."', rcon_receive.command.value ) #reply back to the server with an in-game console command cb(event_id, message_string, sock) print(message_string) else: break #break out of this while loop if the beginning or ending delimiter characters aren't found and go back to reading network data
def handle_rcon_logged_in(event_id, message_string, sock): if event_id == rcon_event.rcon_logged_in.value: send_packet(sock, "enablemutators", rcon_receive.command.value)
def start_parser(sock, cm, cb): #initialize some globals for network data reading #sock.recv() uses bytes so lets make them empty byte arrays buffer = b'' get_data = b'' data = b'' #these two are the delimiters for B-Man packets start_read = b'\xe2\x94\x90' #translates to ascii character "┐" end_read = b'\xe2\x94\x94' #translates to ascii character "└" timeout = 0 #used for timing out a bad connection while True: timeout += 1 if timeout > 3600000: #increase timeout value and if it reaches more then 3600000, kill the app #timeout is reset when rcon receives an "rcon_event.rcon_ping.value" event from the game server print("Timed out from server!") sys.exit() data = b'' #reset main data byte array try: #attempt to load bytes from the network #buffer size read per cycle set to 64k because YEET #set it to something lower if youre having network performance problems get_data = sock.recv(64000) except: get_data = b'' #return empty byte array is fail if get_data != b'':#if the byte array is not empty, load them into the current data buffer buffer += get_data while True: #a second while loop is needed to loop through the buffer to make sure all data is processed if buffer.find(end_read) != -1 and buffer.find(start_read) != -1: #this if-else statement checks if the data buffer has the beginning delimiter and the end delimiter start_index = buffer.find(start_read) #find the beginning byte position of the Boring Man packet end_index = buffer.find(end_read)+3 #find the ending byte position of the Boring Man packet and offset it to make sure its included (1 character string = 3 bytes) data = buffer[start_index:end_index] #carve out the complete packet out of the data buffer and assign it to the 'data' variable for processing buffer = buffer[end_index:] #take the complete packet out of the buffer so only the unused data is left so it can be used next cycle if data != b'': #make sure the data variable isn't empty data_info = struct.unpack_from('<'+'3s'+'h',data,0) #read the beginning delimiter character, and then the JSON string size (in bytes) event_data = struct.unpack_from('<'+'3s'+'h'+'h'+str(data_info[1])+'s',data,0) #read the beginning delimiter character, and then the JSON string size, then the event ID integer, then the JSON string itself using the size value from the line above data = b'' #reset the data variable event_id = event_data[2] #get the event ID number message_string = event_data[3].decode().strip() #get the JSON string and sanitize it message_string = message_string[:-1] #remove the ending delimiter character (└) #uncomment the print line below to see the event IDs received and the JSON data that comes with them if str(event_id) != "41": print("EVENT ID: "+str(event_id)+" - JSON: "+str(message_string)) # #!!BELOW IS WHERE YOU SHOULD START PROCESSING THE GAME'S JSON DATA!! # if event_id == rcon_event.rcon_ping.value: #if the event is a ping #event ID for pinging. Boring Man will send each RCON client a ping event every few seconds, reply to it to keep your connection alive #use the 'rcon_receive.ping' enum for pinging, this tells the server its just a ping packet and to do nothing with it timeout = 0 #reset timeout if a ping is received send_packet(sock, "1",rcon_receive.ping.value) #i put a "1" string cuz sometimes game maker gets mad at empty strings # #this event ID is for logging in-game console messages in your python window if event_id == rcon_event.log_message.value: js = json.loads(message_string) #print(js['Message']) #load the JSON key 'Message' to get the log message # # if event_id == rcon_event.server_shutdown.value: #end the app if it receives a "server_shutdown" event print("Server disconnected") sys.exit() cb(event_id, message_string, sock, cm) else: break #break out of this while loop if the beginning or ending delimiter characters aren't found and go back to reading network data
def request_player(sock, player_id): content = '"' + 'a' + '" "' + player_id + '"' send_packet(sock, content, rcon_receive.request_player.value)