Wow that class is exactly what I needed! That's going to allow me to do sooo much...wow
Ok, I'm having a little trouble with one of the functions. The ServerMaps function is supposed to return a multidimensional array with a list of the maps on the server right? Well, it returns a totally empty variable! I don't understand why...
Here is the ServerMaps function straight from the class
PHP Code:
//Get all maps in all directories
function ServerMaps($pagenumber = 0)
{
//If there is no open connection return false
if(!$this->connected)
return $this->connected;
//Get list of maps
$maps = $this->RconCommand("maps *", $pagenumber);
//If there is no open connection return false
//If there is bad rcon password return "Bad rcon_password."
if(!$maps || trim($maps) == "Bad rcon_password.")
return $maps;
//Split Maplist in rows
$line = explode("\n", $maps);
$count = sizeof($line) - 4;
//format maps
for($i = 0; $i <= $count; $i++)
{
$text = $line[$i];
//at directory output sorted map list
if(strstr($text, "Dir:"))
{
//reset counter
$mapcount = 0;
//parse directory name
$directory = strstr($text, " ");
} //if(strstr($text, "Dir:"))
else if(strstr($text, "(fs)"))
{
//parse mappath
$mappath = strstr($text, " ");
//parse mapname
//if no "/" is included in the "maps * " result
if(!($tmpmap = strrchr($mappath, "/")))
$tmpmap = $mappath;
//parse mapname without suffix (.bsp)
$result[$directory][$i] = substr($tmpmap, 1, strpos($tmpmap, ".") - 1);
} //else if(strstr($text, "(fs)"))
} //for($i = 1; $i <= $count; $i++)
//return formatted result
return $result;
} //function ServerMaps()
The way I am calling the function is this
PHP Code:
$server = new Rcon(); // Initiate class
.//Connection script
.
.
.
$maps = $server->ServerMaps();
$check = is_array($maps) // Returns False
$maps returns from the ServerMaps function totally null, and I can't figure out why. However I am able to pull server information and send rcon commands, so the connection is definately there