Expand description
Native bindings for the Open Multiplayer SDK.
Independent pure-Rust implementation of the binary ABI of the Open Multiplayer
server: vtables, layout of IComponent/ICore/ITimer, calling
conventions, and subobject offsets. No dependency on the original C++ libs
(robin_hood, glm, nonstd) — only the types sufficient to implement a
component’s lifecycle.
Offsets and slots were confirmed via disasm of Console.dll / Console.so
and omp-server.exe, not by guessing from the C++ headers.
Supports the two i686 ABIs used by the server:
- Itanium (Linux GCC) — calling convention
extern "C" - MSVC (Windows) — calling convention
extern "thiscall"for virtual methods,extern "C"(cdecl) for variadic
Modules§
- component
IComponentinterface from the Open Multiplayer SDK in pure Rust.- component_
api - High-level API for Open Multiplayer server components.
- core
- Bindings for the
ILoggerinterface ofICore(Open Multiplayer). - events
- Pawn script events via
IEventDispatcher<PawnEventHandler>. - extensions
- Reading the extension map an
IExtensiblecarries. - players
- Player events straight from the Open Multiplayer server.
- server
- Vtables for objects managed by the Open Multiplayer server.
- timers
- Bindings for the Open Multiplayer
ITimersComponentinterface. - types
- Primitive types for the Open Multiplayer ABI:
UID,SemanticVersion,StringView,Colour,Vector{2,3,4},ComponentType. - vehicles
- The Open Multiplayer vehicle component.
- vtable
- Helpers for accessing vtables (primary and secondary) of server-owned C++ objects.
- world
- World entities: objects and pickups.
Structs§
- Colour
- RGBA color.
- Gang
Zone Pos - The rectangle a gang zone covers, as
GangZonePosdeclares it. - IActor
- Opaque handle for
IActor*. - IActors
Component - Opaque handle for
IActorsComponent*. - IClass
- Opaque handle for
IClass*. - IClasses
Component - Opaque handle for
IClassesComponent*. - IComponent
List IComponentList*— list of loaded components. Received inon_init; use to query other components.- IComponentV
Table - Primary
IComponentvtable for the MSVC ABI (Windows). - ICore
ICore*— opaque pointer to the Open Multiplayer server core. Received inon_load; use only for caching or future queries.- IEarly
Config IEarlyConfig*— configuration during initialization.- IEvent
Dispatcher Pawn - Opaque handle for the server’s
IEventDispatcher<PawnEventHandler>*. - IGang
Zone - Opaque handle for
IGangZone*. - IGang
Zones Component - Opaque handle for
IGangZonesComponent*. - ILogger
ILogger*— server logging interface.- IMenu
- Opaque handle for
IMenu*. - IMenus
Component - Opaque handle for
IMenusComponent*. - IObject
- Opaque handles for the objects a shot can hit, beyond the vehicle the
vehiclesmodule already defines. - IObjects
Component - Opaque handle for
IObjectsComponent*. - IPawn
Script - Opaque handle for the server’s
IPawnScript*. - IPickup
- Opaque handle for
IPickup*. - IPickups
Component - Opaque handle for
IPickupsComponent*. - IPlayer
- Opaque handle for the server’s
IPlayer*, as received by a handler. - IPlayer
Change Dispatcher - Opaque handle for
IEventDispatcher<PlayerChangeEventHandler>*. - IPlayer
Check Dispatcher - Opaque handle for
IEventDispatcher<PlayerCheckEventHandler>*. - IPlayer
Click Dispatcher - Opaque handle for
IEventDispatcher<PlayerClickEventHandler>*. - IPlayer
Connect Dispatcher - Opaque handle for
IEventDispatcher<PlayerConnectEventHandler>*. - IPlayer
Damage Dispatcher - Opaque handle for
IEventDispatcher<PlayerDamageEventHandler>*. - IPlayer
Object - See
IObject. - IPlayer
Pool - Opaque handle for the server’s
IPlayerPool*. - IPlayer
Shot Dispatcher - Opaque handle for
IEventDispatcher<PlayerShotEventHandler>*. - IPlayer
Spawn Dispatcher - Opaque handle for
IEventDispatcher<PlayerSpawnEventHandler>*. - IPlayer
Stream Dispatcher - Opaque handle for
IEventDispatcher<PlayerStreamEventHandler>*. - IPlayer
Text Dispatcher - Opaque handle for
IEventDispatcher<PlayerTextEventHandler>*. - IPlayer
Update Dispatcher - Opaque handle for
IEventDispatcher<PlayerUpdateEventHandler>*. - IText
Draw - Opaque handle for
ITextDraw*. - IText
Draws Component - Opaque handle for
ITextDrawsComponent*. - IText
Label - Opaque handle for
ITextLabel*. - IText
Labels Component - Opaque handle for
ITextLabelsComponent*. - ITimer
- Opaque pointer to the server’s
ITimer— returned bycreate_timer. - ITimers
Component - Opaque pointer to the server’s
ITimersComponent. - IUID
ProviderV Table - Secondary
IUIDProvidervtable for the MSVC ABI (Windows). - IVehicle
- Opaque handle for the server’s
IVehicle*. - IVehicle
Dispatcher - Opaque handle for
IEventDispatcher<VehicleEventHandler>*. - IVehicles
Component - Opaque handle for the server’s
IVehiclesComponent*. - OmpComponent
- Pawn
Component - Typed wrapper for the Open Multiplayer server’s
IPawnComponent. - Pawn
Event Handler - Rust object compatible with Open Multiplayer’s
PawnEventHandler*. - Pawn
Event HandlerV Table PawnEventHandlervtable for the MSVC ABI (Windows).- Player
Bullet Data PlayerBulletData, passed by const reference — opaque here, since reading it means pinning another layout.- Player
Change Handler - Object the server calls through
PlayerChangeHandlerVTable. Layout: vtable pointer at offset 0, like any C++ object with virtuals. The server keeps the pointer, so it must outlive the registration. - Player
Change HandlerV Table PlayerChangeEventHandler.PlayerStateand the key masks arrive as plain integers.- Player
Check Handler - Object the server calls through
PlayerCheckHandlerVTable. Layout: vtable pointer at offset 0, like any C++ object with virtuals. The server keeps the pointer, so it must outlive the registration. - Player
Check HandlerV Table PlayerCheckEventHandler— the reply to a client check request.- Player
Click Handler - Object the server calls through
PlayerClickHandlerVTable. Layout: vtable pointer at offset 0, like any C++ object with virtuals. The server keeps the pointer, so it must outlive the registration. - Player
Click HandlerV Table PlayerClickEventHandler.Vector3is passed by value, as the header declares it.- Player
Connect Handler - Object the server calls on player connection events.
- Player
Connect HandlerV Table PlayerConnectEventHandlervtable — MSVC ABI (thisin ECX).- Player
Damage Handler - Object the server calls through
PlayerDamageHandlerVTable. Layout: vtable pointer at offset 0, like any C++ object with virtuals. The server keeps the pointer, so it must outlive the registration. - Player
Damage HandlerV Table PlayerDamageEventHandler.killeris null when nobody killed the player, andpartis aBodyPartvalue.- Player
Shot Handler - Object the server calls through
PlayerShotHandlerVTable. Layout: vtable pointer at offset 0, like any C++ object with virtuals. The server keeps the pointer, so it must outlive the registration. - Player
Shot HandlerV Table PlayerShotEventHandler— returningfalserejects the shot.bullet_datapoints at aPlayerBulletDatathe server owns.- Player
Spawn Handler - Object the server calls through
PlayerSpawnHandlerVTable. Layout: vtable pointer at offset 0, like any C++ object with virtuals. The server keeps the pointer, so it must outlive the registration. - Player
Spawn HandlerV Table PlayerSpawnEventHandler—onPlayerRequestSpawnreturningfalsedenies the spawn.- Player
Stream Handler - Object the server calls through
PlayerStreamHandlerVTable. Layout: vtable pointer at offset 0, like any C++ object with virtuals. The server keeps the pointer, so it must outlive the registration. - Player
Stream HandlerV Table PlayerStreamEventHandler— a player entering or leaving another’s stream radius.- Player
Text Handler - Object the server calls through
PlayerTextHandlerVTable. Layout: vtable pointer at offset 0, like any C++ object with virtuals. The server keeps the pointer, so it must outlive the registration. - Player
Text HandlerV Table PlayerTextEventHandler—onPlayerTextreturningfalseblocks the message;onPlayerCommandTextreturningtruemarks the command as handled.- Player
Update Handler - Object the server calls through
PlayerUpdateHandlerVTable. Layout: vtable pointer at offset 0, like any C++ object with virtuals. The server keeps the pointer, so it must outlive the registration. - Player
Update HandlerV Table PlayerUpdateEventHandler— fires for every player on every server tick, so keep the body short. Returningfalsedrops the update.- Pool
Bounds - The range of ids a pool can hand out, as
IReadOnlyPool<T>::bounds()reports it: inclusive on both ends. - Semantic
Version - Semantic version major.minor.patch with pre-release support.
- Server
Component List - Opaque handle for the server’s
IComponentList*. - Server
Pawn Component - Opaque handle for the server’s
IPawnComponent*. - String
View - Non-owning string —
(pointer, length)pair, no\0terminator. - Timer
HandlerV Table TimerTimeOutHandlervtable — MSVC ABI (thisin ECX).- Timer
Time OutHandler - Object the server will invoke on each timer timeout.
- Timers
Component - Typed wrapper for the Open Multiplayer server’s
ITimersComponent. - Vector2
- 2D vector.
- Vector3
- 3D vector — used for world positions in SA-MP/Open Multiplayer.
- Vector4
- 4D vector.
- Vehicle
Handler - Object the server calls on vehicle events. The
*mut u8arguments areIPlayer*; casting them tosuper::players::IPlayeris the caller’s call, and keeps this module from depending on the player one. - Vehicle
HandlerV Table VehicleEventHandlervtable — MSVC ABI (thisin ECX).- Weapon
Slot - One weapon slot of a spawn class (
WeaponSlotData).
Enums§
- Component
Type - Component type.
- Disconnect
Reason - Why the server dropped a player (
PeerDisconnectReasoninnetwork.hpp). - LogLevel
- Open Multiplayer log level (corresponds to
LogLevelincore.hpp).
Constants§
- ACTORS_
COMPONENT_ UID - UID of the Open Multiplayer
Actorscomponent. - CLASSES_
COMPONENT_ UID - UID of the Open Multiplayer
Classescomponent. - GANGZONES_
COMPONENT_ UID - UID of the Open Multiplayer
GangZonescomponent. - MAX_
WEAPON_ SLOTS - How many weapon slots a spawn class carries (
MAX_WEAPON_SLOTS). - MENUS_
COMPONENT_ UID - UID of the Open Multiplayer
Menuscomponent. - OBJECTS_
COMPONENT_ UID - UID of the Open Multiplayer
Objectscomponent. - PAWN_
COMPONENT_ UID - UID of the Open Multiplayer Pawn component (
PawnComponent_UIDin the SDK). - PICKUPS_
COMPONENT_ UID - UID of the Open Multiplayer
Pickupscomponent. - TEXTDRAWS_
COMPONENT_ UID - UID of the Open Multiplayer
TextDrawscomponent. - TEXTLABELS_
COMPONENT_ UID - UID of the Open Multiplayer
TextLabelscomponent. - TIMERS_
COMPONENT_ UID - UID of the Open Multiplayer
Timerscomponent. - VEHICLES_
COMPONENT_ UID - UID of the Open Multiplayer
Vehiclescomponent.
Traits§
- OmpComponent
Handle - Trait implemented by typed wrappers for Open Multiplayer components.
Functions§
- add_
pawn_ ⚠event_ handler - Registers a Pawn event handler in the dispatcher.
- add_
player_ ⚠change_ handler - Registers
handleron the dispatcher (addEventHandler, slot [0]). - add_
player_ ⚠check_ handler - Registers
handleron the dispatcher (addEventHandler, slot [0]). - add_
player_ ⚠click_ handler - Registers
handleron the dispatcher (addEventHandler, slot [0]). - add_
player_ ⚠connect_ handler - Registers
handleron the dispatcher (addEventHandler, slot [0]). - add_
player_ ⚠damage_ handler - Registers
handleron the dispatcher (addEventHandler, slot [0]). - add_
player_ ⚠shot_ handler - Registers
handleron the dispatcher (addEventHandler, slot [0]). - add_
player_ ⚠spawn_ handler - Registers
handleron the dispatcher (addEventHandler, slot [0]). - add_
player_ ⚠stream_ handler - Registers
handleron the dispatcher (addEventHandler, slot [0]). - add_
player_ ⚠text_ handler - Registers
handleron the dispatcher (addEventHandler, slot [0]). - add_
player_ ⚠update_ handler - Registers
handleron the dispatcher (addEventHandler, slot [0]). - add_
vehicle_ ⚠handler - Registers
handleron the vehicle dispatcher (addEventHandler, slot [0]). - all_
players ⚠ - Every player currently in the pool.
- as_
actors_ ⚠component - Casts a component handle obtained by UID into the actors component.
- as_
classes_ ⚠component - Casts a component handle obtained by UID into the classes component.
- as_
gangzones_ ⚠component - Casts a component handle obtained by UID into the gang zones component.
- as_
menus_ ⚠component - Casts a component handle obtained by UID into the menus component.
- as_
objects_ ⚠component - Casts a component handle obtained by UID into the objects component.
- as_
pickups_ ⚠component - Casts a component handle obtained by UID into the pickups component.
- as_
textdraws_ ⚠component - Casts a component handle obtained by UID into the text draws component.
- as_
textlabels_ ⚠component - Casts a component handle obtained by UID into the text labels component.
- as_
vehicles_ ⚠component - Casts a component handle obtained by UID into the vehicles component.
- component_
name - Reads the component name by calling
componentName()([SLOT_COMPONENT_NAME] of theIComponentvtable). - component_
version - Reads the component version by calling
componentVersion()([SLOT_COMPONENT_VERSION] of theIComponentvtable). - core_
log_ ⚠ln ICore::logLn(level, message)— writes a line with a log level.- core_
log_ ⚠ln_ u8 ICore::logLnU8(level, message)— UTF-8 variant oflogLn.- core_
print_ ⚠ln ICore::printLn(message)— writes a line to the server log.- core_
print_ ⚠ln_ u8 ICore::printLnU8(message)— UTF-8 variant ofprintLn.- create_
actor ⚠ IActorsComponent::create(skin, pos, angle)— a static NPC-looking actor.- create_
class ⚠ IClassesComponent::create(skin, team, spawn, angle, weapons)— a spawn class, whatAddPlayerClasscreates on the script side.- create_
gangzone ⚠ IGangZonesComponent::create(pos).- create_
menu ⚠ IMenusComponent::create(title, position, columns, col1Width, col2Width).- create_
object ⚠ IObjectsComponent::create(modelID, position, rotation, drawDistance).- create_
pickup ⚠ IPickupsComponent::create(modelId, type, pos, virtualWorld, isStatic).- create_
repeating_ ⚠timer - Creates a repeating timer on the Open Multiplayer server.
- create_
textdraw ⚠ ITextDrawsComponent::create(position, text)— a global text draw.- create_
textlabel ⚠ ITextLabelsComponent::create(text, colour, pos, drawDist, vw, los)— a label everyone sees.- create_
vehicle ⚠ IVehiclesComponent::create(...)— spawns a vehicle.- entity_
id ⚠ IEntity::getID()for any entity that carries the subobject — an object, a pickup, a vehicle or a player.- extension⚠
- The
IExtension*registered underuid, or null. - get_
amx_ ⚠from_ script - Extracts the
AMX*pointer from anIPawnScript*. - get_
amx_ ⚠functions - Gets the pointer to the AMX function table from the
IPawnComponent. - get_
pawn_ ⚠event_ dispatcher - Gets the Pawn event dispatcher from the
IPawnComponent. - kill_
timer ⚠ - Kills an active timer, stopping future fires.
- player_
armour ⚠ IPlayer::getArmour().- player_
by_ ⚠id IReadOnlyPool<IPlayer>::get(int)— the player with that id, or null.- player_
change_ ⚠dispatcher - The pool’s dispatcher for this event group.
- player_
check_ ⚠dispatcher - The pool’s dispatcher for this event group.
- player_
click_ ⚠dispatcher - The pool’s dispatcher for this event group.
- player_
connect_ ⚠dispatcher IPlayerPool::getPlayerConnectDispatcher().- player_
damage_ ⚠dispatcher - The pool’s dispatcher for this event group.
- player_
extension ⚠ IExtensible::getExtension(UID)on a player.- player_
give_ ⚠money IPlayer::giveMoney(int)— adds to what the player already has.- player_
health ⚠ IPlayer::getHealth().- player_
id ⚠ IEntity::getID()— the id Pawn scripts know this player by.- player_
interior ⚠ IPlayer::getInterior().- player_
is_ ⚠bot IPlayer::isBot()— whether this “player” is an NPC.- player_
kick ⚠ - Calls
IPlayer::kick()— drops the player from the server. - player_
money ⚠ IPlayer::getMoney().- player_
name ⚠ IPlayer::getName()— the player’s name, copied into aString.- player_
pool ⚠ ICore::getPlayers()— the server’s player pool.- player_
position ⚠ IEntity::getPosition()— where the player is.- player_
score ⚠ IPlayer::getScore().- player_
send_ ⚠message IPlayer::sendClientMessage(const Colour&, StringView)— a chat line for this player only.- player_
set_ ⚠armour IPlayer::setArmour(float).- player_
set_ ⚠controllable IPlayer::setControllable(bool)—falsefreezes the player.- player_
set_ ⚠drunk_ level IPlayer::setDrunkLevel(int).- player_
set_ ⚠health IPlayer::setHealth(float).- player_
set_ ⚠interior IPlayer::setInterior(unsigned).- player_
set_ ⚠money IPlayer::setMoney(int).- player_
set_ ⚠position IEntity::setPosition(Vector3)— teleports the player.- player_
set_ ⚠score IPlayer::setScore(int).- player_
set_ ⚠skin IPlayer::setSkin(int, bool)—sendasks the server to tell the other players about the change, which is what a script normally wants.- player_
set_ ⚠team IPlayer::setTeam(int).- player_
set_ ⚠virtual_ world IEntity::setVirtualWorld(int).- player_
set_ ⚠wanted_ level IPlayer::setWantedLevel(unsigned)— zero to six, as the game shows.- player_
set_ ⚠weather IPlayer::setWeather(int)— for this player alone.- player_
shot_ ⚠dispatcher - The pool’s dispatcher for this event group.
- player_
skin ⚠ IPlayer::getSkin().- player_
spawn_ ⚠dispatcher - The pool’s dispatcher for this event group.
- player_
stream_ ⚠dispatcher - The pool’s dispatcher for this event group.
- player_
team ⚠ IPlayer::getTeam().- player_
text_ ⚠dispatcher - The pool’s dispatcher for this event group.
- player_
update_ ⚠dispatcher - The pool’s dispatcher for this event group.
- player_
virtual_ ⚠world IEntity::getVirtualWorld().- player_
wanted_ ⚠level IPlayer::getWantedLevel().- pool_
bounds ⚠ IReadOnlyPool<T>::bounds()for any pool, given the offset of its subobject.- query_
component ⚠ - Queries a component by UID in the list provided by the server.
- query_
timers_ ⚠component - Queries
ITimersComponentin the server’s component list. - remove_
pawn_ ⚠event_ handler - Removes a Pawn event handler from the dispatcher.
- vehicle_
by_ ⚠id IReadOnlyPool<IVehicle>::get(int)— the vehicle with that id, or null.- vehicle_
event_ ⚠dispatcher IVehiclesComponent::getEventDispatcher().- vehicle_
health ⚠ IVehicle::getHealth().- vehicle_
id ⚠ IEntity::getID()for a vehicle — the id Pawn scripts use.- vehicle_
model ⚠ IVehicle::getModel().- vehicle_
position ⚠ IEntity::getPosition()for a vehicle.- vehicle_
set_ ⚠colour IVehicle::setColour(int, int).- vehicle_
set_ ⚠health IVehicle::setHealth(float).
Type Aliases§
- AmxFunction
Table - Table of 52 AMX function pointers (
StaticArray<void*, NUM_AMX_FUNCS>). - Pickup
Type - What a pickup does when a player walks into it (
PickupTypeinpickups.hpp). The values the scripts use are passed straight through, so this is ani32rather than an enum that would have to track the server’s. - UID
- 64-bit unique identifier of an Open Multiplayer component.