![]() |
|
[Plugin] mysql_samp — MySQL support for SA-MP and open.mp, now featuring an open.mp-style API - Printable Version + open.mp forum (https://forum.open.mp) -- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) --- Forum: Releases (https://forum.open.mp/forumdisplay.php?fid=13) ---- Forum: Plugins (https://forum.open.mp/forumdisplay.php?fid=32) ---- Thread: [Plugin] mysql_samp — MySQL support for SA-MP and open.mp, now featuring an open.mp-style API (/showthread.php?tid=6368) |
mysql_samp — MySQL support for SA-MP and open.mp, now featuring an open.mp-style API - NullSablex - 2026-09-07 🦀 mysql_samp 1.3.0
MySQL para SA-MP e open.mp — o mesmo binário nos dois MySQL for SA-MP and open.mp — the same binary on both Download · GitHub · Documentação Quote:🇧🇷 Um plugin MySQL escrito em Rust, com 75 natives e nenhuma dependência para instalar. O novo desta versão: a API inteira também está disponível na convenção de nomes do open.mp — MySQL_Connect, Cache_GetRowCount, ORM_Create — para quem não quer snake_case no meio do gamemode. 📦 Instalar é copiar um arquivo / Installing is copying one file 🇧🇷 Não há libmysqlclient para caçar na versão certa, nem Boost, nem OpenSSL no sistema. O protocolo do MySQL e o TLS estão compilados dentro do binário. Você joga o .so ou o .dll na pasta e acabou — inclusive em host compartilhado, onde você não instala pacote nenhum. 🇬🇧 No libmysqlclient to hunt down, no Boost, no system OpenSSL. The MySQL protocol and TLS are compiled into the binary. Drop the .so or .dll in and you're done — including on shared hosting, where you install nothing. 🇧🇷 E é um binário só para os dois servidores: 🇬🇧 And it's one binary for both servers:
🆕 A novidade da 1.3.0: a API no estilo open.mp New in 1.3.0: the API in open.mp style 🇧🇷 Quem desenvolve para open.mp escreve CreateVehicle, GetPlayerName, TogglePlayerControllable. Aí chega a parte do banco de dados e o código vira mysql_connect, cache_get_row_count. Funciona, mas destoa. 🇬🇧 If you develop for open.mp you write CreateVehicle, GetPlayerName. Then the database part arrives and the code turns into mysql_connect, cache_get_row_count. It works, but it clashes. 🇧🇷 A partir desta versão existe um segundo include com todas as 75 natives na convenção Prefixo_PascalCase: 🇬🇧 From this release there's a second include with all 75 natives in Prefix_PascalCase: Code: // mysql_samp.inc // mysql_samp_omp.inc🇧🇷 São apelidos de Pawn (native MySQL_Connect(...) = mysql_connect;) — nenhum custo em tempo de execução, nada muda no plugin, é o mesmo binário. O include é gerado a partir do outro a cada build, então os dois nunca ficam fora de sincronia: native nova aparece nos dois automaticamente. 🇬🇧 They're Pawn aliases — zero runtime cost, nothing changes plugin-side, same binary. The include is generated from the other one on every build, so the two can never drift. Quote:🇧🇷 Os dois includes são alternativas, não camadas: escolha um por script. Quem já usa o <mysql_samp> não precisa mudar nada — nenhuma native foi removida ou renomeada. 📖 Documentação no editor / Docs in the editor 🇧🇷 Junto com isso, as 75 natives ganharam bloco JavaDoc (@param, @return) direto no include. Num editor que renderize isso — como a extensão PawnPro para VS Code — você passa o mouse sobre a função e lê a descrição e o que cada parâmetro espera, sem abrir o .inc para conferir a ordem dos argumentos. Em editor que não renderize, o comentário continua lá, legível como texto. 🇬🇧 The 75 natives also got JavaDoc blocks in the include. In an editor that renders them — such as the PawnPro extension for VS Code — hover a function and read the description and what each parameter expects. In editors that don't, it's still readable as a comment. 🔧 O que o plugin faz / What the plugin does 🇧🇷 Para quem está chegando agora, o conjunto completo: 🇬🇧 For anyone arriving now, the full set: 🇧🇷 Nenhuma query trava o servidor / 🇬🇧 No query stalls the server 🇧🇷 Não existe versão síncrona na API. mysql_query roda em thread separada e entrega os callbacks na ordem em que você pediu; mysql_pquery entrega assim que cada uma termina, sem ordem garantida. 🇬🇧 There is no synchronous version in the API. mysql_query runs off-thread and delivers callbacks in submission order; mysql_pquery delivers as each finishes. Code: mysql_query(g_mysql, "SELECT id, nome FROM contas LIMIT 10", "OnContasCarregadas", "");🇧🇷 ORM: a tabela vira variável / 🇬🇧 ORM: the table becomes a variable 🇧🇷 Você registra as variáveis do gamemode como colunas e usa orm_select / orm_save. Sem escrever SELECT e UPDATE à mão para cada campo de conta. 🇬🇧 Register your gamemode variables as columns, then use orm_select / orm_save. Code: new ormId = orm_create("contas", g_mysql);🇧🇷 Senha de jogador com Argon2id / 🇬🇧 Player passwords with Argon2id 🇧🇷 mysql_hash_password e mysql_verify_password rodam fora da thread do servidor — hash forte não trava o tick. O texto puro nunca entra numa query, então nunca entra num log. 🇬🇧 Both run off the server thread — strong hashing doesn't stall the tick. The plaintext never reaches SQL, so it never reaches a log. Code: mysql_hash_password(senhaDigitada, "OnSenhaGerada", "d", playerid);🇧🇷 Prepared statements / 🇬🇧 Prepared statements 🇧🇷 Para qualquer coisa digitada pelo jogador. Os valores vão pelo protocolo binário do MySQL: não há string montada, então não há escape para errar. 🇬🇧 For anything a player typed. Values go over MySQL's binary protocol: no string is assembled, so there's no escaping to get wrong. Code: new stmt = mysql_stmt_new(g_mysql, "SELECT id FROM contas WHERE nome = ?");🇧🇷 E ainda / 🇬🇧 And also
🎯 Começando / Getting started 🇧🇷 Baixe o binário da sua plataforma e o include que preferir — os dois são 32 bits, como o servidor. Depois: 🇬🇧 Download the binary for your platform and the include you prefer — both are 32-bit, like the server. Then: Code: #include <a_samp>🇧🇷 O passo a passo por servidor, os caminhos de include e o que fazer quando algo não conecta estão na página de instalação. 🇬🇧 Per-server steps, include paths and troubleshooting are on the installation page. 📚 Links
🇧🇷 Este projeto não é afiliado, endossado nem patrocinado pelo SA-MP ou pelo open.mp. "SA-MP", "open.mp" e "MySQL" pertencem a seus respectivos donos e são citados apenas para descrever compatibilidade. 🇬🇧 This project is not affiliated with, endorsed by, or sponsored by SA-MP or open.mp. "SA-MP", "open.mp", and "MySQL" are trademarks of their respective owners and are mentioned solely to describe compatibility. 🇧🇷 Dúvidas, sugestões e relatos de bug são bem-vindos — aqui no tópico ou nas issues.
🇬🇧 Questions, suggestions and bug reports are welcome — here or on GitHub issues. ⭐ github.com/NullSablex/mysql_samp |