Author Topic: "r_con [password] say" help  (Read 4281 times)

Ace

  • Autococker
  • Posts: 661
"r_con [password] say" help
« on: November 08, 2014, 10:21:18 PM »
What I am looking for is a script or something that tells the console to print out a message every so often. I know superman's servers do it, but I couldn't find anything on forums about it. If anyone has the script for this, let me know. I'd rather use one that works than write my own.

gotmtdew

  • PGP
  • Posts: 37
Re: "r_con [password] say" help
« Reply #1 on: November 09, 2014, 12:50:34 AM »

mRokita

  • Autococker
  • Posts: 598
Re: "r_con [password] say" help
« Reply #2 on: November 09, 2014, 03:13:17 AM »
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)

You must to have python2.7 installed on the computer you want to run it on.
Just save this code to a *.py file and run it.

Ace

  • Autococker
  • Posts: 661
Re: "r_con [password] say" help
« Reply #3 on: November 09, 2014, 11:50:32 AM »
I must be blind, thanks guys.

mRokita

  • Autococker
  • Posts: 598
Re: "r_con [password] say" help
« Reply #4 on: November 09, 2014, 12:56:09 PM »
I must be blind, thanks guys.
Np, talk to me on IRC when you will have any problem :).

mRokita

  • Autococker
  • Posts: 598
Re: "r_con [password] say" help
« Reply #5 on: December 30, 2014, 04:21:24 AM »
Now, with pypb2lib you can do it in an easier way.
On linux, simply clone the github repo (git clone https://github.com/hTmlDP/pyp2lib
Thats an example python script
Code: [Select]
from pypb2lib import *
from time import sleep
s=Server(hostname='127.0.0.1', port=27910, rcon_password='1234')
while 1:
   s.Say('{C}9visit {C}S{I}{U}http://htmldp.com') #{C} - color {I}- italic {U} -underline
   sleep(120) # wait 120 seconds
« Last Edit: January 04, 2015, 07:21:28 PM by hTml »