View Single Post
dustinandband
Senior Member
Join Date: May 2015
Old 10-13-2018 , 18:06   Re: Shell script to check if server's empty
Reply With Quote #4

Quote:
Originally Posted by nosoop View Post
  1. There's a couple of ways. You can either send the A2S_INFO (Source Server) query via some application, use a standalone rcon tool to read the status output, or write some plugin using the socket extension to respond with your desired info
  2. Don't think so. Not sure if the logging facilities would catch that.
Any particular reason why a SteamWorks-based plugin that gets forwarded an event on restart request won't work for you?
Thanks.

I've compiled the rcon tool, but I'm not sure if I'm using it correctly.
In this example, the rcon password is just a made up password.

Code:
root@testsvrchi:~# ./rcon --help
Usage: <programname> --rcon="<ip> <port> <rconpw> <cmd>"
Example: --rcon="127.0.0.1 27960 myrconpw devmap oasis"

root@testsvrchi:~# ./rcon --rcon="74.91.124.177 27015 rconpassword101 status"
Sending:
¦¦¦¦rcon rconpassword101 status

Could not receive.
Not sure if there's a more specific rcon command to query "players - humans" count, or if it's something that would have to be parsed from the status command.
Code:
] rcon status
hostname: Left 4 Dead 2
version : 2.1.5.2 7149 secure  (unknown)
udp/ip  : 74.91.124.177:27015 [ public same ]
os      : Linux Dedicated
map     : c2m1_highway
players : 1 humans, 0 bots (4 max) (not hibernating) (reserved 186000000a383ab)
Edit:
Haven't worked with c++ / c before, but it looks like the error is stemming from this returning -1:
Code:
    n = recvfrom(sockfd, srline, MAX_SR_LINE, 0, NULL, NULL);
    if(n < 0) {
        close(sockfd);
        return RC_RECV;
    }
http://pubs.opengroup.org/onlinepubs.../recvfrom.html

Edit#2
Forgot to mention I tried the local IP as well
Code:
./rcon --rcon="127.0.0.1 27015 rconpassword101 status"

Last edited by dustinandband; 10-13-2018 at 19:03.
dustinandband is offline