[Tool/Web/Other] [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010)
#1

(Alright, that was a lame description, but I needed something. Folks, could you please gimmie a decent catchphrase for the title? Thanks!)

Server Query and RCON API - 1.2


Introduction
I was doing some investigation into SA-MP's RCON when I realised, there's no decent tool to help you with RCON (well... not for download anyway). So, out of either complete boredom, or a burning desire to figure out how to get this working, I made it. I made an API (SDK?) that retrieves every output that the server gives out, to do with that command. I've also found out a few bugs (or 'measures') along the way, bla bla bla. I'm also releasing the Server Query script, that provides you with the tools necessary to check how your server is going on, etc. (The RCON and Query protocols IMHO both compliment each other...)


Function list: SampQueryAPI
Full documentation for this class are available here.

SampQueryAPI::__construct( string $sServer, [integer $iPort = 7777] )
SampQueryAPI::getBasicPlayers( )
SampQueryAPI::getDetailedPlayers( )
SampQueryAPI::getInfo( )
SampQueryAPI::getRules( )
SampQueryAPI::isOnline( )


You can use this class, as an example, to get the server environment rules, like below. For an example list of the rules that can be sent, please check the documentation.

Code:
<?php

$query = new SampQueryAPI('192.168.4.1', 7777);

print_r
(
    $query->getRules()
);

?>
Function list: SampRconAPI
Full documentation for this class are available here.

SampRconAPI::__construct( $sServer, $iPort, $sPassword )
SampRconAPI::addressBan( string $sIPAddress )
SampRconAPI::addressUnban( string $sIPAddress )
SampRconAPI::adminSay( string $sMessage )
SampRconAPI::Call( string $sCommand, [float $fDelay = 1.0] )
SampRconAPI::gameChangeMode( string $sGamemode )
SampRconAPI::gameExec( string $sConfig )
SampRconAPI::gameExit( )
SampRconAPI::gameLoadFilterscript( string $sFilterscript )
SampRconAPI::gameNextMode( )
SampRconAPI::gameReloadFilterscript( string $sFilterscript )
SampRconAPI::gameUnloadFilterscript( string $sFilterscript )
SampRconAPI::getCommandList( )
SampRconAPI::getServerVariables( )
SampRconAPI::isOnline( )
SampRconAPI::playerBan( integer $iPlayerID )
SampRconAPI::playerKick( integer $iPlayerID )
SampRconAPI::reloadBans( )
SampRconAPI::reloadLogs( )
SampRconAPI::setGravity( float $fGravity )
SampRconAPI::setWeather( integer $iWeatherID )


You can use this class to do general administration work with, calling custom commands, or maybe banning someone. The below example explains how to ban an IP address, and how to unban another.

Code:
<?php

$rcon = new SampRconAPI('192.168.4.1', 7777, 'lolarcon');

$rcon->addressBan('192.168.5.1'); // Just banned an address.
$rcon->addressUnban('192.168.5.6'); // Just unbanned another address.

$rcon->reloadBans(); // You'll need to reload the ban files!

?>
Do you need to call a command that is not listed here, for example a custom RCON command? You can use the SampRconAPI::Call() method (example 1), or you can integrate this into another class to make your code all nice and neat! (example 2)

Code:
<?php

/* Example 1 */
$rcon = new SampRconAPI('192.168.4.1', 7777, 'lolarcon');
$rcon->Call('your_custom_func_here');


/* Example 2 */
class CustomRcon extends SampRconAPI
{
	public function someFunctionName()
	{
		parent::Call('your_custom_func_here');
	}
}

$rcon = new CustomRcon('192.168.4.1', 7777, 'lolarcon');
$rcon->someFunctionName();
Download
Was that simple enough? If not, I'll be uploading a sample RCON panel, as well as a script demonstrating examples what you could do with the query script. Watch this space, or maybe this space, don't really know.



API files
(Both files updated 05/07/2010)
SampQueryAPI: http://files.typefish.co.uk/sa-mp/SampQueryAPI.php
SampRconAPI: http://files.typefish.co.uk/sa-mp/SampRconAPI.php

Examples
Query example: http://gist.github.com/234209

(Don't worry, they'll download in your browser... hopefully.)

Remember, no mirrors, but most importantly, post if you have problems!
Reply


Messages In This Thread
Server Query and RCON API - Be an admin at ease! (05/07/2010) - by Westie - 23.10.2009, 19:38
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by MenaceX^ - 23.10.2009, 19:41
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Silent314 - 23.10.2009, 19:46
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Westie - 23.10.2009, 19:52
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Johnstonio - 23.10.2009, 20:03
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by capikepi - 27.10.2009, 22:34
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Westie - 28.10.2009, 17:09
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by _Healer_ - 28.10.2009, 20:39
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by dirkblok - 29.10.2009, 16:20
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by @TheShadow@ - 31.10.2009, 12:06
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Westie - 31.10.2009, 22:26
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by (Jeff) - 13.11.2009, 12:54
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by sakang - 13.11.2009, 13:58
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by thimo - 13.11.2009, 15:13
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by elvago - 13.11.2009, 17:28
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Westie - 13.11.2009, 20:58
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by devnull - 12.01.2010, 03:34
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by LifestealeR - 12.01.2010, 15:38
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Westie - 12.01.2010, 15:49
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Nokia - 13.01.2010, 18:14
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Westie - 13.01.2010, 20:09
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Amit_B - 14.01.2010, 11:08
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Perker12345 - 14.01.2010, 22:24
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Westie - 16.01.2010, 19:12
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Mechscape - 16.01.2010, 19:34
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Jay. - 16.01.2010, 21:26
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Crazzhell - 17.01.2010, 18:03
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Nekom - 16.02.2010, 17:03
Re: [PHP] Server Query and RCON API - Be an admin at ease! - by Westie - 16.02.2010, 17:37
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Peppe95 - 07.09.2010, 20:53
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Westie - 08.09.2010, 15:35
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Winston - 09.09.2010, 08:01
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by xyly - 09.09.2010, 15:26
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Westie - 09.09.2010, 15:31
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by xyly - 09.09.2010, 15:35
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Cameltoe - 23.09.2010, 20:52
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Brian_Furious - 14.10.2010, 18:50
Re: [PHP] Server Query and RCON API - by Westie - 23.10.2010, 16:14
Re: [PHP] Server Query and RCON API - by epic.matrix - 23.10.2010, 17:25
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Typhome - 31.10.2010, 11:52
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Sim00n - 02.11.2010, 18:06
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by HACKHERS - 05.11.2010, 21:14
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Westie - 06.11.2010, 08:56
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Typhome - 06.11.2010, 13:07
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Westie - 06.11.2010, 17:44
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Shinoda90 - 08.11.2010, 11:11
Respuesta: Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by zSuYaNw - 08.11.2010, 12:51
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by sciman001 - 24.04.2011, 16:54
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by tony_fitto - 28.04.2011, 03:43
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Slice - 28.04.2011, 11:08
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Westie - 28.04.2011, 16:53
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by falenone1 - 28.04.2011, 17:11
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Westie - 28.04.2011, 17:37
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by falenone1 - 28.04.2011, 17:42
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Westie - 28.04.2011, 18:52
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by tony_fitto - 28.04.2011, 19:41
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by sciman001 - 29.04.2011, 01:15
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Westie - 29.04.2011, 09:40
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by XFlawless - 18.06.2011, 12:24
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Sascha - 18.06.2011, 12:27
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by XFlawless - 18.06.2011, 12:29
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Sascha - 18.06.2011, 12:32
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by lolumadd_ - 29.06.2011, 01:48
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Unknown123 - 06.12.2011, 20:24
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by lamarr007 - 28.12.2011, 11:31
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by CoaPsyFactor - 08.01.2012, 23:37
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by mikiii18 - 14.01.2012, 17:29
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by robintjeh - 14.01.2012, 22:35
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Luka P. - 27.01.2012, 12:45
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by royal_king - 27.01.2012, 17:59
Respuesta: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by [DOG]irinel1996 - 27.01.2012, 23:17
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by TheArcher - 20.02.2012, 17:32
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by dydjyz - 21.02.2012, 01:36
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by toofast - 05.07.2013, 08:40
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by God'Z War - 10.07.2013, 11:53
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by _Application_ - 07.09.2013, 18:32
AW: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Arendium - 28.10.2013, 09:18
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Asdelon - 03.06.2014, 14:19
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Mark_Weston - 05.06.2014, 17:41
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Tisot - 20.08.2014, 20:26
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Tisot - 20.08.2014, 20:28
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by nickdodd25 - 29.08.2014, 17:50
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by papagei9 - 15.05.2015, 13:47
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by ZaBraNjeNi - 03.10.2016, 18:52
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by BroZeus - 04.10.2016, 16:21
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by ZaBraNjeNi - 05.10.2016, 19:17
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by BroZeus - 06.10.2016, 04:39
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by KokyZ - 06.02.2017, 14:01
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by azzerking - 06.02.2017, 18:22
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by KokyZ - 06.02.2017, 19:40
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by KokyZ - 07.02.2017, 19:16
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by KokyZ - 17.02.2017, 14:56
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by 4D1L - 25.02.2017, 19:09
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Romz - 27.09.2017, 12:36
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by cuber - 27.09.2017, 12:42
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Romz - 27.09.2017, 12:55
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by cuber - 27.09.2017, 12:57
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Rusich - 05.11.2017, 20:35
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by SupperRobin6394 - 05.11.2017, 21:04
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Rusich - 06.11.2017, 08:41
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by x8er - 28.03.2018, 16:56
Re: [PHP] Server Query and RCON API - Be an admin at ease! (16/02/2010) - by Kaperstone - 28.03.2018, 22:20

Forum Jump:


Users browsing this thread: 1 Guest(s)