08.04.2018, 15:21
(
Последний раз редактировалось BrunoBM23; 11.05.2018 в 19:56.
)
SA-MP Query Lib
Uma simples lib para fazer uma "query" em servidores SA-MP.
Funзхes:
PHP код:
SampQuery(std::string ip, const short port, const int timeout); // Constructor
~SampQuery(); // Destructor
unsigned char GetInformation(ServerInformation *info); // Obtйm informaзгo do servidor, como, nome do servidor, gamemode, lнnguagem, nъmero de slots, etc - Resposta do opcode 'i'.
unsigned char GetPlayersInfo(); // Obtйm informaзгo de jogadores, que й, nome e score - Resposta do opcode 'c'.
unsigned char GetServerRules(); // Obtйm as regras do servidor e valores - Resposta do opcode 'r'.
Quote:
SAMP_QUERY_SUCCESS - 0 SAMP_QUERY_FAILED - 1 SAMP_INVALID_SOCKET - 2 |
PHP код:
SampQuery query("samp.advanced-roleplay.com.br", 7777, 1000);
SampQuery::ServerInformation info;
memset(&info, 0, sizeof(info));
if (query.GetInformation(&info) == SAMP_QUERY_SUCCESS)
{
std::cout << info.hostname << std::endl;
std::cout << info.gamemode << std::endl;
std::cout << info.language << std::endl;
std::cout << info.max_players << std::endl;
std::cout << info.total_players << std::endl;
if(info.is_locked)
std::cout << "The server is locked" << std::endl;
}
PHP код:
SampQuery query("samp.advanced-roleplay.com.br", 7777, 1000);
if (query.GetPlayersInfo() == SAMP_QUERY_SUCCESS)
{
for (std::vector<short>::size_type i = 0; i != query.ServerPlayers.size(); i++)
{
std::cout << query.ServerPlayers[i].name << ' ' << query.ServerPlayers[i].score << std::endl;
}
}
Github