View Single Post
Old 10-25-2004, 03:20 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,542
sde is on a distinguished road
http://ocsclan.com/rcon/

i just modified the logic of that function a bit .. now in the loop, if it finds a .bsp file, it adds it to the map array.

most of the for loop is commented out now .. this should work:
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++)
    {
      if(
strstr($line[$i],".bsp"))
        
$result[]=str_replace(".bsp","",$line[$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() 
__________________
Mike
sde is offline   Reply With Quote