1. GSManager
    1. Funktionen
    2. Unterstützte Spiele
    3. Neuigkeiten
    4. Statistiken
    5. Serverliste
  2. Lexikon
  3. Filebase
  4. Entwicklung
  5. Forum
    1. Dashboard
    2. Unerledigte Themen
  6. Web-Interface
  7. Artikel
  8. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Dateien
  • Forum
  • Lexikon
  • Erweiterte Suche
  1. GSManager
  2. Mitglieder
  3. Mirko911

Beiträge von Mirko911

Das Projekt GSManager (vormals ManuAdminMod) wurde am 01.01.2020 eingestellt - diese Internetpräsenz bleibt verfügbar, die Software wird aber nicht länger gepflegt. Vielen Dank für eure Unterstützung in den mehr als zehn vergangenen Jahren!
  • Random Mapcycle

    • Mirko911
    • 20. Mai 2017 um 14:15

    Hi,

    sry for the long waiting time.

    Can you try to replace the content of the plugins/randommapcycle/randommapcycle.php file with this one:

    PHP
    <?php
        /**
         * GSManager
         *
         * This is a mighty and platform independent software for administrating game servers of various kinds.
         * If you need help with installing or using this software, please visit our website at: www.gsmanager.de
         * If you have licensing enquiries e.g. related to commercial use, please contact us at: sales@gsmanager.de
         *
         * @copyright Greenfield Concept UG (haftungsbeschränkt)
         * @license GSManager EULA <https://www.gsmanager.de/eula.php>
         * @version 1.2.1
        **/
        namespace GSM\Plugins\Randommapcycle;
        use GSM\Daemon\Core\Utils;
        /**
         * randommapcycle Class
         *
         * The randommapcycle plugin
         *
         */
        class RandomMapCycle extends Utils {
            /**
             * Maps
             *
             * @var array $maps Maps
             */
            private $maps = array();
            /**
             * lastmaps
             *
             * @var array $lastmaps the last maps
             */
            private $lastmaps = array();
            /**
             * Chosen
             *
             * @var array $chosen
             */
            private $chosen = array();
            /**
             * Start
             *
             * @var int $start
             */
            private $start = 0;
            /**
             * last announce
             *
             * @var int $lastannounce
             */
            private $lastAnnounce = 0;
            /**
             * vote in progress
             *
             * @var boolean $voteinprogress
             */
            private $voteinprogress = false;
            /**
             * Skips
             *
             * @var array $skips
             */
            private $skips = array();
            /**
             * Gametypes
             *
             * @var array $gametypes
             */
            private $gametypes = array();
            /**
             * Voters
             *
             * @var array $voters
             */
            private $voters = array();
            /**
             * Votes
             *
             * @var array $votes
             */
            private $votes = array();
            private $job_id;
            /**
             * Inits the plugin
             *
             * This function initiates the plugin. This means that it register commands
             * default values, and events. It's important that every plugin has this function
             * Otherwise the plugin exists but can't be used
             */
            public function initPlugin() {
                parent::initPlugin();
                $this->config->setDefault('randommapcycle', 'enabled', true);
                $this->config->setDefault('randommapcycle', 'type', 2);
                $this->config->setDefault('randommapcycle', 'mapcount', 3);
                $this->config->setDefault('randommapcycle', 'duration', 300);
                $this->config->setDefault('randommapcycle', 'interval', 90);
                $this->config->setDefault('randommapcycle', 'maps', array('*'));
                $this->config->setDefault('randommapcycle', 'gametypes', array('*'));
                $this->config->setDefault('randommapcycle', 'ignorepriorgametype', true);
                $this->config->setDefault('randommapcycle', 'ignorepriormaps', 3);
                $this->config->setDefault('randommapcycle', 'skipquorum', '50%');
                $this->config->setDefault('randommapcycle', 'skipvoting', false);
            }
            /**
             * Function to enable this plugin
             */
            public function enable() {
                parent::enable();
                $this->events->register('nextMap', [$this, 'eventNextMap']);
                /* Fix if the vote command isn't enabled */
                if ($this->commands->getCommand('vote') === false) {
                    $this->commands->register('vote', false, false, $this);
                }
                $this->commands->registerSubCommand('vote', 'choice', '~choice \d+~i', [$this, 'commandVmap']);
                $this->commands->registerSubCommand('vote', 'skip', false, [$this, 'commandSkip']);
                $this->readConfig();
                list($this->lastmaps[]) = $this->mod->getLastMaps(1);
                $this->eventNextMap();
            }
            /**
             * Function to disable this plugin
             */
            public function disable() {
                parent::disable();
                $this->events->unregister('nextMap', [$this, 'eventNextMap']);
                $this->commands->unregisterSubCommand('vote', 'choice');
                $this->commands->unregisterSubCommand('vote', 'skip');
            }
            /**
             * executes the readConfig event.
             */
            private function readConfig() {
                $this->maps = array();
                $allowed_maps = $this->config->get('randommapcycle', 'maps');
                if (is_array($allowed_maps) && isset($allowed_maps[0]) && $allowed_maps[0] == '*') {
                    $this->maps = $this->mod->getMaps();
                } elseif (is_array($allowed_maps)) {
                    $this->maps = $allowed_maps;
                }
                $allowed_gametypes = $this->config->get('randommapcycle', 'gametypes');
                if (is_array($allowed_gametypes) && isset($allowed_gametypes[0]) && $allowed_gametypes[0] == '*') {
                    $this->gametypes = $this->mod->getGametypes();
                } elseif (is_array($allowed_gametypes)) {
                    $this->gametypes = $allowed_gametypes;
                }
            }
            /**
             * executes the nextMap event.
             */
            public function eventNextMap() {
                $this->readConfig();
                $lastmaps = $this->mod->getLastMaps(2);
                if ($lastmaps[1] == $lastmaps[0]) {
                    return;
                }
                $this->lastmaps[] = $lastmaps[0];
                $this->voteinprogress = false;
                $last_map_count = count($this->lastmaps);
                /** Shift to old entrys */
                while ($last_map_count > $this->config->get('randommapcycle', 'ignorepriormaps')) {
                    array_shift($this->lastmaps);
                }
                $this->lastmaps = array_merge($this->lastmaps);
                if ($this->config->get('randommapcycle', 'type') == 2) {
                    $this->logging->debug("[Random MapCycle] Random map set.");
                    $this->jobs->addSingleJob(20, array($this, "setRandomMap"));
                }
                if ($this->config->get('randommapcycle', 'type') == 1) {
                    $this->jobs->addSingleJob(20, array($this, "startVote"));
                }
            }
            /**
             * announce if the vote is possible to skip.
             */
            public function setRandomMap() {
                $this->readConfig();
                $this->chooseMap(1);
                if (empty($this->chosen)) {
                    return false;
                }
                $this->rcon->rconSetNextMap($this->chosen[0]['map'], $this->chosen[0]['gametype'], false);
                $this->skips = array();
                if ($this->config->get('randommapcycle', 'skipvoting')) {
                    $this->announceSkipMessage();
                }
            }
            /**
             * the message on the server for the skip vote.
             */
            public function announceSkipMessage() {
                $this->rcon->rconSay($this->language->get('randommapcycle.voteforskip', array('<MAP>', '<GAMETYPE>'), array($this->mod->getLongMapName($this->chosen[0]['map']), $this->mod->getLongGametype($this->chosen[0]['gametype']))));
                $this->job_id = $this->jobs->addSingleJob($this->config->get('randommapcycle', 'interval'), array($this, 'announceSkipMessage'));
            }
            /**
             * execztes the command skip.
             *
             * @param   string      $guid       Guid of executing player
             * @param   string[]    $parameters The chatline splitted by " " without !command
             */
            public function commandSkip($guid, $parameters) {
                if ($this->config->get('randommapcycle', 'type') != 2 || !$this->config->get('randommapcycle', 'skipvoting')) {
                    return;
                }
                if (in_array($guid, $this->skips)) {
                    $this->players[$guid]->say($this->language->get('randommapcycle.alreadyvoted'));
                } else {
                    $this->skips[] = $guid;
                    if (substr(trim($this->config->get('randommapcycle', 'skipquorum')), -1) == '%') {
                        $needed = round(((int) $this->config->get('randommapcycle', 'skipquorum')) / 100 * count($this->players));
                    } else {
                        $needed = (int) $this->config->get('randommapcycle', 'skipquorum');
                    }
                    $skippers = count($this->skips);
                    $search = array('<SKIPPERS>', '<NEEDED>', '<MAP>', '<GAMETYPE>');
                    $replace = array($skippers, $needed, $this->mod->getLongMapName($this->chosen[0]['map']), $this->mod->getLongGametype($this->chosen[0]['gametype']));
                    $say = $this->language->get('randommapcycle.votedskip', $search, $replace);
                    $this->rcon->rconSay($say);
                    if ($skippers >= $needed) {
                        $this->jobs->deleteJob($this->job_id);
                        $this->setRandomMap();
                    }
                }
            }
            /**
             * choose a map
             *
             * @param int $count
             */
            private function chooseMap($count) {
                $maps = $this->maps;
                $gametypes = $this->gametypes;
                foreach ($maps as $key => $value) {
                    if (in_array($value, $this->lastmaps)) {
                        unset($maps[$key]);
                    }
                }
                if ($this->config->get('randommapcycle', 'ignorepriorgametype')) {
                    $current = $this->mod->getCurrentGametype();
                    foreach ($gametypes as $key => $value) {
                        if ($value == $current) {
                            unset($gametypes[$key]);
                        }
                    }
                }
                $gametypes = array_merge($gametypes);
                if (count($gametypes) == 0) {
                    $gametypes[0] = $this->mod->getCurrentGametype();
                }
                if (count($maps) < $count) {
                    /* @todo logmarker */
                    $this->logging->warning("[Random MapCycle] Couldn't choose a random map because count(maps) < $count");
                    return false;
                }
                $this->chosen = array();
                for ($i = 1; $i <= $count; $i++) {
                    $maps = array_merge($maps);
                    $rand = rand(0, count($maps) - 1);
                    if ($this->mod->getEngine() == 'frostbite3') {
                        // $this->rcon->getMaps()->clear();
                        $map_gametypes = $this->rcon->getMaps()->getAllowedGametypesOnMap($maps[$rand]);
                        foreach ($gametypes as $key => $value) {
                            if (!in_array($value, $map_gametypes)) {
                                unset($gametypes[$key]);
                            }
                        }
                        $gametypes = array_merge($gametypes);
                    }
                    $rand2 = rand(0, count($gametypes) - 1);
                    $this->chosen[] = array('map' => $maps[$rand], 'gametype' => $gametypes[$rand2]);
                    unset($maps[$rand]);
                }
                return true;
            }
            /**
             * Ends a Vote
             */
            public function endVote() {
                $this->voteinprogress = false;
                arsort($this->votes);
                reset($this->votes);
                $won = key($this->votes);
                $this->rcon->rconSay($this->language->get('randommapcycle.wonvote', array('<MAP>', '<GAMETYPE>'), array($this->mod->getLongMapName($this->chosen[$won]['map']), $this->mod->getLongGametype($this->chosen[$won]['gametype']))));
                $this->rcon->rconSetNextMap($this->chosen[$won]['map'], $this->chosen[$won]['gametype'], false);
                $this->jobs->deleteJob($this->job_id);
            }
            /**
             * Starts a Vote
             */
            public function startVote() {
                $this->chooseMap($this->config->get('randommapcycle', 'mapcount'));
                $this->start = time();
                $this->voteinprogress = true;
                $this->votes = array_fill(0, $this->config->get('randommapcycle', 'mapcount'), 0);
                $this->voters = array();
                $this->announceVote();
                $this->jobs->addSingleJob($this->config->get('randommapcycle', 'duration'), array($this, "endVote"));
            }
            /**
             * Announces a Vote
             */
            public function announceVote() {
                $mapstr = array();
                foreach ($this->chosen as $id => $map) {
                    $mapstr[] = $this->language->get('randommapcycle.list', array('<ID>', '<MAP>', '<GAMETYPE>'), array($id + 1, $this->mod->getLongMapName($map['map']), $this->mod->getLongGametype($map['gametype'])));
                }
                $mapstr = implode("\n", $mapstr);
                $this->rcon->rconSay($this->language->get('randommapcycle.voteformap') . "\n" . $mapstr);
                $this->job_id = $this->jobs->addSingleJob($this->config->get('randommapcycle', 'interval'), array($this, "announceVote"));
            }
            /**
             * executes the command vmap
             *
             * Example: !vmap 1-3
             *
             * @param   string      $guid       Guid of executing player
             * @param   string[]    $parameters The chatline splitted by " " without !command
             */
            public function commandVmap($guid, $parameters) {
                if ($this->config->get('randommapcycle', 'type') != 1) {
                    return;
                }
                if (!$this->voteinprogress) {
                    return;
                }
                //-1 because we start with 1 but count array with 0
                $map = $parameters[0] - 1;
                if (!array_key_exists($map, $this->chosen)) {
                    return;
                }
                if (in_array($guid, $this->voters)) {
                    return;
                }
                $this->voters[] = $guid;
                $this->votes[$map] ++;
                $str = $this->language->get('randommapcycle.voted', array('<MAP>', '<GAMETYPE>'), array($this->mod->getLongMapName($this->chosen[$map]['map']), $this->mod->getLongGametype($this->chosen[$map]['gametype'])));
                $this->players[$guid]->say($str);
            }
        }
    Alles anzeigen
  • Einen weiteren Admin zufügen

    • Mirko911
    • 29. April 2017 um 13:15

    versuchs mal mit

    !group set <GRUPPENNAME> <SPIELERNAME>

    mit !group list werden dir die Gruppen angezeigt.

    Ich vermute mal dein Fehler lag darin, dass du "admin" und nicht "admins" genommen hast.

    Standardmäßig sind bei uns die Gruppennamen Plural (ops, admins, mods)

  • Problem with weaponrestriction plugin

    • Mirko911
    • 22. April 2017 um 16:26

    it seems that the weapon restrictions for CoD5 are buggy. I'll try to fix this ;)

  • Censor Cirillic

    • Mirko911
    • 26. März 2017 um 15:06

    can you try to replace the daemon/libraries/database/database.php file with

    PHP: daemon/libraries/database/database.php
    <?php
    /**
     * GSManager
     *
     * This is a mighty and platform independent software for administrating game servers of various kinds.
     * If you need help with installing or using this software, please visit our website at: www.gsmanager.de
     * If you have licensing enquiries e.g. related to commercial use, please contact us at: sales@gsmanager.de
     *
     * @copyright Greenfield Concept UG (haftungsbeschränkt)
     * @license GSManager EULA <https://www.gsmanager.de/eula.php>
     * @version 1.2.1
    **/
    
    namespace GSM\Daemon\Libraries\Database;
    
    use \PDO;
    use GSM\Daemon\Libraries\Logging\LogLevel;
    
    /**
     * Database Class
     *
     * This class is a powerfull class to handle your database connection
     * through PDO as database driver it#s possible to use nearly every database
     * This class also supports transactions with rollbacks
     *
     * @author Mirko911 <mirko911@gsmanager.de>
     */
    class Database {
        /**
         * Database handler
         * @var PDO
         */
        protected $dbh;
        /**
         * Value of the last inserted id
         *
         * @var int
         */
        protected $last_inserted_id;
        /**
         * How to order the get sql query
         *
         * @var string
         */
        protected $order;
        /**
         * How to limit the get sql query
         * @var string
         */
        protected $limit;
        /**
         *
         * PDO Statement
         *
         * @var PDOStatement
         */
        protected $sth;
        /**
         * The database prefix
         *
         * For example gsm_
         *
         * @var string
         */
        protected $prefix;
        /**
         * Fetch type for database
         * @var type
         */
        protected $fetch_type;
        /**
         * Saves the parameters for PDO
         *
         * @var array
         */
        protected $options = array(
            PDO::ATTR_PERSISTENT => true,
            PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ,
            PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
        );
    
        /**
         * Set Parameters for PDO
         *
         * @link http://is1.php.net/manual/en/pdo.setattribute.php List of Paramters
         *
         * @param array $options Key => $value where both are PDO Constatns
         */
        public function setParameters($options) {
            foreach ($options as $key => $value) {
                $this->options[$key] = $value;
            }
        }
    
        /**
         * Set Prefix for Tables
         *
         * Every Table gets this pfx | except you use the query/exec function
         *
         * @param string $prefix
         */
        public function setPrefix($prefix) {
            $this->prefix = $prefix;
        }
    
        /**
         * Sets the fetch type for 1 query
         *
         * @see http://www.php.net/manual/de/pdostatement.fetch.php
         * @param int $type Pdo fetch type
         */
        public function setFetchType($type) {
            $this->fetch_type = $type;
        }
    
        /**
         * Returns the Prefix
         *
         * @return string
         */
        public function getPrefix() {
            return $this->prefix;
        }
    
        /**
         * Constrcutor function
         *
         * @link http://www.php.net/manual/de/pdo.drivers.php List of drivers you can use
         * @param   string    $dsn      Data Source Name
         * @param   string    $user     Username [optional]
         * @param   string    $password Password [optional]
         */
        public function __construct($dsn, $user = '', $password = '') {
            $this->connect($dsn, $user, $password);
        }
    
        /**
         * Desturctor
         */
        public function __destruct() {
            $this->dbh = null;
        }
    
        /**
         * Returns a string if object is printed
         *
         * Notice: all plugins which where moved to core needs a __tostring function
         * to get it working with the permissions system. Therefore the return of __tostring must me the
         * namespace like deamon, punishment, permissions ...
         *
         * @see http://php.net/manual/en/language.oop5.magic.php#object.tostring
         * @return string
         */
        public function __toString() {
            return 'database';
        }
    
        /**
         * Connects to Database
         *
         * @param string $dsn Data Source Name
         * @param string $user Username if needed, otherwise it's an empty string
         * @param string $password Password if needed, otherwise it's an empty string
         */
        public function connect($dsn, $user, $password) {
            $this->dbh = null;
            try {
                $this->dbh = new PDO($dsn, $user, $password, $this->options);
            } catch (\PDOException $ex) {
                \GSM\Daemon\Core\Registry::getInstance()->logging->error('Database Class: ' . $ex);
            }
        }
    
        /**
         * Binds a value to a predefined parameter
         *
         * With this function it's possible to execute a query multiple
         * times with different values
         *
         * @param   string  $name   Parameter Name
         * @param   mixed   $value  Parameter Value
         * @param   int     $type   PDO Param Type [optional]
         */
        public function bindValue($name, $value, $type = NULL) {
            if (is_null($type)) {
                $type = $this->getPDOType($value);
            }
            $this->sth->bindValue($name, $value, $type);
        }
    
        /**
         * Adds a specific order for the get function
         *
         * you can use this function multiple times to set multiple orders
         *
         * @param   string      $column Name of the column
         * @param   string      $type ASC or DESC
         * @return  Database    The actual instance of the database class
         */
        public function addOrder($column, $type = '') {
            if (empty($this->order)) {
                $this->order = ' ORDER by ';
            }
            $this->order .= '`' . $column . '`' . ' ' . $type;
            return $this;
        }
    
        /**
         * Removes the order, so it can't affect the next query
         */
        public function clearOrder() {
            $this->order = '';
        }
    
        /**
         * Sets a limit for the get function
         *
         * @param   int $startvalue ID to start from
         * @param   int $count      How much results to you want to get?
         * @return  Database        The actual instance of the database class
         */
        public function setLimit($startvalue, $count) {
            $this->limit = ' LIMIT ' . $startvalue . ',' . $count;
            return $this;
        }
    
        /**
         * Removes the limit, so it can't affect the next query
         */
        public function clearLimit() {
            $this->limit = '';
        }
    
        /**
         * Gets Values from the database
         *
         * If you pass an array as input you can directly affect the where clause
         * Example:
         * $db->get("gsm_users", array("id",5)); => "SELECT * FROM gsm_users WHERE id = 5
         *
         * If you only need some fields you can pass a numeric array with the fields you want
         * Example:
         * $db->get("gsm_users", array("id",5), array("guid", "lastseen")); => "SELECT guid,lastseen FROM gsm_users WHERE id = 5
         *
         * If you pass a string as input, you'll pass a sql query
         * Example:
         * $db->get("gsm_users", "SELECT * FROM <TABLE> WHERE guid = :guid, array(":guid" => $guid));
         * For SQL Querys it's possible to use the placeholders <TABLE> for table with prefix or <PFX> for prefix
         *
         * The functions setOrder and setLimit will affect BOTH types
         *
         * @param   string          $table      Name of the table without prefix
         * @param   string|string[] $input      Key => $value array or string with query
         * @param   array           $parameters Optional Parameters for BindValue or to select columns, depends on $input
         * @return  array           SQL Result. Default Data is access able like an obj $player->guid
         */
        public function get($table, $input = array(), $parameters = array()) {
            if (is_array($input)) {
                if (!empty($parameters)) {
                    if (is_array($parameters)) {
                        $params = implode(',', $parameters);
                    } else {
                        $params = $parameters;
                    }
                    $sql = 'SELECT ' . $params . ' FROM ' . $this->prefix . $table . ' WHERE 1';
                } else {
                    $sql = 'SELECT * FROM ' . $this->prefix . $table . ' WHERE 1';
                }
                foreach ($input as $key => $value) {
                    $sql .= ' AND `' . $key . '` = :col_' . $key;
                }
                $sql = rtrim($sql, ',');
                $sql .= $this->order;
                $sql .= $this->limit;
                $this->sth = $this->dbh->prepare($sql);
                foreach ($input as $key => $value) {
                    $this->bindValue(':col_' . $key, $value);
                }
            } else if (is_string($input)) {
                $sql = str_replace(array("<PFX>", "<TABLE>"), array($this->prefix, $this->prefix . $table), $input);
                $this->sth = $this->dbh->prepare($sql);
                foreach ($parameters as $key => $value) {
                    $this->bindValue($key, $value);
                }
            }
    
            $this->sth->execute();
            $this->clearLimit();
            $this->clearOrder();
    
            if (!is_numeric($this->fetch_type)) {
                $data = $this->sth->fetchAll();
            } else {
                $data = $this->sth->fetchAll($this->fetch_type);
                $this->fetch_type = NULL;
            }
            \GSM\Daemon\Core\Registry::getInstance()->logging->debug("SQL: $sql Code: " . $this->dbh->errorCode(), LogLevel::DEBUG_DATABASE);
    
            return $data;
        }
    
        /**
         * Gets the first result from a database
         *
         * If you pass an array as input you can directly affect the where clause
         * Example:
         * $db->get("gsm_users", array("id",5)); => "SELECT * FROM gsm_users WHERE id = 5
         *
         * If you only need some fields you can pass a numeric array with the fields you want
         * Example:
         * $db->get("gsm_users", array("id",5), array("guid", "lastseen")); => "SELECT guid,lastseen FROM gsm_users WHERE id = 5
         *
         * If you pass a string as input, you'll pass a sql query
         * Example:
         * $db->get("gsm_users", "SELECT * FROM <TABLE> WHERE guid = :guid, array(":guid" => $guid));
         * For SQL Query it's possible to use the placeholders <TABLE> for table with prefix or <PFX> for prefix
         *
         * The functions setOrder and setLimit will affect BOTH types
         *
         * @param   string          $table      Name of the table without prefix
         * @param   string|string[] $input      Key => $value array or string with query
         * @param   array           $parameters Optional Parameters for BindValue or to select columns, depends on $input
         * @return  array           SQL Result. Default Data is access able like an obj $player->guid
         */
        public function row($table, $input = array(), $parameters = array()) {
            $this->setLimit(0, 1);
            $result = $this->get($table, $input, $parameters);
            if (is_array($result) && !empty($result)) {
                return $result[0];
            } elseif (empty($result)) {
                return false;
            } else {
                return $result;
            }
        }
    
        /**
         * Upddates a database entry
         *
         * @param string $table Name of the table without prefix
         * @param array $entrys Key Value Array
         * @param array $condition_or_statement Array with 3 Entrys 1)Column Name 2) Condition 3) Value Example | or SQL Statement
         * @return int affected rows
         */
        public function update($table, $entrys, $condition_or_statement) {
            $sql = 'UPDATE ' . $this->prefix . $table;
            $sql .= ' SET ';
            foreach ($entrys as $key => $value) {
                $sql .= '`' . $key . '` = :col_' . $key . ',';
            }
            $sql = rtrim($sql, ',');
            if (is_array($condition_or_statement)) {
                if (!is_int($condition_or_statement[2]) && !is_bool($condition_or_statement[2])) {
                    $condition_or_statement[2] = '"' . $condition_or_statement[2] . '"';
                }
                $sql .= ' WHERE `' . $condition_or_statement[0] . '` ' . $condition_or_statement[1] . ' ' . $condition_or_statement[2];
            } else {
                $sql .= ' WHERE ' . $condition_or_statement;
            }
    
            $this->sth = $this->dbh->prepare($sql);
            foreach ($entrys as $key => $value) {
                $this->bindValue(':col_' . $key, $value);
            }
            $this->sth->execute();
            \GSM\Daemon\Core\Registry::getInstance()->logging->debug("SQL: $sql Code: " . $this->dbh->errorCode(), LogLevel::DEBUG_DATABASE);
    
            return $this->sth->rowCount();
        }
    
        /**
         * Insert new data into the database
         *
         * @param string $table Name of the table without prefix
         * @param array $entrys $key => $value where key is the column name
         * @return boolean True if successful else false
         */
        public function insert($table, $entrys) {
            $sql = 'INSERT INTO ' . $this->prefix . $table;
            $sql .= ' (' . implode(',', array_map(function($val) { return '`' . $val . '`'; }, array_keys($entrys)));
            $sql .= ') VALUES (';
            foreach ($entrys as $key => $value) {
                $sql .= ':col_' . $key . ',';
            }
            $sql = rtrim($sql, ',');
            $sql .= ')';
            $this->sth = $this->dbh->prepare($sql);
            foreach ($entrys as $key => $value) {
                $this->bindValue(':col_' . $key, $value);
            }
            \GSM\Daemon\Core\Registry::getInstance()->logging->debug("SQL: $sql", LogLevel::DEBUG_DATABASE);
    
            if (!$this->sth->execute()) {
                return false;
            } else {
                return true;
            }
        }
    
        /**
         * Deletes an entry from Database
         *
         * @param string $table Name of the table without prefix
         * @param string $column_or_statement Name of the column | or own SQL Statement
         * @param mixed $value Value to sarch for in the overgiven column
         * @return int affected rows
         */
        public function delete($table, $column_or_statement, $value = false) {
            $sql = 'DELETE FROM ' . $this->prefix . $table;
            if ($value !== false) {
                $sql .= ' WHERE ' . '`' . $column_or_statement . '`';
                $sql .= ' = ';
                if (!is_int($value) && !is_bool($value)) {
                    $value = '"' . $value . '"';
                }
                $sql .= $value;
            } else {
                $sql .= " WHERE " . $column_or_statement;
            }
            \GSM\Daemon\Core\Registry::getInstance()->logging->debug("SQL: $sql", LogLevel::DEBUG_DATABASE);
    
            return $this->dbh->exec($sql);
        }
    
        /**
         * Returns the last inserted id or NULL
         *
         * @return int
         */
        public function getLastInsertedId() {
            return $this->dbh->lastInsertId();
        }
    
        /**
         * Direclty query the database
         *
         * @param string $sql The sql query
         *
         * @return \PDOStatement The Result
         */
        public function query($sql) {
            $sql = str_replace('<PFX>', $this->prefix, $sql);
            \GSM\Daemon\Core\Registry::getInstance()->logging->debug("SQL: $sql", LogLevel::DEBUG_DATABASE);
    
            return $this->dbh->query($sql);
        }
    
        /**
         * Executes a query
         *
         * @param string $sql The sql query
         *
         * @return int Affected Rows
         */
        public function exec($sql) {
            $sql = str_replace('<PFX>', $this->prefix, $sql);
            \GSM\Daemon\Core\Registry::getInstance()->logging->debug("SQL: $sql", LogLevel::DEBUG_DATABASE);
    
            return $this->dbh->exec($sql);
        }
    
        /**
         * Prepare SQL Statement
         * @param string $sql The sql query
         */
        public function prepare($sql) {
            $sql = str_replace('<PFX>', $this->prefix, $sql);
            \GSM\Daemon\Core\Registry::getInstance()->logging->debug("SQL: $sql", LogLevel::DEBUG_DATABASE);
    
            $this->sth = $this->dbh->prepare($sql);
        }
    
        /**
         * Executes a statement
         *
         * @return \PDOStatement The Result
         */
        public function execute() {
            return $this->sth->execute();
        }
    
        /**
         * Fetches the Data after a statement
         * @param int $mode
         * @return mixed depends on the mode
         */
        public function fetch($mode) {
            return $this->sth->fetch($mode);
        }
    
        /**
         * Start a transaction
         *
         * It's possible to execute multiple querys and commit them
         *
         * @return boolean
         */
        public function beginTransaction() {
            return $this->dbh->beginTransaction();
        }
    
        /**
         * Ends a transaction
         *
         * It's possible to execute multiple querys and commit them
         *
         * @return boolean
         */
        public function endTransaction() {
            return $this->dbh->commit();
        }
    
        /**
         * Cancel a transaction
         *
         * It's possible to execute multiple querys and commit them
         *
         * @return boolean
         */
        public function cancelTransaction() {
            return $this->dbh->rollBack();
        }
    
        /**
         * Finds the fitting PDO Typoe for a parameter
         * @param mixed $param string bool or int
         * @return int
         */
        private function getPDOType($param) {
            if (is_string($param)) {
                return PDO::PARAM_STR;
            } elseif (is_int($param)) {
                return PDO::PARAM_INT;
            } elseif (is_bool($param)) {
                return PDO::PARAM_BOOL;
            } else {
                return PDO::PARAM_STR;
            }
        }
    
        /**
         * Replaces any parameter placeholders in a query with the value of that
         * parameter. Useful for debugging. Assumes anonymous parameters from
         * $params are are in the same order as specified in $query
         *
         * @param string $query The sql query with parameter placeholders
         * @param array $params The array of substitution parameters
         * @return string The interpolated query
         */
        public function interpolateQuery($query, $params) {
            $keys = array();
    
            # build a regular expression for each parameter
            foreach ($params as $key => $value) {
                if (is_string($key)) {
                    $keys[] = '/:' . $key . '/';
                } else {
                    $keys[] = '/[?]/';
                }
            }
    
            $query = preg_replace($keys, $params, $query, 1, $count);
    
            #trigger_error('replaced '.$count.' keys');
    
            return $query;
        }
    }
    Alles anzeigen
  • Login failed

    • Mirko911
    • 16. März 2017 um 13:57

    Change your game in the gsm.cfg to cod2 cod4 or any other cod you want to manage

  • CoD 2 log configs for Gsm

    • Mirko911
    • 1. März 2017 um 10:48
    Code
    g_logsync 2
    sv_log_damage 1
    logfile 0
    g_log "games_mp.log"
  • CoD 2 1.0 disable pb_sv_guidrelax 0

    • Mirko911
    • 1. März 2017 um 10:47

    also set

    punishment.punkbuster to false

  • GSM & CoD 2

    • Mirko911
    • 28. Februar 2017 um 20:06

    as I said, here the fix.

    Please replace the following files with the new versions in this post

    JavaScript: daemon/engines/quake3/games/cod2/data/weapons.json
    {
        "extensions": {
            "american": "M2 Frag Grenade",
            "british": "MK1 Frag Grenade",
            "german": "Stilhandgranate",
            "russian": "RDG-33 Stick Grenade"
        },
        "special": {
            "none": "nothing",
            "MOD_FALLING": "Fall",
            "MOD_MELEE": "Melee",
            "MOD_EXPLOSIVE": "Explosion",
            "MOD_RIFLE_BULLET": "Bullet",
            "MOD_SUICIDE": "Selfkill"
        },
        "weapons": {
            "weapons": {
                "30cal": "Browning .30cal",
                "PPS42": "PPS42",
                "SVT40": "Tokarev SVT-40",
                "TT30": "TT 30",
                "bar": "Bar",
                "bren": "Bren LMG",
                "colt": "Colt .45",
                "enfield": "Lee-Enfield",
                "g43": "Gewehr 43",
                "greasegun": "Grease Gun",
                "kar98k": "Kar98k",
                "luger": "Luger",
                "m1carbine": "M1A1 Carabine",
                "m1garand": "M1 Garand",
                "mg42": "MG42",
                "mosin": "Mosin-Nagant",
                "mp40": "MP40",
                "mp44": "MP44",
                "ppsh": "PPSh",
                "shotgun": "M1897 Trench Gun",
                "springfield": "Springfield",
                "sten": "Sten",
                "thompson": "Thompson",
                "webley": "Webley"
            },
            "Grenades": {
                "scope": "Scoped"
            }
        }
    }
    Alles anzeigen
    PHP: daemon/engines/quake3/games/cod2/weapons.php
    <?php
    /**
     * GSManager
     *
     * This is a mighty and platform independent software for administrating game servers of various kinds.
     * If you need help with installing or using this software, please visit our website at: www.gsmanager.de
     * If you have licensing enquiries e.g. related to commercial use, please contact us at: sales@gsmanager.de
     *
     * @copyright Greenfield Concept UG (haftungsbeschränkt)
     * @license GSManager EULA <https://www.gsmanager.de/eula.php>
     * @version 1.2.1
    **/
    
    namespace GSM\Daemon\Engines\Quake3\Games\CoD2;
    
    use GSM\Daemon\Core\Registry;
    use GSM\Daemon\Libraries\Helper\Helper;
    
    /**
     * Weapon Class for Call od Duty 4
     *
     * This class contains all weapons for Call od Duty 4
     *
     * @author Master of Little <masteroflittle@gsmanager.de>
     */
    class Weapons {
        /**
         * Contains all weapons
         *
         * @var array
         */
        private $weapons;
        /**
         * Contains all extensions like silencer, red dot ...
         *
         * @var array
         */
        private $extensions;
        /**
         * Contains special stuff like suicide, death by world ...
         *
         * @var array
         */
        private $special;
        /**
         * Class for Logging
         *
         * @var \GSM\Daemon\Libraries\Logging\LogHandler
         */
        private $logging;
    
        /**
         * Constructor
         */
        public function __construct() {
            $registry = Registry::getInstance();
            $this->logging = &$registry->logging;
    
            $this->getWeapons();
        }
    
        /**
         * Defines the Weapons
         */
        private function getWeapons() {
            $json = \GSM\Daemon\Libraries\Helper\Helper::parseJson(__DIR__ . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR . "weapons.json");
            $json = \GSM\Daemon\Core\Language::replaceLanguageRecursive($json);
    
            $this->weapons = $json["weapons"];
            $this->extensions = $json["extensions"];
            $this->special = $json["special"];
        }
    
        /**
         * Returns an array with detailed information about the weapon
         *
         * The array contains the weapon section, the weapon name and the short weapon name
         *
         * @todo Optimize it
         * @param array|string $index
         * @return array
         */
        public function getWeapon($index) {
            if (!$index) {
                return array("section" => 'special', "name" => $this->special["none"], "short" => 'none');
            }
    
            if (is_array($index) && $index[0] == "none") {
                $weaponindex = $index[0];
                $specialindex = $index[1];
                $specialindex_array = explode("_", $specialindex);
            } elseif (is_array($index)) {
                $weaponindex = $index[0];
                $specialindex = $index[1];
            } else {
                $weaponindex = $index;
                $specialindex = NULL;
            }
    
            $index_array = explode("_", $weaponindex);
    
            foreach ($this->special as $short => $long) {
                if (strtolower($short) == strtolower($weaponindex)) {
                    return array("section" => "special", "name" => $this->special[$short], "short" => $short);
                }
            }
    
            foreach ($this->weapons as $section => $values) {
                foreach ($values as $short => $long) {
                    if (strtolower($short) == strtolower($index_array[0])) {
                        return array("section" => $section, "name" => $this->weapons[$section][$short], "short" => $short);
                    }
                }
            }
    
            foreach ($this->extensions as $short => $long) {
                if (strtolower($short) == strtolower($index_array[2])) {
                    return array("section" => 'extensions', "name" => $this->extensions[$short], "short" => $short);
                }
            }
    
            $this->logging->error("Weapon with index: $weaponindex not found");
        }
    }
    Alles anzeigen
  • GSM & CoD 2

    • Mirko911
    • 28. Februar 2017 um 00:47

    Do you have steam and some time tomorrow. I would like to test it with you to add the missing weapons.

    http://steamcommunity.com/id/mirko91194/

  • Pingchecker

    • Mirko911
    • 26. Februar 2017 um 19:12

    are you sure that you've enabled the pingkicker plugin in the config/plugins/pingkicker.json file?

  • GeoIP

    • Mirko911
    • 26. Februar 2017 um 19:08

    you can edit the languages/english/libraries/geoip.json and change the "other", or "own" line.

    JavaScript: languages/english/libraries/geoip.json
    {
        "geoip": {
            "own": "Hallo my name is <NAME> and I'm from <COUNTRY_NAME>",
            "other": "Player <NAME> is from <COUNTRY_NAME>"
        },
        "geoip.help": {
            "location": "location <OPTIONAL PID|NAME> returns the country of a player"
        }
    }

    Here you can use the following keywords:

    Code
    '<NAME>',
    '<COUNTRY_CODE>',
    '<COUNTRY_NAME>',
    '<CITY_NAME>',
    '<CONTINENT_CODE>',
    '<CONTINENT_NAME>'
  • Pingchecker

    • Mirko911
    • 26. Februar 2017 um 18:26

    can you send us the logfiles?

  • GeoIP

    • Mirko911
    • 26. Februar 2017 um 18:25

    do you want to integrate the geoip functions into a plugin, or do you just want a !location command with more information?

  • Installation error

    • Mirko911
    • 18. Februar 2017 um 18:21

    [18.02.17 17:37:49] Warning: Error in file "config//plugins/automessages.json": Syntax error

    Check your automessages file. You can use a Json Validator for that. http://jsonlint.com/

  • Logging GSManager

    • Mirko911
    • 12. Februar 2017 um 11:33

    https://gitlab.mirko-rosenthal.info/gsm-plugins/iplog

    Direct download: https://gitlab.mirko-rosenthal.info/gsm-plugins/ip….zip?ref=master

    Notice: I failed with the logfile name in the chatlog plugin. I updated it. You can download the new version from the link in my old post from yesterday

  • Logging GSManager

    • Mirko911
    • 12. Februar 2017 um 11:12

    I'll create the IPLog Plugin asap.

    There isn't much to change to log the ip

  • Logging GSManager

    • Mirko911
    • 11. Februar 2017 um 22:48

    https://gitlab.mirko-rosenthal.info/gsm-plugins/chatlog

    or the direct download:

    https://gitlab.mirko-rosenthal.info/gsm-plugins/ch….zip?ref=master

  • mapsettings

    • Mirko911
    • 5. Februar 2017 um 17:16
    Code
    {
      "mapsettings": 
      {
        "enabled": false,
        "mp_example": 
        {
          "automessages": 
          {
            "enabled": false
          },
          "rcon": 
          [
            "g_gravity 800",
            "g_speed 270",
            "sv_hostname ^1New Hostname"
          ],
          "default": 
          [
            "sv_hostname ^1Default Hostname",
            "g_speed 180"
          ]
        },
        "mp_crash": 
        {
          "automessages": 
          {
            "enabled": true
          },
          "rcon": 
          [
            "sv_hostname ^1Server is running mp_crash now"
          ],
          "default": 
          [
            "sv_hostname ^1My cool server with GSM",
          ]
        },
    "mp_backlot": 
        {
          "welcomemessages": 
          {
            "enabled": false
          },
          "rcon": 
          [
            "sv_hostname ^1Server is running mp_backlot now"
          ],
          "default": 
          [
            "sv_hostname ^1My cool server with GSM",
          ]
        }
      }
    }
    Alles anzeigen

    Just copy and paste the the mapname + the whole { } section.

    You can overwrite any config settings for each map. Also it's possible to change rcon values in the "rcon" section.

    The default section is needed to change the values back to the old value on mapchange

  • mapsettings

    • Mirko911
    • 5. Februar 2017 um 15:09

    what do you mean with "to use in other maps"?

  • Problem with GSManager and IW4X (solved) 1 new problem

    • Mirko911
    • 4. Februar 2017 um 17:05

    you don't help anyone if you delete all your messages ...

  1. Mitarbeiter
  2. Datenschutzerklärung
  3. Nutzungsbedingungen
  4. Impressum
  5. Kontakt
Community-Software: WoltLab Suite™