<?php
   /*
    * phpUA
    * United Admins © 2004
    * http://www.unitedadmins.com/
    *
    * This program is free software; you can redistribute it and/or
    * modify it under the terms of the GNU General Public License
    * as published by the Free Software Foundation; either version 2
    * of the License, or (at your option) any later version.
    *
    * This program is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    * GNU General Public License for more details.
    *
    * You should have received a copy of the GNU General Public License
    * along with this program; if not, write to the Free Software
    * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    *
    */
    
    // $Id: plugin_q3.inc,v 1.4 2004/02/27 13:14:09 mad-x Exp $
    // Created by Hendri Leppkes (punisher@unitedadmins.com)
    
    pluginRegisterGame("Q3", "Quake III Arena", "plugin_q3", basename(__FILE__));
    addCredits($phpUA["LANGUAGE"]["Plugin"] . ": Quake III Arena", "Hendrik Leppkes");
    
    class plugin_q3 {
        var $_id;
        var $_ip;
        var $_port;
        var $_info;
        
        function plugin_q3($id, $ip, $port)
        {
            $this->_id = $id;
            $this->_ip = $ip;
            $this->_port = $port;
        }
        
        function isOnline()
        {
            require_once(ABSOLUTEPATH . "plugins/shared/plugin_q3_query.inc");
            
            $server_query = new plugin_q3_query($this->_ip, $this->_port);
            if (!$this->info = $server_query->getinfo()) return false;
            if (empty($this->info["hostname"])) return false;
            $this->info["hostname"] = $server_query->stripColorCodes($this->info["hostname"]);
            return true;
        }
        
        function getInfo()
        {
            global $phpUA;
            require_once(ABSOLUTEPATH . "plugins/shared/plugin_q3_query.inc");
            
            if (empty($this->info["game"])) $this->info["game"] = "baseq3";
            
            return array("name"=>$this->info["hostname"],
                         "desc"=>$this->info["game"] . ": " . $this->info["clients"] . "/" . $this->info["sv_maxclients"] . " " . $phpUA["LANGUAGE"]["on"] . " " . $this->info["mapname"]);
        }
    }
?>
