Jump to content

MTA GameQ and PHP


Recommended Posts

I welcome! I have a problem with GameQ on my side; I want to charge the number of players on the server and amount of slots. It is my code:

<?php include("head.php");  
  
require_once 'GameQ.php';  
  
  
  
$servers['Polski Realny Serwer'] = array('mtasa', '178.19.106.171', '22106 +123'); // dodajemy serwer 
  
//inicjalizajca 
  
  
$gq = new GameQ; 
  
//dodawanie zdefiniowanych serwerów 
$gq->addServers($servers); 
  
//proszenie o dane i wypisywanie ich 
try { 
    $data = $gq->requestData(); 
    
    
} 
//wyłapywanie błędów 
catch (GameQ_Exception $e) { 
    echo 'ZNALEZIONO BŁĄD W KODZIE!'; 
} 
// 
  
  
  
  
?> 
<body> 
  
<div style="text-align: center;"> 
<div class="page-header"> 
  <h1>Wybierz serwer </h1> <br> 
  
</div> 
  
<div class="alert alert-success">Muzyka: Bingo Players ft. Far East Movement - Get Up</div> 
<div class="btn-group btn-group-justified"> 
  <div class="btn-group"> 
  
    <button type="button" onclick="document.location.href='prs.php'" class="btn btn-default"><h1>Polski Realny Serwer</h1><br><h2>Graczy online: <?php echo ($data["num_players"] ."/". $data["max_players"]);?></h2></button>  
     
  </div>  
  
  <div class="btn-group btn-group-justified"> 
  <div class="btn-group"> 
   
    <button type="button" onclick="document.location.href='ts.php'" class="btn btn-default"><h1>TeamSpeak 3</h1><br><h2>Graczy online: x/10</h2></button> 
    <EMBED src="song.mp3" width="0" height="0" loop="4"> </EMBED> 
     
   
  
  </div> 
</div> 
  
</body> 
</html> 

Errors: http://zapodaj.net/199408dbbbe24.png.html (It is line 45)

Please, help me :(

Link to comment
I welcome! I have a problem with GameQ on my side; I want to charge the number of players on the server and amount of slots. It is my code:

<?php include("head.php");  
  
require_once 'GameQ.php';  
  
  
  
$servers['Polski Realny Serwer'] = array('mtasa', '178.19.106.171', '22106 +123'); // dodajemy serwer 
  
//inicjalizajca 
  
  
$gq = new GameQ; 
  
//dodawanie zdefiniowanych serwerów 
$gq->addServers($servers); 
  
//proszenie o dane i wypisywanie ich 
try { 
    $data = $gq->requestData(); 
    
    
} 
//wyłapywanie błędów 
catch (GameQ_Exception $e) { 
    echo 'ZNALEZIONO BŁĄD W KODZIE!'; 
} 
// 
  
  
  
  
?> 
<body> 
  
<div style="text-align: center;"> 
<div class="page-header"> 
  <h1>Wybierz serwer </h1> <br> 
  
</div> 
  
<div class="alert alert-success">Muzyka: Bingo Players ft. Far East Movement - Get Up</div> 
<div class="btn-group btn-group-justified"> 
  <div class="btn-group"> 
  
    <button type="button" onclick="document.location.href='prs.php'" class="btn btn-default"><h1>Polski Realny Serwer</h1><br><h2>Graczy online: <?php echo ($data["num_players"] ."/". $data["max_players"]);?></h2></button>  
     
  </div>  
  
  <div class="btn-group btn-group-justified"> 
  <div class="btn-group"> 
   
    <button type="button" onclick="document.location.href='ts.php'" class="btn btn-default"><h1>TeamSpeak 3</h1><br><h2>Graczy online: x/10</h2></button> 
    <EMBED src="song.mp3" width="0" height="0" loop="4"> </EMBED> 
     
   
  
  </div> 
</div> 
  
</body> 
</html> 

Errors: http://zapodaj.net/199408dbbbe24.png.html (It is line 45)

Please, help me :(

character "a" not allowed in prolog

Edited by Guest
Link to comment

this is going through my head

the only minor error i can see in this html is

<div style="text-align: center;"> 
<div class="page-header"> 
  <h1>Wybierz serwer </h1> <br> 
  
</div> 

line 35 to 39

you opened div tag twice but closed it only once, but it's minor error it shoul'nt create that problem which you are getting, maybe someother error which i'm not getting.

also replace 45 line with this and try

<body> 
  <button type="button" onclick="document.location.href='prs.php'" class= 
  "btn btn-default"> 
  <h1>Polski Realny Serwer</h1><br /> 
  
  <h2>Graczy online: 
  <?php echo ($data["num_players"] ."/". $data["max_players"]);?></h2></button> 

Link to comment

Next error :(

This is the new code:

  
<?php include("head.php");  
  
require_once 'GameQ.php'; 
  
$server = $_GET['server']; 
$game = $_GET['game']; 
  
// Jesli nie podano ip lub gry 
if (isset($server) && !empty($server) && isset($game) && !empty($game)) 
{ 
   // podzielenie adresu na ip oraz port 
   list($ip, $port) = explode(":", $server); 
} 
  
list($ip, $port) = explode(":", $server); 
  
$gq = new GameQ(); 
  
$gq->addServer('serwer', array('mtasa', '178.19.106.171', '22106')); 
$gq->setOption('timeout', 200); 
$gq->setFilter('normalise'); 
$gq->setFilter('sortplayers', 'gq_ping'); 
$results = $gq->requestData(); 
  
if($results['serwer']['gq_hostname']=="") 
{ 
   $hostname = "Serwer OFFLINE"; 
   $players = "x"; 
   $playersmax = "x"; 
   $map = "Offline"; 
} 
else 
{ 
   $hostname = $results['serwer']['gq_hostname']; 
   $players = $results['serwer']['gq_numplayers']; 
   $playersmax = $results['serwer']['gq_maxplayers']; 
   $map = $results['serwer']['gq_mapname']; 
} 
$players = ($results['serwer']['gq_numplayers'] == '') ? 0 : $results['serwer']['gq_numplayers']; 
  
?> 
<body> 
  
<div style="text-align: center;"> 
<div class="page-header"> 
  <h1>Wybierz serwer </h1> <br> 
  
</div> 
  
<div class="alert alert-success">Muzyka: Bingo Players ft. Far East Movement - Get Up</div> 
<div class="btn-group btn-group-justified"> 
  <div class="btn-group"> 
  
   <body> 
  <button type="button" onclick="document.location.href='prs.php'" class= 
  "btn btn-default"> 
  <h1>Polski Realny Serwer</h1><br /> 
  
  <h2>Graczy online: 
  <?php echo ($data["num_players"] ."/". $data["max_players"]);?></h2></button> 
  
     
  </div>  
  
  <div class="btn-group btn-group-justified"> 
  <div class="btn-group"> 
   
    <button type="button" onclick="document.location.href='ts.php'" class="btn btn-default"><h1>TeamSpeak 3</h1><br><h2>Graczy online: x/10</h2></button> 
    <EMBED src="song.mp3" width="0" height="0" loop="4"> </EMBED> 
  <!-- Ahh te moje umiejetnosci programowania w HTML ;p (+ rolora ) -->   
   
  
  </div> 
</div> 
  
</body> 
</html> 

Errors:

Notice: Undefined index: server in D:\xampp\htdocs\index.php on line 5

Notice: Undefined index: game in D:\xampp\htdocs\index.php on line 6

Notice: Undefined offset: 1 in D:\xampp\htdocs\index.php on line 15

Link to comment

Errors:

Notice: Undefined index: server in D:\xampp\htdocs\index.php on line 5

Notice: Undefined index: game in D:\xampp\htdocs\index.php on line 6

Notice: Undefined offset: 1 in D:\xampp\htdocs\index.php on line 15

these errors only appears when your variable is not properly set, it's because of your PHP error reporting settings, sorry i can't fix it :(

Edited by Guest
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...