Digital Paint Discussion Board

Paintball 2: The Game => Server Discussion => Topic started by: mRokita on February 10, 2014, 12:26:26 PM

Title: AutoMessage script that supports more than 1 message
Post by: mRokita on February 10, 2014, 12:26:26 PM
Hello,
I have written a simple AutoMessage script in python for Superman that supports more than 1 message.
Code: [Select]
import socket
import time
 
host = "83.3.12.43" #your servers ip
port = 1111 #your servers port
rcon_password = "rcon_password" #your servers rcon password
command = "say" #command
interval = 7 #in minutes
messages = ['message 1', 'message 2'] #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*interval)
Title: Re: AutoMessage script that supports more than 1 message
Post by: SuperMAn on February 12, 2014, 11:43:40 AM
Thanks, it works well.

Like I said on irc:  If you get bored again it would be nice if this script could also support multiple servers.   :)
Title: Re: AutoMessage script that supports more than 1 message
Post by: not_payl_obviously on February 12, 2014, 12:44:10 PM
Btw. nobody likes when his console is spammed with pointless messages. Just take it out, it does not make any good.
Title: Re: AutoMessage script that supports more than 1 message
Post by: xrichardx on February 12, 2014, 12:54:37 PM
@M1CH43L: you should add that this only works with python 2, python 3 will require encrypting the string.
If you get bored again it would be nice if this script could also support multiple servers.   :)
I dont know if he minds other people modifying his source, but simply replacing the vars with a list you can loop through will do that:
Code: [Select]
import socket
import time
 
servers = [
    # syntax:       ("<ip>", <port>, "<password>"),
    # example line: ("12.34.45.67", 27910, "password"),
    ("12.34.45.67", 27911, "password"),
    ]

command = "say" #command
interval = 7 #in minutes
messages = ['message 1', 'message 2'] #message list


sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
i = 0

while True:
   for server in servers:
      print("Sending to " + server[0] + ":" + str(server[1]))
      sock.sendto("\xFF\xFF\xFF\xFFrcon %s %s %s\0" % (server[2], command, messages[i%len(messages)]), (server[0], server[1]) );

   i=i+1
   time.sleep(60*interval)
Title: Re: AutoMessage script that supports more than 1 message
Post by: SuperMAn on February 12, 2014, 01:32:58 PM
Thanks xrichardx.  I will test it out later.
Title: Re: AutoMessage script that supports more than 1 message
Post by: mRokita on February 12, 2014, 03:49:27 PM
Nice script, xrichardx.
I dont have anything to editing my script, but it would be nice to ask me first ;).