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
//! `ICustomModelsComponent` — generated by `cargo xtask gen-omp` from `Server/Components/CustomModels/custommodels.hpp`.
//! Implemented by `CustomModelsComponent` in the server's `CustomModels`.
//!
//! 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::*;

opaque! {
    /// Opaque handle for `ICustomModelsComponent*`.
    pub ICustomModelsComponent;
}

/// `ModelsComponent_UID` in `Server/Components/CustomModels/custommodels.hpp`.
pub const CUSTOM_MODELS_COMPONENT_UID: UID = 0x15e3cb1e7c77ffff;

impl ComponentInterface for ICustomModelsComponent {
    const UID: UID = CUSTOM_MODELS_COMPONENT_UID;
}

slots! {
    /// `bool ICustomModelsComponent::addCustomModel(ModelType, int32_t, int32_t, StringView, StringView, int32_t, uint8_t, uint8_t)`
    SLOT_ADD_CUSTOM_MODEL: usize = 18, 16;
    /// `bool ICustomModelsComponent::getBaseModel(uint32_t &, uint32_t &)`
    SLOT_GET_BASE_MODEL: usize = 19, 17;
    /// `IEventDispatcher<PlayerModelsEventHandler> & ICustomModelsComponent::getEventDispatcher()`
    SLOT_GET_EVENT_DISPATCHER: usize = 20, 18;
    /// `StringView ICustomModelsComponent::getModelNameFromChecksum(uint32_t)`
    SLOT_GET_MODEL_NAME_FROM_CHECKSUM: usize = 21, 19;
    /// `bool ICustomModelsComponent::isValidCustomModel(int32_t)`
    SLOT_IS_VALID_CUSTOM_MODEL: usize = 22, 20;
    /// `bool ICustomModelsComponent::getCustomModelPath(int32_t, StringView &, StringView &)`
    SLOT_GET_CUSTOM_MODEL_PATH: usize = 23, 21;
}

virtual_fns! {
    /// `bool ICustomModelsComponent::addCustomModel(ModelType, int32_t, int32_t, StringView, StringView, int32_t, uint8_t, uint8_t)`.
    ///
    /// # Safety
    /// `component` must be a live `ICustomModelsComponent`.
    #[must_use]
    pub fn custom_models_add_custom_model(
        component: ICustomModelsComponent,
        type_value: u8,
        id: i32,
        base_id: i32,
        dff_name: StringView,
        txd_name: StringView,
        virtual_world: i32,
        time_on: u8,
        time_off: u8,
    ) -> bool = [0, SLOT_ADD_CUSTOM_MODEL] or false;

    /// `bool ICustomModelsComponent::getBaseModel(uint32_t &, uint32_t &)`.
    ///
    /// # Safety
    /// `component` must be a live `ICustomModelsComponent`.
    #[must_use]
    pub fn custom_models_base_model(
        component: ICustomModelsComponent,
        base_model_id_or_input: &mut u32,
        custom_model: &mut u32,
    ) -> bool = [0, SLOT_GET_BASE_MODEL] or false;

    /// `IEventDispatcher<PlayerModelsEventHandler> & ICustomModelsComponent::getEventDispatcher()`.
    ///
    /// # Safety
    /// `component` must be a live `ICustomModelsComponent`.
    #[must_use]
    pub fn custom_models_event_dispatcher(
        component: ICustomModelsComponent,
    ) -> *mut EventDispatcher<PlayerModelsHandler> = [0, SLOT_GET_EVENT_DISPATCHER] or std::ptr::null_mut();

    /// `bool ICustomModelsComponent::isValidCustomModel(int32_t)`.
    ///
    /// # Safety
    /// `component` must be a live `ICustomModelsComponent`.
    #[must_use]
    pub fn custom_models_is_valid_custom_model(
        component: ICustomModelsComponent,
        model_id: i32,
    ) -> bool = [0, SLOT_IS_VALID_CUSTOM_MODEL] or false;

    /// `bool ICustomModelsComponent::getCustomModelPath(int32_t, StringView &, StringView &)`.
    ///
    /// # Safety
    /// `component` must be a live `ICustomModelsComponent`.
    #[must_use]
    pub fn custom_models_custom_model_path(
        component: ICustomModelsComponent,
        model_id: i32,
        dff_path: &mut StringView,
        txd_path: &mut StringView,
    ) -> bool = [0, SLOT_GET_CUSTOM_MODEL_PATH] or false;
}

/// `StringView ICustomModelsComponent::getModelNameFromChecksum(uint32_t)`.
///
/// # Safety
/// `component` must be a live `ICustomModelsComponent`.
#[must_use]
pub unsafe fn custom_models_model_name_from_checksum(
    component: *mut ICustomModelsComponent,
    checksum: u32,
) -> Option<String> {
    let view = call_vtable_small_struct!(
        component.cast::<u8>(),
        0,
        SLOT_GET_MODEL_NAME_FROM_CHECKSUM,
        StringView,
        StringView::EMPTY,
        (u32)(checksum)
    )?;
    unsafe { view.to_owned_string() }
}