rust-samp-sdk 3.6.0

Low-level FFI bindings for the SA-MP AMX virtual machine and open.mp native component ABI. Used internally by `rust-samp`; depend on it directly only if you need raw access without the higher-level macros and lifecycle.
Documentation
//! `IPlayerPool` — generated by `cargo xtask gen-omp` from `player.hpp`.
//! Implemented by `PlayerPool` in the server's `omp-server`.
//!
//! Do not edit: change `xtask/omp-wrappers.toml` or the generator and
//! regenerate. Slots are clang's layout of the header for each ABI, checked
//! against the official binaries by `cargo xtask check-abi --generated`.

#![allow(unused_imports)]

use crate::omp::containers::{FlatSet, HybridString, Pair, Span};
use crate::omp::types::{
    Colour, GTAQuat, Hours, Microseconds, Milliseconds, Minutes, Seconds, StringView, TimePoint,
    UID, Vector2, Vector3, Vector4, WorldTimePoint,
};
use crate::omp::vtable::{call_vtable_small_struct, opaque, slots, virtual_fns};
use crate::omp::*;

slots! {
    /// `const FlatPtrHashSet<IPlayer> & IPlayerPool::entries()`
    SLOT_ENTRIES: usize = 6, 5;
    /// `const FlatPtrHashSet<IPlayer> & IPlayerPool::players()`
    SLOT_PLAYERS: usize = 7, 6;
    /// `const FlatPtrHashSet<IPlayer> & IPlayerPool::bots()`
    SLOT_BOTS: usize = 8, 7;
    /// `IEventDispatcher<PoolEventHandler<IPlayer>> & IPlayerPool::getPoolEventDispatcher()`
    SLOT_GET_POOL_EVENT_DISPATCHER: usize = 19, 18;
    /// `bool IPlayerPool::isNameTaken(StringView, const IPlayer *)`
    SLOT_IS_NAME_TAKEN: usize = 20, 19;
    /// `void IPlayerPool::sendClientMessageToAll(const Colour &, StringView)`
    SLOT_SEND_CLIENT_MESSAGE_TO_ALL: usize = 21, 20;
    /// `void IPlayerPool::sendChatMessageToAll(IPlayer &, StringView)`
    SLOT_SEND_CHAT_MESSAGE_TO_ALL: usize = 22, 21;
    /// `void IPlayerPool::sendGameTextToAll(StringView, Milliseconds, int)`
    SLOT_SEND_GAME_TEXT_TO_ALL: usize = 23, 22;
    /// `void IPlayerPool::hideGameTextForAll(int)`
    SLOT_HIDE_GAME_TEXT_FOR_ALL: usize = 24, 23;
    /// `void IPlayerPool::sendDeathMessageToAll(IPlayer *, IPlayer &, int)`
    SLOT_SEND_DEATH_MESSAGE_TO_ALL: usize = 25, 24;
    /// `void IPlayerPool::sendEmptyDeathMessageToAll()`
    SLOT_SEND_EMPTY_DEATH_MESSAGE_TO_ALL: usize = 26, 25;
    /// `void IPlayerPool::createExplosionForAll(Vector3, int, float)`
    SLOT_CREATE_EXPLOSION_FOR_ALL: usize = 27, 26;
    /// `Pair<NewConnectionResult, IPlayer *> IPlayerPool::requestPlayer(const PeerNetworkData &, const PeerRequestParams &)`
    SLOT_REQUEST_PLAYER: usize = 28, 27;
    /// `void IPlayerPool::broadcastPacket(Span<uint8_t>, int, const IPlayer *, bool)`
    SLOT_BROADCAST_PACKET: usize = 29, 28;
    /// `void IPlayerPool::broadcastRPC(int, Span<uint8_t>, int, const IPlayer *, bool)`
    SLOT_BROADCAST_RPC: usize = 30, 29;
    /// `bool IPlayerPool::isNameValid(StringView)`
    SLOT_IS_NAME_VALID: usize = 31, 30;
    /// `void IPlayerPool::allowNickNameCharacter(char, bool)`
    SLOT_ALLOW_NICK_NAME_CHARACTER: usize = 32, 31;
    /// `bool IPlayerPool::isNickNameCharacterAllowed(char)`
    SLOT_IS_NICK_NAME_CHARACTER_ALLOWED: usize = 33, 32;
    /// `Colour IPlayerPool::getDefaultColour(int)`
    SLOT_GET_DEFAULT_COLOUR: usize = 34, 33;
}

virtual_fns! {
    /// `const FlatPtrHashSet<IPlayer> & IPlayerPool::entries()`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    #[must_use]
    pub fn players_entries(
        pool: IPlayerPool,
    ) -> *const FlatSet<IPlayer> = [0, SLOT_ENTRIES] or std::ptr::null();

    /// `const FlatPtrHashSet<IPlayer> & IPlayerPool::players()`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    #[must_use]
    pub fn players_players(
        pool: IPlayerPool,
    ) -> *const FlatSet<IPlayer> = [0, SLOT_PLAYERS] or std::ptr::null();

    /// `const FlatPtrHashSet<IPlayer> & IPlayerPool::bots()`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    #[must_use]
    pub fn players_bots(
        pool: IPlayerPool,
    ) -> *const FlatSet<IPlayer> = [0, SLOT_BOTS] or std::ptr::null();

    /// `IEventDispatcher<PoolEventHandler<IPlayer>> & IPlayerPool::getPoolEventDispatcher()`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    #[must_use]
    pub fn players_pool_event_dispatcher(
        pool: IPlayerPool,
    ) -> *mut EventDispatcher<PlayerPoolHandler> = [0, SLOT_GET_POOL_EVENT_DISPATCHER] or std::ptr::null_mut();

    /// `bool IPlayerPool::isNameTaken(StringView, const IPlayer *)`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    #[must_use]
    pub fn players_is_name_taken(
        pool: IPlayerPool,
        name: StringView,
        skip: *mut IPlayer,
    ) -> bool = [0, SLOT_IS_NAME_TAKEN] or false;

    /// `void IPlayerPool::sendClientMessageToAll(const Colour &, StringView)`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    pub fn players_send_client_message_to_all(
        pool: IPlayerPool,
        colour: &Colour,
        message: StringView,
    ) = [0, SLOT_SEND_CLIENT_MESSAGE_TO_ALL];

    /// `void IPlayerPool::sendChatMessageToAll(IPlayer &, StringView)`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    pub fn players_send_chat_message_to_all(
        pool: IPlayerPool,
        from: *mut IPlayer,
        message: StringView,
    ) = [0, SLOT_SEND_CHAT_MESSAGE_TO_ALL];

    /// `void IPlayerPool::sendGameTextToAll(StringView, Milliseconds, int)`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    pub fn players_send_game_text_to_all(
        pool: IPlayerPool,
        message: StringView,
        time: Milliseconds,
        style: i32,
    ) = [0, SLOT_SEND_GAME_TEXT_TO_ALL];

    /// `void IPlayerPool::hideGameTextForAll(int)`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    pub fn players_hide_game_text_for_all(
        pool: IPlayerPool,
        style: i32,
    ) = [0, SLOT_HIDE_GAME_TEXT_FOR_ALL];

    /// `void IPlayerPool::sendDeathMessageToAll(IPlayer *, IPlayer &, int)`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    pub fn players_send_death_message_to_all(
        pool: IPlayerPool,
        killer: *mut IPlayer,
        killee: *mut IPlayer,
        weapon: i32,
    ) = [0, SLOT_SEND_DEATH_MESSAGE_TO_ALL];

    /// `void IPlayerPool::sendEmptyDeathMessageToAll()`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    pub fn players_send_empty_death_message_to_all(
        pool: IPlayerPool,
    ) = [0, SLOT_SEND_EMPTY_DEATH_MESSAGE_TO_ALL];

    /// `void IPlayerPool::createExplosionForAll(Vector3, int, float)`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    pub fn players_create_explosion_for_all(
        pool: IPlayerPool,
        vec: Vector3,
        type_value: i32,
        radius: f32,
    ) = [0, SLOT_CREATE_EXPLOSION_FOR_ALL];

    /// `void IPlayerPool::broadcastPacket(Span<uint8_t>, int, const IPlayer *, bool)`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    pub fn players_broadcast_packet(
        pool: IPlayerPool,
        data: Span<u8>,
        channel: i32,
        skip_from: *mut IPlayer,
        dispatch_events: bool,
    ) = [0, SLOT_BROADCAST_PACKET];

    /// `void IPlayerPool::broadcastRPC(int, Span<uint8_t>, int, const IPlayer *, bool)`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    pub fn players_broadcast_rpc(
        pool: IPlayerPool,
        id: i32,
        data: Span<u8>,
        channel: i32,
        skip_from: *mut IPlayer,
        dispatch_events: bool,
    ) = [0, SLOT_BROADCAST_RPC];

    /// `bool IPlayerPool::isNameValid(StringView)`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    #[must_use]
    pub fn players_is_name_valid(
        pool: IPlayerPool,
        name: StringView,
    ) -> bool = [0, SLOT_IS_NAME_VALID] or false;

    /// `void IPlayerPool::allowNickNameCharacter(char, bool)`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    pub fn players_allow_nick_name_character(
        pool: IPlayerPool,
        character: i8,
        allow: bool,
    ) = [0, SLOT_ALLOW_NICK_NAME_CHARACTER];

    /// `bool IPlayerPool::isNickNameCharacterAllowed(char)`.
    ///
    /// # Safety
    /// `pool` must be a live `IPlayerPool`.
    #[must_use]
    pub fn players_is_nick_name_character_allowed(
        pool: IPlayerPool,
        character: i8,
    ) -> bool = [0, SLOT_IS_NICK_NAME_CHARACTER_ALLOWED] or false;
}

/// `Pair<NewConnectionResult, IPlayer *> IPlayerPool::requestPlayer(const PeerNetworkData &, const PeerRequestParams &)`.
///
/// # Safety
/// `pool` must be a live `IPlayerPool`.
#[must_use]
pub unsafe fn players_request_player(
    pool: *mut IPlayerPool,
    net_data: &PeerNetworkData,
    params: &PeerRequestParams,
) -> Option<Pair<i32, *mut IPlayer>> {
    call_vtable_small_struct!(pool.cast::<u8>(), 0, SLOT_REQUEST_PLAYER, Pair<i32, *mut IPlayer>, unsafe { std::mem::zeroed::<Pair<i32, *mut IPlayer>>() }, (&PeerNetworkData, &PeerRequestParams) (net_data, params))
}

/// `Colour IPlayerPool::getDefaultColour(int)`.
///
/// # Safety
/// `pool` must be a live `IPlayerPool`.
#[must_use]
pub unsafe fn players_default_colour(pool: *mut IPlayerPool, pid: i32) -> Option<Colour> {
    call_vtable_small_struct!(
        pool.cast::<u8>(),
        0,
        SLOT_GET_DEFAULT_COLOUR,
        Colour,
        Colour::default(),
        (i32)(pid)
    )
}

// What the generator left out, and why.
// skipped: `IEventDispatcher<PlayerSpawnEventHandler> & IPlayerPool::getPlayerSpawnDispatcher()` — `PlayerSpawnHandler` and its dispatcher are written by hand
// skipped: `IEventDispatcher<PlayerConnectEventHandler> & IPlayerPool::getPlayerConnectDispatcher()` — `PlayerConnectHandler` and its dispatcher are written by hand
// skipped: `IEventDispatcher<PlayerStreamEventHandler> & IPlayerPool::getPlayerStreamDispatcher()` — `PlayerStreamHandler` and its dispatcher are written by hand
// skipped: `IEventDispatcher<PlayerTextEventHandler> & IPlayerPool::getPlayerTextDispatcher()` — `PlayerTextHandler` and its dispatcher are written by hand
// skipped: `IEventDispatcher<PlayerShotEventHandler> & IPlayerPool::getPlayerShotDispatcher()` — `PlayerShotHandler` and its dispatcher are written by hand
// skipped: `IEventDispatcher<PlayerChangeEventHandler> & IPlayerPool::getPlayerChangeDispatcher()` — `PlayerChangeHandler` and its dispatcher are written by hand
// skipped: `IEventDispatcher<PlayerDamageEventHandler> & IPlayerPool::getPlayerDamageDispatcher()` — `PlayerDamageHandler` and its dispatcher are written by hand
// skipped: `IEventDispatcher<PlayerClickEventHandler> & IPlayerPool::getPlayerClickDispatcher()` — `PlayerClickHandler` and its dispatcher are written by hand
// skipped: `IEventDispatcher<PlayerCheckEventHandler> & IPlayerPool::getPlayerCheckDispatcher()` — `PlayerCheckHandler` and its dispatcher are written by hand
// skipped: `IEventDispatcher<PlayerUpdateEventHandler> & IPlayerPool::getPlayerUpdateDispatcher()` — `PlayerUpdateHandler` and its dispatcher are written by hand