Jump to content
  • 0

pomoc Upravení GameQ V3


jAk3r

Dotaz

Zdravím pánové,
mám takový problém chtěl hledal jsem nějaký systém na game server status a našel jsem jeden který se mi velice líbí a jmenuje se GameQ v3 je v něm vše co potřebuji ale mám problém s úpravou...


Kód který definuje systém aby fungoval.... plus vypisuje všechny informace které tento systém umí zjistit ale to vím....

require_once('src/GameQ/Autoloader.php');
// Define the servers you wish you query
$servers = [
    [
    'type'    => 'rust',
    'host'    => '185.91.116.30:28020',
    ]
];
$GameQ = new \GameQ\GameQ(); // or $GameQ = \GameQ\GameQ::factory();
$GameQ->addServers($servers);
$GameQ->setOption('timeout', 5); // seconds
$results = $GameQ->process();
print_r($results);

Když chci určitý data o serveru přidat do templates musím to dělat pomocí
$results["ip:port"]["funkci_kterou_chci_zjistit"]

Což mi přijde zbytečně složitý když si uvědomím že časem těch serverů bude více a přidávat každou funkci zvlášť....

Chtěl bych abych mohl třeba funkce volat $results->gg_hostname nebo $results->gg_adress atd....

a jen někam zadat typ hry,ip,port a potom mi to automaticky vypíše nový server do určité sekce které mám rozděleny podle typu hry....

Tak jak to mají na https://www.gamesites.cz/servery/

můj kamarád mi poslal jak tento systém používal ty ale problém je v tom že to má podle staré verze tudíž když sem se to pokusil opravit nelíbilo se mu zapisování $servers

error_reporting(E_ALL);
require_once('src/GameQ/Autoloader.php');

// Define your servers,
// see list.php for all supported games and identifiers.
$servers = array(
    'server 1' => array('halflife', '185.91.116.39', 27028),
    'server 2' => array('ts3', '185.91.116.215', 9987),
    'server 3' => array('bf2142', '194.109.69.21'),
'server 4' => array('ts3', 'voice.planetteamspeak.com')
);

// Call the class, and add your servers.
$gq = new \GameQ\GameQ();
$gq->addServers($servers);
  
// You can optionally specify some settings
$gq->setOption('timeout', 200);

// You can optionally specify some output filters,
// these will be applied to the results obtained.
$gq->setFilter('normalise');
$gq->setFilter('sortplayers', 'gq_ping');
// Send requests, and parse the data
$results = $gq->requestData();


// Some functions to print the results
function print_results($results) {
    foreach ($results as $id => $data) {
        printf("<h2>%s</h2>\n", $id);
        print_table($data);
    }
}
function print_table($data) {
    $gqs = array('gq_online', 'gq_address', 'gq_port', 'gq_prot', 'gq_type');
  
    if (!$data['gq_online']) {
        printf("<p>The server did not respond within the specified time.</p>\n");
        return;
    }
    print("<table><thead><tr><td>Variable</td><td>Value</td></tr></thead><tbody>\n");
    foreach ($data as $key => $val) {
        if (is_array($val)) continue;
        $cls = empty($cls) ? ' class="uneven"' : '';
        if (substr($key, 0, 3) == 'gq_') {
            $kcls = (in_array($key, $gqs)) ? 'always' : 'normalise';
            $key = sprintf("<span class=\"key-%s\">%s</span>", $kcls, $key);
        }
        printf("<tr%s><td>%s</td><td>%s</td></tr>\n", $cls, $key, $val);
    }
    print("</tbody></table>\n");
  
}

Opravdu se to snažím udělat sám ale nějak to nejde proto sem chtěl požádat o pomoc vás zkušenější...

předem děkuji za pomoc smile.png

S pozdravem
jAk3r
Link to comment
Share on other sites

0 odpovědí na tuto otázku

Recommended Posts

There have been no answers to this question yet

Guest
This topic is now closed to further replies.
×
×
  • Create New...