A long time ago, i made this
PHP Code:
#include < amxmodx >
#include <colorchat>
#include < server_query >
new const SERVER_IP[ ] = "172.21.63.113"; //this will be your server ip :3
const SERVER_PORT = 27015; // this will be the your server port
public plugin_init( )
{
register_clcmd( "say /server", "command_QueryPlayers" );
register_clcmd( "say_team /server", "command_QueryPlayers" );
}
public command_QueryPlayers( id )
{
new iError;
if( !sq_query( SERVER_IP, SERVER_PORT, SQ_Server, "handle_playerQuery", iError ) )
{
new sError[ 128 ];
sq_error( iError, sError, charsmax( sError ) );
ColorChat( id, GREY, "^4Error: %s", sError );
}
}
public handle_playerQuery( QueryID, iType, Trie:buffer, Float:queryTime, bool:bFailed, sData[ ], iDataSize )
{
if( bFailed )
{
ColorChat( 0, GREY, "^4Failed query for %d type", iType );
}
else
{
if( iType == SQ_Server )
{
new host[64], map[64];
new numPlayers, maxPlayers, bool:password;
TrieGetString(buffer, "server_name", host, charsmax(host));
TrieGetString(buffer, "map", map, charsmax(map));
TrieGetCell(buffer, "num_players", numPlayers);
TrieGetCell(buffer, "max_players", maxPlayers);
password = TrieKeyExists(buffer, "password");
set_hudmessage(0, 255, 0, 0.25, 0.0, 0, 6.0, 12.0)
show_hudmessage(0, "Server name:%s^nIP:%s:%d^nMap:%s^nPlayers: (%d/%d)^nPassword:%s",host,SERVER_IP,SERVER_PORT,map,numPlayers,maxPlayers,password?"Yes":"No");
}
}
}
Link to server query api :
https://forums.alliedmods.net/showthread.php?t=142858