[Ajuda] API SAMP PHP
#3

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(<= $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.'
Reply


Messages In This Thread
API SAMP PHP - by idegod - 03.05.2018, 04:08
Re: API SAMP PHP - by RodrigoMSR - 03.05.2018, 05:58
Re: API SAMP PHP - by Locky_ - 03.05.2018, 13:26
Re: API SAMP PHP - by idegod - 03.05.2018, 17:30

Forum Jump:


Users browsing this thread: 1 Guest(s)