From 47e23d4e83ad40fc45e22bca885d5a89d91150e6 Mon Sep 17 00:00:00 2001 From: DryByte <93609026+DryByte@users.noreply.github.com> Date: Mon, 16 Feb 2026 18:26:58 -0300 Subject: [PATCH 1/4] update example in README.md --- README.md | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 94b8214..29a1c9f 100644 --- a/README.md +++ b/README.md @@ -45,25 +45,47 @@ This library provides a complete C API for open.mp server functionality, allowin ```c #include "ompcapi.h" +#include struct OMPAPI_t api; -int main() -{ - // Initialize the API - this loads the $CAPI library and all functions - if (!omp_initialize_capi(&api)) - { - // Initialization failed - library not found or functions couldn't be loaded - printf("Failed to initialize open.mp C API\n"); - return 1; - } +void on_ready_callback() { + api.Core.Log("Example - Ready callback"); // Now you can use the API // Example: Create an actor int actor_id; void* actor = api.Actor.Create(123, 0.0f, 0.0f, 3.0f, 0.0f, &actor_id); - return 0; + // The CAPI doesn't support passing vargs, so you need to format it + // before calling the Log function from the API + char actor_msg[512]; + + sprintf(actor_msg, "Created actor with ID: %i (at address 0x%x)", actor_id, actor); + api.Core.Log(actor_msg); +} + +void on_reset_callback() { + api.Core.Log("Example - Reset callback"); +} + +void on_free_callback() { + api.Core.Log("Example - Free callback"); +} + +void ComponentEntryPoint() { + if (!omp_initialize_capi(&api)) + { + // Initialization failed - library not found or functions couldn't be loaded + printf("Failed to initialize open.mp C API\n"); + return; + } + + // Link the IComponent basic informations + // UID, Component Name, Version, Callbacks + api.Component.Create(0x17C581AEC8711DD9, "Example", (struct ComponentVersion){ + 1, 0, 0, 0 + }, on_ready_callback, on_reset_callback, on_free_callback); } ``` From 860a5e1443b908c0b84f19ea6965176d83e732d1 Mon Sep 17 00:00:00 2001 From: DryByte <93609026+DryByte@users.noreply.github.com> Date: Mon, 16 Feb 2026 18:30:04 -0300 Subject: [PATCH 2/4] update project structure --- README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 29a1c9f..16bf0da 100644 --- a/README.md +++ b/README.md @@ -115,13 +115,16 @@ The complete API documentation is available in the `apidocs/` directory: ``` open.mp-capi/ ├── include/ -│ └── ompcapi.h # Main header file with complete API +│ └── ompcapi.h # Main header file with complete API ├── apidocs/ -│ ├── api.json # API function specifications -│ └── events.json # Event system specifications -├── CMakeLists.txt # CMake configuration -├── LICENSE.md # Mozilla Public License 2.0 -└── README.md # This file +│ ├── api.json # API function specifications +│ └── events.json # Event system specifications +├── tools/ +│ ├── generate_docs.js # Generate the api.json file +│ └── generate_single_header.js # Generate the ompcapi.h if you cloned the main open.mp repository +├── CMakeLists.txt # CMake configuration +├── LICENSE.md # Mozilla Public License 2.0 +└── README.md # This file ``` ## License From 1fc0762e315dde5df0c6a85ef17d0c53fb262d53 Mon Sep 17 00:00:00 2001 From: DryByte <93609026+DryByte@users.noreply.github.com> Date: Mon, 16 Feb 2026 18:34:17 -0300 Subject: [PATCH 3/4] update library link name in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 16bf0da..acc0083 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ Add this repository as a subdirectory: ```cmake add_subdirectory(open.mp-capi) -target_link_libraries(your_component PRIVATE ompcapi) +target_link_libraries(your_component PRIVATE OMP-CAPI) ``` ## API Documentation From 0f501151015c15dee6ed11dee9c332f3646c077d Mon Sep 17 00:00:00 2001 From: sByte <93609026+DryByte@users.noreply.github.com> Date: Tue, 17 Feb 2026 09:51:53 -0300 Subject: [PATCH 4/4] Use brackets instead of quotes for ompcapi.h Since the file isn't in the same folder, doesn't make sense to use quotes instead of brackets. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index acc0083..32f2e78 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ This library provides a complete C API for open.mp server functionality, allowin 2. Initialize the API by creating an `OMPAPI_t` instance and calling `omp_initialize_capi`: ```c -#include "ompcapi.h" +#include #include struct OMPAPI_t api; @@ -129,4 +129,4 @@ open.mp-capi/ ## License -This project is licensed under the Mozilla Public License Version 2.0. See [LICENSE.md](LICENSE.md) for details. \ No newline at end of file +This project is licensed under the Mozilla Public License Version 2.0. See [LICENSE.md](LICENSE.md) for details.