rCon tool like a backend of server. [CLI / Linux / Go-lang]
0 replies, posted
Hello!
[I](all examples for linux here)[/I]
Friend and me do fork on go-lang [URL="https://github.com/james4k/rcon"]rcon tool[/URL].
What's we have at start: buggy buffered [B]rcon tool with amazin' speed[/B] of work.
We fix bugs and and added features what's we need to work with the site and the server.
Now anyone can download these sources, compiled for your OS and establish interaction site and rcon.
It's tool work with all games who can rCon protocol (CS, CS:S, TF2, etc.)
Simple example of use on site (if site and rcon tool on 1 server and you know linux basics :)):
[CODE]
<?
shell_exec("rcon -cmd='inv.giveplayer \"Nick\" \"Item Name\" \"Amount\"'");
?>
[/CODE]
You can use this for shop. If you know how to code simple php :). it's rly fast. More faster then PHP.
Another way to use: online list on site.
In linux console:
[CODE]setsid bash -c 'while :; do rcon -cmd="status" > ./rust/rcon/online; sleep 5; done'&>/dev/null &[/CODE]
This simple example do "status" command every 5 second and place into file. ([URL="http://rust.ttyh.ru/rcon/online"]like this[/URL]).
Then you can parse this from PHP. Like me:
[CODE]<?
$str = file_get_contents('rcon/online'); //way to file
$reg = '(\\d+)\\s+\\"([^"]+)"\\s+(\\d+)\\s+(\\d+)\\w\\s+([0-9.]+)\\s*';
$reg = str_replace("/", "\/", $reg);
preg_match_all("/$reg/", $str, $words, PREG_SET_ORDER);
echo "<div>";
echo "<table width='100%'>";
echo "<tr>";
echo "<td><center>№</center></td>";
echo "<td>Nick</td>";
echo "<td width='58'><center>Online</center></td>";
echo "</tr>";
$i = 0;
for ($i = 0; $i <= 200; $i++) //200 max players.. Yeap, this is stupid, to place here.. but i'am lazy :D
{
if($words[$i][4] / 60 != 0)
{ $time = number_format($words[$i][4] / 60,0,",","."); }
else
{ $time = $words[$i][4]; }
if(!empty($words[$i][1]))
{
$n = $i + 1;
echo "<tr>";
echo "<td><center>". $n ."</center></td>";
echo "<td><a href=http://steamcommunity.com/profiles/" .$words[$i][1].">" .$words[$i][2]."</td>";
echo "<td><center>".$time." min.</center></td>";
echo "</tr>";
}
}
echo "</table>";
echo "</div>";
?>
[/CODE]
On site it looks like on my server [URL="http://rust.ttyh.ru/"]site[/URL].
Also. this rcon tool can listen port.
[CODE]rcon -listen[/CODE]
How you can use this? I use this for check "Connected messages" and nick "SERVER CONSOLE" for autokick and ban this ugly guys. Another way of "listen" - do chat on [URL="http://rust.ttyh.ru/?m=chat"]site[/URL](i dont give privilegies to all user for post in chat via site, but i can :)).
[B]You can download sources on [URL="https://github.com/cxindex/rust-cli"]github[/URL].[/B]
All question place here or email me: dyworm at gmail dot com.
Want to thank us?
[url=https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5LQ4Z3YP9X6CW][img]https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif[/img][/url]
also you can [URL="http://toprustservers.com/ttyh"]vote[/URL] for project :)
Sorry, you need to Log In to post a reply to this thread.