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, 09: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 07:59 AM. Reason: Update v1.06 RC2
Reply With Quote
  #2  
Old 03-29-2010, 11: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, 07: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, 05: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, 09: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, 12:31 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.4b.
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 11:57 PM.


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