0
import socket
import time
 


host = "192.168.1.12" #your servers ip
port = 28960 #your servers port
rcon_password = "rconhere" #your servers rcon password
command = "say" #command
messages = [ 'message1', 'message2', 'message3', 'message5'] #message list

 
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.connect((host, port))
i = 0
while True:
   print("Sending..")
   sock.send("\xFF\xFF\xFF\xFFrcon %s %s %s\0" % (rcon_password, command, messages[i%len(messages)]))
   i=i+1
   time.sleep(60)

This script works with python3 when we encode but this wont respond to Server it only responses to when i execute this script with python2

Ain Gaming
  • 11
  • 2
  • this is why... TypeError: a bytes-like object is required, not 'str' . – D.L Jul 31 '22 at 08:04
  • Use `b"..."` for all the strings that are being passed to [send](https://docs.python.org/3/library/socket.html#socket.socket.send) (which means everything apart from the print line in your example). – ekhumoro Jul 31 '22 at 09:47

0 Answers0