Runnable Pawn snippets showing how to use the plugin on SA-MP and Open Multiplayer. The plugin natives (mysql_*, cache_*, orm_*) and the OnQueryError forward are identical across both servers — every snippet here exercises only the plugin API.
| File | Topic |
|---|---|
01_basic_connection.pwn |
Connect / close, with and without mysql_options_new() |
02_threaded_query.pwn |
mysql_query + callback, read cache by column name / index |
03_parallel_query.pwn |
mysql_pquery for unordered, parallel work |
04_escape_and_format.pwn |
mysql_format (%s auto-escape, %e, %r, %d, %f) |
05_orm.pwn |
ORM: bind Pawn vars to columns, orm_save / orm_select |
06_ssl.pwn |
Enable TLS via MYSQL_OPT_SSL / MYSQL_OPT_SSL_CA (v1.1.1+) |
07_error_handling.pwn |
OnQueryError, mysql_errno, mysql_error |
The examples assume the include path is set up so that <mysql_samp> resolves to ../include/mysql_samp.inc.
pawncc -i../include 01_basic_connection.pwnOr copy mysql_samp.inc into your pawno/include/ (SA-MP) or qawno/include/ (open.mp) folder and compile from inside the gamemode tree.
Drop mysql_samp.so (Linux) or mysql_samp.dll (Windows) into plugins/ and register it in server.cfg:
plugins mysql_samp.so
Drop the binary into the components/ folder. open.mp auto-discovers it on start and loads it via ComponentEntryPoint. No config.json entry is required — listing the file in components is not a thing; the folder itself IS the registration.
Drop the binary into plugins/ and declare it under legacy_plugins in config.json (legacy plugins must be listed explicitly, unlike native components):
{
"pawn": {
"legacy_plugins": ["mysql_samp"]
}
}- Connection credentials are placed at the top as
#defines — replace with values from a config file in real code. - One global
g_MysqlConnholds the connection id;0means "not connected". - Threaded callbacks read from the implicit active cache; no need to call
cache_set_activeunless you persisted the cache withcache_save. - All queries are non-blocking — the gamemode never waits on MySQL.