SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Português/Portuguese > Lançamentos/Releases

Reply
 
Thread Tools Display Modes
Old 08/04/2018, 04:21 PM   #1
BrunoBM23
Banned
 
Join Date: Mar 2018
Posts: 54
Reputation: 97
Default SA-MP Query Lib [C++]

SA-MP Query Lib

Uma simples lib para fazer uma "query" em servidores SA-MP.

Funções:
PHP Code:
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'. 
As funções Get* vão retornar esses valores:

Quote:
SAMP_QUERY_SUCCESS - 0
SAMP_QUERY_FAILED - 1
SAMP_INVALID_SOCKET - 2
Obtendo informação do servidor - Exemplo 1
PHP Code:
SampQuery query("samp.advanced-roleplay.com.br"77771000);

SampQuery::ServerInformation info;

memset(&info0sizeof(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;

Obtendo informação de jogadores - Exemplo 2
PHP Code:
SampQuery query("samp.advanced-roleplay.com.br"77771000);

if (
query.GetPlayersInfo() == SAMP_QUERY_SUCCESS)
{
    for (
std::vector<short>::size_type i 0!= query.ServerPlayers.size(); i++)
    {
        
std::cout << query.ServerPlayers[i].name << ' ' << query.ServerPlayers[i].score << std::endl;
    }

Aviso: Não esqueça de usar Ws2_32.lib como dependência adicional no seu projeto.

Github

Last edited by BrunoBM23; 11/05/2018 at 08:56 PM.
BrunoBM23 is offline   Reply With Quote
Old 08/04/2018, 05:57 PM   #2
ThiagoScottish
Little Clucker
 
ThiagoScottish's Avatar
 
Join Date: Mar 2018
Location: São Paulo
Posts: 30
Reputation: 0
Default Re: SA-MP Query Lib [C++]

Legal, testei aqui e até que ficou bom, parabéns.
__________________


Não é a linguagem de programação que define o programador, mas sim sua lógica.
ThiagoScottish is offline   Reply With Quote
Old 08/04/2018, 07:02 PM   #3
PT
Godfather
 
PT's Avatar
 
Join Date: Nov 2012
Location: Europe
Posts: 7,168
Reputation: 802
Default Re: SA-MP Query Lib [C++]

Bem top bom trabalho
PT is offline   Reply With Quote
Old 10/09/2019, 01:22 AM   #4
Sn0wden
Little Clucker
 
Join Date: Dec 2018
Posts: 5
Reputation: 4
Default Re: SA-MP Query Lib [C++]

Link caído
Sn0wden is offline   Reply With Quote
Old 10/09/2019, 03:45 PM   #5
Jimmmy
Gangsta
 
Jimmmy's Avatar
 
Join Date: Jul 2014
Location: Rio de Janeiro
Posts: 531
Reputation: 66
Default Re: SA-MP Query Lib [C++]

bom trabalho!
__________________



Hospedagem de Site, Host SA:MP, Revenda SA:MP, Host MTA, Host minecraft e VPS, Antiddos incluído em todos planos.

Viva Virtual - Em desenvolvimento...

Faço scripts de samp por encomenda. Entra em contato PM!.
Jimmmy is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it safe to include an un-escaped query into SQLite's query? Meller Scripting Help 2 09/10/2017 07:28 PM
a query elpana27 Scripting Help 2 30/12/2016 04:37 AM
Query ScriptWriter Scripting Help 1 27/10/2012 09:19 AM
Failed to exeute query. Lost connection to MySQL server during query. *IsBack Help Archive 10 06/01/2011 09:50 AM
QUERY tarmo Help Archive 7 04/12/2010 09:36 AM


All times are GMT. The time now is 02:52 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.