Game server admin's helping the community setup and maintain great dedicated game servers.
----Home----Submit News ----Forum--------Guides----


Go Back   FPSadmin.com > BattleField > Bad Company 2 > BC2: Remote Admin Tool Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-29-2010, 08:39 AM
JLNNN's Avatar
JLNNN JLNNN is offline
Member
 
Join Date: Mar 2010
Location: Germany
Age: 29
Posts: 39
Rep Power: 0
JLNNN is on a distinguished road
BC2Conn v1.06 - PHP class to communicate with a gameserver

This is a PHP class that allows you to administrate / observer your Battlefield Bad Company 2 gameserver just by using a few methods. Visit the project's site for more information!

Download: BC2Conn_v1.06 (updated: 16.01.2011)

There are some XML files for map/squad/playmode/team names, too.

You can find the API here.

Visit the official message board of BC2Conn!

If you experience any problems - let me know

Changelog:
v1.06
* R28 support
* updated maxNames.xml
* added maps for Battlefield Bad Company 2: Vietnam
Preview of how to use it:

PHP Code:
<?php
/**
 * some examples - how to use the BC2Conn class
 *
 * this file requires BC2Conn >= v1.03-Update1
 *
 * project page: http://bc2conn.sf.net/
 * board       : http://bc2conn.sf.net/board/
 * API         : http://bc2conn.sf.net/API/
 *
 * live demo of this script: http://bc2conn.sf.net/demo/
 *
 * contact     : JLN@hush.ai
 *
 * $Id: example.php 15 2010-06-10 16:05:40Z jlnnn $
 */

// include the class file
include ("BC2Conn.php");

// opens a connection to gameserver
$BC2Conn = new BC2Conn("127.0.0.1"48888);

if (!
$BC2Conn->isConnected()) {
    echo 
"Connection could not be established. " .
    
"To debug, set '-d' as 3rd parameter to new connection.<br />" .
    
"<br />" .
    
"Example: \$BC2Conn = new BC2Conn(\"127.0.0.1\", 48888, \"-d\");";

    return 
0// stop executing this script
}

// secure login
$BC2Conn->loginSecure("yourRconPassword");

// unsecure login (not salted)
//$BC2Conn->loginInsecure("yourRconPassword");

// some random serverinformation
echo "Server IP: " $BC2Conn->getServerIP() . "<br />";
echo 
"Servername: " $BC2Conn->getServerName() . "<br />";
echo 
"Players: " $BC2Conn->getCurrentPlayers() . "/" $BC2Conn->getMaxPlayers() . "<br />";
echo 
"Playmode: " $BC2Conn->getCurrentPlaymodeName() . "<br />";
echo 
"Current Map: " $BC2Conn->getCurrentMapName() . "<br /><br /><br /><u>Players:</u><br /><br />";

// playerlist
$playerNames $BC2Conn->getPlayerlistNames();
foreach (
$playerNames as $key => $content) {
    if (
$BC2Conn->getPlayerClantag($content) != "") {
        echo 
"[" $BC2Conn->getPlayerClantag($content) . "]";
    }
    echo 
" " $BC2Conn->getPlayername($content) . " - Kills: ";
    echo 
$BC2Conn->getPlayerKills($content) . " | Deaths: ";
    echo 
$BC2Conn->getPlayerDeaths($content) . " | Score: ";
    echo 
$BC2Conn->getPlayerScore($content) . "<br />";
}

/*
 // change playmode and map and perform nextmap to save settings
 $BC2Conn->adminSetPlaylist("SQDM");
 $BC2Conn->adminMaplistClear();
 $BC2Conn->adminMaplistAppend("Levels/MP_006SDM"); // Arica Harbor
 $BC2Conn->adminMaplistSave();
 $BC2Conn->adminRunNextLevel();
 */

// say something as admin
//$BC2Conn->adminYellMessage("I'm testing BC2Conn PHP class - visit http://bc2conn.sf.net/ for more information!");

// get all available commands
//$BC2Conn->adminGetAllCommands();

// restart current map
//$BC2Conn->adminRestartMap();

// remove map index 3 from maplist and add a new one
//$BC2Conn->adminMaplistRemove(3);
//$BC2Conn->adminMaplistAppend("Levels/MP_003");

// set a new serverdescription
//$BC2Conn->adminVarSetServerDescription("Get the BC2Conn PHP class to administrate your Battlefield Bad Company 2 gameserver - visit http://bc2conn.sf.net/");

// kick a specific player
//$BC2Conn->adminKickPlayer("John Doe");

// ban a specific player permanently and view all bans by playername
//$BC2Conn->adminBanAddPlayername("John Doe");
//print_r($BC2Conn->adminBanlistList());

// turn off killcam
//$BC2Conn->adminVarSetKillCam(false);

// turn off friendly fire
//$BC2Conn->adminVarSetFriendlyFire(false);

// kills the player and moves him to the opponent team
//$BC2Conn->adminMovePlayerSwitchTeam("JLNNN", true);

// logout
$BC2Conn->logout();
?>
- JLNNN

Last edited by JLNNN; 01-16-2011 at 06:59 AM. Reason: Update v1.06 RC2
Reply With Quote
  #2  
Old 03-29-2010, 10:29 AM
Phogue Phogue is offline
Member
 
Join Date: Mar 2010
Posts: 30
Rep Power: 0
Phogue is on a distinguished road
Love ya work and love your sharing

In the spirit of that, if you wanted to add team names to the mix feel free to incorporate this list. I've just ripped it out of my configs but 5 minutes copy+pasting should do the trick =)

global.conquest.us = U.S Army
global.conquest.ru = Russian Army
global.rush.defenders = Defenders
global.rush.attackers = Attackers
global.Squad0 = Alpha
global.Squad1 = Bravo (etc..)
us.png = United States flag
ru.png = Russian flag

While it looks like it follows a fairly steady pattern the US/RU flags are swapped for
port valdez (levels/mp_012gr). Possibly more maps are like that but that's the only one I noticed so far.

[MapFileName] [TeamID] [TeamName] [ImageFlag]
Quote:
procon.protected.teamnames.add "levels/mp_001" 0 "global.conquest.neutral" ""
procon.protected.teamnames.add "levels/mp_001" 1 "global.conquest.us" "us.png"
procon.protected.teamnames.add "levels/mp_001" 2 "global.conquest.ru" "ru.png"
procon.protected.teamnames.add "levels/mp_003" 0 "global.conquest.neutral" ""
procon.protected.teamnames.add "levels/mp_003" 1 "global.conquest.us" "us.png"
procon.protected.teamnames.add "levels/mp_003" 2 "global.conquest.ru" "ru.png"
procon.protected.teamnames.add "levels/mp_005" 0 "global.conquest.neutral" ""
procon.protected.teamnames.add "levels/mp_005" 1 "global.conquest.us" "us.png"
procon.protected.teamnames.add "levels/mp_005" 2 "global.conquest.ru" "ru.png"
procon.protected.teamnames.add "levels/mp_007" 0 "global.conquest.neutral" ""
procon.protected.teamnames.add "levels/mp_007" 1 "global.conquest.us" "us.png"
procon.protected.teamnames.add "levels/mp_007" 2 "global.conquest.ru" "ru.png"
procon.protected.teamnames.add "levels/mp_009cq" 0 "global.conquest.neutral" ""
procon.protected.teamnames.add "levels/mp_009cq" 1 "global.conquest.us" "us.png"
procon.protected.teamnames.add "levels/mp_009cq" 2 "global.conquest.ru" "ru.png"
procon.protected.teamnames.add "levels/mp_002" 0 "global.rush.neutral" ""
procon.protected.teamnames.add "levels/mp_002" 1 "global.rush.attackers" "us.png"
procon.protected.teamnames.add "levels/mp_002" 2 "global.rush.defenders" "ru.png"
procon.protected.teamnames.add "levels/mp_004" 0 "global.rush.neutral" ""
procon.protected.teamnames.add "levels/mp_004" 1 "global.rush.attackers" "us.png"
procon.protected.teamnames.add "levels/mp_004" 2 "global.rush.defenders" "ru.png"
procon.protected.teamnames.add "levels/mp_006" 0 "global.rush.neutral" ""
procon.protected.teamnames.add "levels/mp_006" 1 "global.rush.attackers" "us.png"
procon.protected.teamnames.add "levels/mp_006" 2 "global.rush.defenders" "ru.png"
procon.protected.teamnames.add "levels/mp_008" 0 "global.rush.neutral" ""
procon.protected.teamnames.add "levels/mp_008" 1 "global.rush.defenders" "us.png"
procon.protected.teamnames.add "levels/mp_008" 2 "global.rush.attackers" "ru.png"
procon.protected.teamnames.add "levels/mp_012gr" 0 "global.rush.neutral" ""
procon.protected.teamnames.add "levels/mp_012gr" 1 "global.rush.attackers" "ru.png"
procon.protected.teamnames.add "levels/mp_012gr" 2 "global.rush.defenders" "us.png"
procon.protected.teamnames.add "levels/mp_002sr" 0 "global.rush.neutral" ""
procon.protected.teamnames.add "levels/mp_002sr" 1 "global.conquest.us" "us.png"
procon.protected.teamnames.add "levels/mp_002sr" 2 "global.conquest.ru" "ru.png"
procon.protected.teamnames.add "levels/mp_005sr" 0 "global.rush.neutral" ""
procon.protected.teamnames.add "levels/mp_005sr" 1 "global.conquest.us" "us.png"
procon.protected.teamnames.add "levels/mp_005sr" 2 "global.conquest.ru" "ru.png"
procon.protected.teamnames.add "levels/mp_001sr" 0 "global.rush.neutral" ""
procon.protected.teamnames.add "levels/mp_001sr" 1 "global.conquest.us" "us.png"
procon.protected.teamnames.add "levels/mp_001sr" 2 "global.conquest.ru" "ru.png"
procon.protected.teamnames.add "levels/mp_012sr" 0 "global.rush.neutral" ""
procon.protected.teamnames.add "levels/mp_012sr" 1 "global.conquest.us" "us.png"
procon.protected.teamnames.add "levels/mp_012sr" 2 "global.conquest.ru" "ru.png"
procon.protected.teamnames.add "levels/mp_009sdm" 0 "global.rush.neutral" ""
procon.protected.teamnames.add "levels/mp_009sdm" 1 "global.Squad0" "us.png"
procon.protected.teamnames.add "levels/mp_009sdm" 2 "global.Squad1" "ru.png"
procon.protected.teamnames.add "levels/mp_009sdm" 3 "global.Squad2" "us.png"
procon.protected.teamnames.add "levels/mp_009sdm" 4 "global.Squad3" "ru.png"
procon.protected.teamnames.add "levels/mp_007sdm" 0 "global.rush.neutral" ""
procon.protected.teamnames.add "levels/mp_007sdm" 1 "global.Squad0" "us.png"
procon.protected.teamnames.add "levels/mp_007sdm" 2 "global.Squad1" "ru.png"
procon.protected.teamnames.add "levels/mp_007sdm" 3 "global.Squad2" "us.png"
procon.protected.teamnames.add "levels/mp_007sdm" 4 "global.Squad3" "ru.png"
procon.protected.teamnames.add "levels/mp_006sdm" 0 "global.rush.neutral" ""
procon.protected.teamnames.add "levels/mp_006sdm" 1 "global.Squad0" "us.png"
procon.protected.teamnames.add "levels/mp_006sdm" 2 "global.Squad1" "ru.png"
procon.protected.teamnames.add "levels/mp_006sdm" 3 "global.Squad2" "us.png"
procon.protected.teamnames.add "levels/mp_006sdm" 4 "global.Squad3" "ru.png"
procon.protected.teamnames.add "levels/mp_004sdm" 0 "global.rush.neutral" ""
procon.protected.teamnames.add "levels/mp_004sdm" 1 "global.Squad0" "us.png"
procon.protected.teamnames.add "levels/mp_004sdm" 2 "global.Squad1" "ru.png"
procon.protected.teamnames.add "levels/mp_004sdm" 3 "global.Squad2" "us.png"
procon.protected.teamnames.add "levels/mp_004sdm" 4 "global.Squad3" "ru.png"
Reply With Quote
  #3  
Old 03-30-2010, 06:30 AM
JLNNN's Avatar
JLNNN JLNNN is offline
Member
 
Join Date: Mar 2010
Location: Germany
Age: 29
Posts: 39
Rep Power: 0
JLNNN is on a distinguished road
Updated to v1.2b. (Phogue, I'll take your suggestions into the next version - thanks for that!)
Reply With Quote
  #4  
Old 03-31-2010, 04:26 PM
JLNNN's Avatar
JLNNN JLNNN is offline
Member
 
Join Date: Mar 2010
Location: Germany
Age: 29
Posts: 39
Rep Power: 0
JLNNN is on a distinguished road
Updated to v1.3b.
Reply With Quote
  #5  
Old 04-01-2010, 08:32 PM
Xaiin Xaiin is offline
Junior Member
 
Join Date: Apr 2010
Posts: 2
Rep Power: 0
Xaiin is on a distinguished road
Hi guys,

Very nice work Really appreciate that you shared this with the community.

I'd be really interested in seeing if you can include some sort of event handler, something that can capture incoming captures, kills, deaths, chat etc.

I'll keep looking around to see if I can provide any additional information.

Looking forward to your next release



-Xaiin
Reply With Quote
  #6  
Old 04-02-2010, 11:31 AM
JLNNN's Avatar
JLNNN JLNNN is offline
Member
 
Join Date: Mar 2010
Location: Germany
Age: 29
Posts: 39
Rep Power: 0
JLNNN is on a distinguished road
Updated to v1.4b.
Reply With Quote
  #7  
Old 04-02-2010, 09:30 PM
FireDawg911 FireDawg911 is offline
Senior Member
 
Join Date: Dec 2008
Location: Lexington, KY
Posts: 375
Rep Power: 9
FireDawg911 is on a distinguished road
is there documentation on installing this and use instructions or am i missing something?
Reply With Quote
  #8  
Old 04-03-2010, 06:46 AM
JLNNN's Avatar
JLNNN JLNNN is offline
Member
 
Join Date: Mar 2010
Location: Germany
Age: 29
Posts: 39
Rep Power: 0
JLNNN is on a distinguished road
There are no install instructions yet, but maybe I'll put some on the project's page in the following time..

To use (and understand) the BC2Conn class you need basic PHP skills I think.. Just download the zip archive, extract the included files, edit the example.php (you need to change the example ip and RCON port / password to your gameserver ones) and upload them on your webspace. Then you can call www.example.com/example.php and you'll see some basic data of your gameserver.

To add new functions, just take a look at the API - choose what you want to do and insert the function into your php file with the specific parameters if there are any.

Hope that'll do it.

- JLNNN
__________________
BC2Conn - PHP class for communicating with a Battlefield Bad Company 2 gameserver
Reply With Quote
  #9  
Old 04-03-2010, 10:35 AM
Bakes Bakes is offline
Junior Member
 
Join Date: Jun 2009
Posts: 14
Rep Power: 0
Bakes is on a distinguished road
Is this released under any particular license ie the GNU GPL?
Reply With Quote
  #10  
Old 04-03-2010, 10:48 AM
JLNNN's Avatar
JLNNN JLNNN is offline
Member
 
Join Date: Mar 2010
Location: Germany
Age: 29
Posts: 39
Rep Power: 0
JLNNN is on a distinguished road
No, there is no license - use it in the ways you want to (please let the comments in class intact). But if you earn money with it, it would be nice if you donate me some cents And please set a link on your page to get it more public.

- JLNNN
__________________
BC2Conn - PHP class for communicating with a Battlefield Bad Company 2 gameserver
Reply With Quote
  #11  
Old 04-03-2010, 04:17 PM
DVDFmeanfocker DVDFmeanfocker is offline
Junior Member
 
Join Date: Mar 2010
Posts: 20
Rep Power: 0
DVDFmeanfocker is on a distinguished road
I've been writing my own php script and had success with it being able to list players, ban kick etc etc but couldn't work out what I need to send in the header for white spaces when sending chat? Seeing this I thought I'd bin my script and go with this but it won't work. When running the simple example script (with my gameserver password, port and IP) I get: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/sites/dvdf-clan.co.uk/public_html/rcon/BC2Conn.php on line 18 The webserver is php 5
Reply With Quote
  #12  
Old 04-03-2010, 04:25 PM
JLNNN's Avatar
JLNNN JLNNN is offline
Member
 
Join Date: Mar 2010
Location: Germany
Age: 29
Posts: 39
Rep Power: 0
JLNNN is on a distinguished road
Please show me line 17-19 of your BC2Conn.php file.. I think you edited it - that will be the problem
__________________
BC2Conn - PHP class for communicating with a Battlefield Bad Company 2 gameserver
Reply With Quote
  #13  
Old 04-03-2010, 05:48 PM
DVDFmeanfocker DVDFmeanfocker is offline
Junior Member
 
Join Date: Mar 2010
Posts: 20
Rep Power: 0
DVDFmeanfocker is on a distinguished road
Here's the first part of the code, I haven't edited anything:

PHP Code:
<?php
/**
 * if you've got any improvements or if you like this class,
 * send me a little message by mail. i can read english / german ;)
 *
 * <b>support:</b><br />
 * http://www.bfbc2admin.com/phpbb/viewtopic.php?f=9&t=220&start=0 <b>(english)</b><br />
 * http://www.fpsadmin.com/forum/showthread.php?t=20045 <b>(english)</b><br />
 * http://www.bf-games.net/forum/index.php?showtopic=45896 <b>(german)</b><br />
 * <br />
 * <b>API:</b><br />
 * http://www.jlnx.de/BC2Conn/API/
 *
 * @author JLNNN <JLN@hush.ai>
 * @version 1.4b
 */
class BC2Conn {
    private 
$_serverIP null;
    private 
$_serverRconQueryPort null;
    private 
$_clientSequenceNr 0;
    private 
$_sock null;
    private 
$_connection false;

    
/**
     * @param String
     * @param Integer
     *
     * @return boolean true = connection successful, false = connection failed
     */
    
function __construct($serverIP$serverRconQueryPort) {
        if (
$this->_serverIP == null) {
            
$this->_serverIP $serverIP;
            
$this->_serverRconQueryPort $serverRconQueryPort;
            
$this->_connection $this->_openConnection();
        }

        return 
$this->_connection;
    }
It seems it doesn't like the private variables???? If I remove them it then doesn't like private functions??? weird?
Reply With Quote
  #14  
Old 04-03-2010, 05:54 PM
JLNNN's Avatar
JLNNN JLNNN is offline
Member
 
Join Date: Mar 2010
Location: Germany
Age: 29
Posts: 39
Rep Power: 0
JLNNN is on a distinguished road
Well okay, that's really strange.. I don't see any problems and the BC2Conn class works fine, trust me.. Maybe you should try another webspace? And what if you just edit the

$BC2Conn = new BC2Conn("127.0.0.1", 48888);

line in the example.php and call it via www.example.com/example.php? Does this work?
__________________
BC2Conn - PHP class for communicating with a Battlefield Bad Company 2 gameserver
Reply With Quote
  #15  
Old 04-04-2010, 05:23 AM
JLNNN's Avatar
JLNNN JLNNN is offline
Member
 
Join Date: Mar 2010
Location: Germany
Age: 29
Posts: 39
Rep Power: 0
JLNNN is on a distinguished road
Updated to v1.41b.
__________________
BC2Conn - PHP class for communicating with a Battlefield Bad Company 2 gameserver
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:44 PM.


Powered by: vBulletin Copyright ©2000, Jelsoft Enterprises Ltd.