<?php
/**
*
* @author Edward McKnight (EM-Creations.co.uk)
* This example assumes this file is in the same directory as the SampQuery class.
*/
require("SampQuery.class.php");
$query = new SampQuery("127.0.0.1", 7777);
if ($query->connect()) { // If a successful connection has been made
print_r($query->getInfo()); // Print server info array
print_r($query->getBasicPlayers()); // Print basic players array, connection will time out if the player counter is above 100 and will return an empty array if no players are online
$query->close(); // Close the connection
} else {
echo "Server did not respond!";
}
?>
<?php
/**
*
* @author Edward McKnight (EM-Creations.co.uk)
* This example assumes this file is in the same director as the SampRcon class.
*/
require("SampRcon.class.php");
$query = new SampRcon("127.0.0.1", 7777, "changeme1");
if ($query->connect()) { // If a successful connection has been made
// Output command list
print_r($query->getCommandList());
$query->close(); // Close the connection
} else {
echo "Server did not respond!";
}
$query->close(); // Close the connection
?>
<?php
/**
*
* @author Edward McKnight (EM-Creations.co.uk)
* This example assumes this file is in the same directory as the SampRcon class.
*/
require("SampRcon.class.php");
$query = new SampRcon("127.0.0.1", 7777, "changeme1");
if ($query->connect()) { // If a successful connection has been made
$query->ban(1); // Ban player ID 1
$query->reloadBans(); // Reload the server's bans file
$query->close(); // Close the connection
} else {
echo "Server did not respond!";
}
$query->close(); // Close the connection
?>
Good job again!
Alot of more functions than the westie's query api ^_^ |
How can you get the information detailed on the page like in a table?
|
<?php require("SampQuery.class.php");
$query = new SampQuery("127.0.0.1", 7777);
if ($query->connect()) {
echo "<table><tr><td><strong>ID</strong></td><td><strong>Name</strong></td><td><strong>Score</strong></td><td><strong>Ping</strong></td></tr>";
$players = $query->getDetailedPlayers();
foreach ($players as $player) {
echo "<table><tr><td>{$player['playerid']}</td><td>{$player['nickname']}</td><td>{$player['score']}</td><td>{$player['ping']}</td></tr>";
}
echo "</table>";
} else {
echo "Error: Couldn't connect to server.";
}
?>
Parse error: syntax error, unexpected T_AS, expecting ';' in /home/kevin/public_html/online.php on line 60
<?php
$query = new SampQuery("178.32.227.161", 7777);
if ($query->connect()) {
echo "<table><tr><td><strong>ID</strong></td><td><strong>Name</strong></td><td><strong>Score</strong></td><td><strong>Ping</strong></td></tr>";
$players = $query->getDetailedPlayers();
foreach ($players as $player) { //line 60.
echo "<table><tr><td>{$player['playerid']}</td><td>{$player['nickname']}</td><td>{$player['score']}</td><td>{$player['ping']}</td></tr>";
}
echo "</table>";
} else {
echo "Error: Couldn't connect to server.";
}
?>
Yeah just working out the css now, http://transrp.tk/online.php
|
<?php session_start(); ?>
<?php
include("SampQuery.class.php"); // Require or include the SampQuery class file
?>
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<link type="text/css" href="menu.css" rel="stylesheet" />
<link href='http://fonts.******apis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="menu.js"></script>
<meta charset="utf-8">
<title>Transporter Roleplay</title>
<style type="text/css">
table, td, th
{
border:0px solid grey;
text-align:left;
border-collapse: separate;
border-spacing: 2px;
white-space: normal;
line-height: normal;
font-weight: normal;
font-size: medium;
font-variant: normal;
font-style: normal;
color: -webkit-text;
text-align: -webkit-auto;
}
th
{
background-color:green;
color:white;
text-align:left;
}
tr {
display: table-row;
vertical-align: inherit;
border-color: inherit;
}
tabel {
font-size:5px;
font-family:"Times New Roman", Times, serif;
}
A:link {text-decoration: bold; color: black}
A:visited {text-decoration: bold; color: black}
A:active {text-decoration: bold; color: black}
A:hover {text-decoration: underline; color: black;}
</style>
</head>
<body>
<a href="http://apycom.com/" style="visibility:hidden"></a>
<br />
<div id="wrapper">
<div id="header">
</div>
<div id="nav">
<div id="menu">
<ul class="menu">
<li><a href="/index.php" class="parent"><span>Home</span></a></li>
<li><a href="forums"><span>Forums</span></a></li>
<li><a href="#"><span>Server Team</span></a></li>
<li><a href="online.php"><span>Community</span></a></li>
<li><a href="#"><span>Patrocinations</span></a></li>
<li><a href="#"><span>Donations</span></a></li>
<?php if(empty($_SESSION['myusername'])){ ?>
<li><a href="login.php"><span>Login</span></a></li>
<?php }else{ ?>
<li><a href="user.php?user=<?php echo $_SESSION['myusername']; ?>"><span><?php echo $_SESSION['myusername']; ?></span></a>
<div><ul>
<?php if($_SESSION['playerlevel']>4){ ?>
<li><a href="adminpanel" class="parent"><span>Admin Panel</span></a>
</li>
<?php } ?>
<li><a href="logout.php" class="parent"><span>Log out</span></a>
</ul></div></li>
<?php } ?>
</ul>
</div>
</div>
<div id="mainContent">
<h1 style="font-family: 'Open Sans', sans-serif;">Welcome</h1><br />
<p style="font-family: 'Open Sans', sans-serif;">
<?php
$query = new SampQuery("178.32.227.161", 7777);
if ($query->connect()) {
echo "<table width='100%' border='1' cellpadding='3' cellspacing='1' bgcolor='#FFFFFF'><tr><th><strong>ID</strong></th><th><strong>Name</strong></th><th><strong>Score</strong></th><th><strong>Ping</strong></th></tr>";
$players = $query->getDetailedPlayers();
foreach ($players as $player) {
echo "<table width='100%' border='1' cellpadding='3' cellspacing='1' bgcolor='#FFFFFF'><tr><td>{$player['playerid']}</td><td><A HREF='http://transrp.tk/user.php?user={$player['nickname']}'>{$player['nickname']}</a></td><td>{$player['score']}</td><td>{$player['ping']}</td></tr>";
}
echo "</table></table>";
} else {
echo "Error: Couldn't connect to server.";
}
?>
</p>
</div>
<div id="footer">
</div>
</div>
</body>
</html>