[Ajuda] API SAMP PHP - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (
https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] API SAMP PHP (
/showthread.php?tid=653387)
API SAMP PHP -
idegod - 03.05.2018
Usando essa API
https://sampforum.blast.hk/showthread.php?tid=355574
Eu consegui pegar algumas informaзхes do meu servidor como:
print_r($query->getBasicPlayers());
Array ( [0] => Array ( [name] => Indio [score] => 6 ) )
print_r($query->getDetailedPlayers());
Array ( [0] => Array ( [playerid] => 0 [nickname] => Indio [score] => 6 [ping] => 15 ) )
Mas como printar essas informaзхes separadas?
Tipo apenas nickname, apenas score, queria colocar dentro de uma tabela pra base de algumas coisas como onlinelist
Re: API SAMP PHP -
RodrigoMSR - 03.05.2018
PHP Code:
$players = $query->getBasicPlayers();
foreach($players as $player)
{
echo $player['name']." - ".$player['score']."<br>";
}
Re: API SAMP PHP -
Locky_ - 03.05.2018
Um exemplo de como usar essa API.
PHP Code:
$query = new SampQuery("127.0.0.1", 7777);
if ($query->connect()) {
$info = $query->getInfo();
$players = $query->getDetailedPlayers();
$query-close();
// Informaзхes sobre o servidor (tabelado)
echo '<table>
<tr>
<th>Hostname</th>
<td>'.$info['hostname'].'</td>
<th>Gamemode</th>
<td>'.$info['gamemodename'].'</td>
</tr>
<tr>
<th>Jogadores</th>
<td>'.$info['players'].'</td>
<th>Mбximo</th>
<td>'.$info['maxplayers'].'</td>
</tr>
</table>';
// Listar jogadores caso nгo esteja 0 ou acima de 100.
if(1 <= $info['players'] < 100)
{
echo '<table>
<tr>
<th>ID</th>
<th>Nickname</th>
<th>Scores</th>
<th>Ping</th>
</tr>';
foreach($players as $player)
{
echo '
<tr>
<td>'.$player['playerid'].'</td>
<td>'.$player['nickname'].'</td>
<td>'.$player['score'].'</td>
<td>'.$player['ping'].'</td>
</tr>';
}
echo '</table>';
}
}
else
echo 'Servidor off-line.';
Re: API SAMP PHP -
idegod - 03.05.2018
Muito obrigado aos dois! +REP