|
![]() |
|
Thread Tools | Display Modes |
![]() |
#1 |
Gangsta
![]() ![]() ![]() ![]() Join Date: Jul 2009
Posts: 857
Reputation: 63
|
![]()
(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! ?> 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! Last edited by Westie; 16/08/2011 at 06:20 PM. |
![]() |
![]() |
![]() |
#2 |
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Aug 2008
Posts: 3,262
Reputation: 13
|
![]()
Wow, that's awesome.
Well done. |
![]() |
![]() |
![]() |
#3 |
Big Clucker
![]() ![]() Join Date: Jul 2008
Posts: 59
Reputation: 0
|
![]()
Very nice.
P.S.: You got your download links backwards. ![]() |
![]() |
![]() |
![]() |
#4 |
Gangsta
![]() ![]() ![]() ![]() Join Date: Jul 2009
Posts: 857
Reputation: 63
|
![]()
Oh, thanks for that. Fixed that stupid mistake
![]() |
![]() |
![]() |
![]() |
#5 |
Little Clucker
![]() Join Date: Oct 2009
Posts: 9
Reputation: 0
|
![]()
Sounds awesome, I can't wait to see the panel.
![]() |
![]() |
![]() |
![]() |
#6 |
Little Clucker
![]() Join Date: May 2009
Posts: 6
Reputation: 0
|
![]()
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /szerver/SampRconAPI.php on line 20
|
![]() |
![]() |
![]() |
#7 |
Gangsta
![]() ![]() ![]() ![]() Join Date: Jul 2009
Posts: 857
Reputation: 63
|
![]()
You may of modified it by mistake. Re-download the file.
|
![]() |
![]() |
![]() |
#8 |
Big Clucker
![]() ![]() Join Date: Oct 2009
Posts: 67
Reputation: 0
|
![]()
Awesome
|
![]() |
![]() |
![]() |
#9 |
Huge Clucker
![]() ![]() ![]() Join Date: Aug 2009
Posts: 314
Reputation: 0
|
![]()
Helpful
![]() ![]() |
![]() |
![]() |
![]() |
#10 | |
Big Clucker
![]() ![]() Join Date: May 2009
Posts: 159
Reputation: 0
|
![]() Quote:
|
|
![]() |
![]() |
![]() |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
[FilterScript] [FS] RCON-manager (control your server easier from RCON-console) | Correlli | Filterscripts | 34 | 09/04/2015 09:28 PM |
i need car only rcon or admin can use | matdav | Help Archive | 10 | 30/11/2009 10:21 PM |
Server query url? | kazimieras | Server Support | 2 | 03/03/2009 12:11 AM |
Server Query | Joe_Dean | Server Support | 6 | 27/01/2009 12:33 AM |