itskoleban/Maxora
A fast and robust open.mp plugin for querying MaxMind DB (.mmdb) databases directly from Pawn scripts.
Ajoute ses fichiers include, avec les bibliothèques dont il dépend, au compilateur Pawn de ton navigateur, prêts à être inclus dans un script.
README.md
omp-mmdb
Introduction
omp-mmdb 2.0.0 is a C++20 component for scalable open.mp servers and the incompatible successor to Maxora. Its redesigned Pawn API uses script-local database names and numeric IP addresses to read fields from files supported by libmaxminddb, with no public database or result handles. Paths select fields by schema, so the same API works with geographic, ASN and other MMDB datasets. Release notes
Installation
Copy MMDB.dll (Windows x86) or MMDB.so (Linux x86) into the server's components/ directory alongside the official Pawn component. Copy include/omp_mmdb.inc into your Pawn compiler's include directory and place your licensed databases in scriptfiles/ or another server-readable directory. See installation for package verification and deployment details.
Quick Start
Compile examples/geolocation.pwn with the open.mp Pawn includes. It loads the City and ASN databases, reads the connecting player's address and looks up country and network information.
#include <open.mp>
#include <omp_mmdb>
main() {}
public OnGameModeInit() {
new MMDBStatus:asn = mmdb_load("asn", "scriptfiles/GeoLite2-ASN.mmdb");
new MMDBStatus:city = mmdb_load("city", "scriptfiles/GeoLite2-City.mmdb");
if (city != MMDB_OK || asn != MMDB_OK) {
printf("[MMDB] Load status: city=%d asn=%d", _:city, _:asn);
}
return 1;
}
public OnPlayerConnect(playerid) {
new ip[46], country[128], asn[40], required;
GetPlayerIp(playerid, ip, sizeof(ip));
if (mmdb_get_string("city", ip, "/country/names/en", country, sizeof(country), required) == MMDB_OK) {
printf("[MMDB] %s country: %s", ip, country);
}
if (mmdb_get_text("asn", ip, "/autonomous_system_number", asn, sizeof(asn), required) == MMDB_OK) {
printf("[MMDB] %s ASN: %s", ip, asn);
}
return 1;
}
Database Management
Use mmdb_load(name, file) to register a name and mmdb_reload(name, file) to replace its mapping. Failed reloads preserve the previous database. mmdb_is_loaded reports whether a name is present. Each Pawn script owns its databases and their case-sensitive names. Unloading a gamemode or filterscript automatically releases its databases. Use mmdb_unload(name) to release a database early while the component is operational.
During full server shutdown, MMDB native availability in OnGameModeExit and OnFilterScriptExit is unspecified. In open.mp v1.6.7.3218, component teardown makes the natives unavailable before Pawn runs those callbacks. Rely on automatic cleanup during shutdown. Script unload and server shutdown
Querying Data
Pass a numeric IPv4 or IPv6 address and a JSON Pointer. For example, a dataset may use /country/names/en or /country_code for geographic data. mmdb_has_record checks coverage, and mmdb_get_prefix returns the matched network prefix in bits. mmdb_get_text preserves large integers as decimal and represents binary values as lowercase hexadecimal.
MaxMind Field Paths
See the MaxMind field path reference for common JSON Pointer paths, value types and Pawn reader functions, organized by City, Country, ASN, ISP and other MaxMind MMDB products. Fields depend on the database edition and the IP record; always handle missing values.
Arrays and Maps
Use /subdivisions/0/names/en for the first element of a nested array. "" selects the root, ~0 represents ~ and ~1 represents / within a key. mmdb_get_type identifies a container, mmdb_get_size counts its children and mmdb_has_field checks a path.
For unknown schemas, inspect the provider's field specification or inspect records offline with a database tool. The component bounds work on the server thread by exposing only field traversal and container inspection. See format and traversal for the enumeration and serialization trade-off.
Error Handling
Every native returns MMDBStatus:. Compare it with MMDB_OK, which is zero. mmdb_get_status_message formats a status directly. On MMDB_BUFFER_TOO_SMALL, required includes the terminating cell and the destination is unchanged. See status and output contracts.
Asynchronous Reloading
The component currently exposes synchronous mmdb_reload. The open.mp Pawn SDK has no lifetime guard for a callback that triggers immediate unload or reload of its own script. A future asynchronous callback requires a server guarantee that the script stays alive until execution returns. Lifecycle details.
API Reference
The public include declares every native and tag. See the API reference for argument order, return states and conversions, and the migration guide for changes from Maxora 1.x and 2.0 RC.
Building and Testing
Initialize recursive submodules and use CMake 3.24 or newer. The component builds for Windows x86 and Linux x86. The CI suite also builds a core-only host configuration, compiles Pawn examples, exercises a packaged component in open.mp and runs sanitizers and fuzzers. Build commands · Release qualification.
Performance and Limitations
Lookups and reloads run on the Pawn execution thread. Memory mapping permits demand paging, so cold pages and I/O can stall a tick. Stage immutable local files and reload during a low-traffic window. x86 maps the whole file and can fail below the reader's 2,147,483,647-byte ceiling, especially when old and new mappings coexist. Measurements and reproduction.
License
MIT. The package includes notices for its third-party dependencies. Maxora's Git history and earlier version tags remain available.
componentcpp17geoipmaxmindmmdbopenmppawnpluginsamp
Cette page est construite à partir de ce que GitHub publie sur le dépôt. samp.directory n’héberge pas le code. Signaler un problème avec cette fiche