Skip to content

Commit

Permalink
docs(plugin): update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dockfries committed Feb 15, 2024
1 parent 281b3bc commit 8d2e1ed
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/.vitepress/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const en_US = defineConfig({
sidebar: [
{ base: "/", text: "Getting Started", items: sidebarGuide() },
{ base: "/essentials/", text: "Essentials", items: sidebarEssentials() },
{ base: "/plugins/", text: "Plugins", items: sidebarPlugins() },
],

editLink: {
Expand Down Expand Up @@ -67,3 +68,7 @@ function sidebarEssentials(): DefaultTheme.SidebarItem[] {
{ text: "Use", link: "use" },
];
}

function sidebarPlugins(): DefaultTheme.SidebarItem[] {
return [{ text: "Introduction", link: "introduction" }];
}
5 changes: 5 additions & 0 deletions docs/.vitepress/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const zh_CN = defineConfig({
text: "基础",
items: sidebarEssentials(),
},
{ base: "/zh-CN/plugins/", text: "插件", items: sidebarPlugins() },
],

editLink: {
Expand Down Expand Up @@ -82,6 +83,10 @@ function sidebarEssentials(): DefaultTheme.SidebarItem[] {
];
}

function sidebarPlugins(): DefaultTheme.SidebarItem[] {
return [{ text: "介绍", link: "introduction" }];
}

export const search = {
"zh-CN": {
translations: {
Expand Down
28 changes: 28 additions & 0 deletions docs/plugins/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Plugins

## Necessary work

::: warning
You must place `samp-node` after other plugins in `pawn.legacy_plugins` to ensure that other plugins are loaded first.
:::

If you need to use legacy plugins, you must place the plugin's `dll/so` file in the `plugins` folder, configure it in the `config.json` file under `pawn.legacy_plugins`, and include the `.inc` files of these plugins through `pawno/qawno`. Then, modify `pawn.main_scripts` to point to the `.amx` file you compiled.

Due to the various possible combinations of plugins, `infernus-starter` only includes common versions without `raknet` and versions with `raknet`.

If you are not able to use the plugins correctly, you will usually receive error messages similar to the following during server startup, and some plugins may have runtime issues:

```
[Error] Function not registered: CA_DestroyObject
[Error] File or function is not found
```

## Wrapper development

For the implementation of wrappers, please refer to the relevant code of `infernus` and the `samp-node` `wiki`.

Due to the underlying implementation of plugins or `samp-node` or `sampgdk` or `omp`, you may not be able to directly call `native` functions of `plugins/omp components` using `samp-node`, or directly register callback functions.

For example, `raknet` cannot be called directly, so `infernus` took a detour and implemented the call through a `polyfill`.

If you encounter similar issues when developing wrappers, you may need to refer to the `polyfill` implementation for `raknet` to work around the problem, unless someday in the future `samp-node` and other ecosystems become fully compatible with `omp`.
28 changes: 28 additions & 0 deletions docs/zh-CN/plugins/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 插件

## 必要工作

::: warning
您必须在`pawn.legacy_plugins``samp-node` 放到其他插件的后面,以确保其他插件先加载。
:::

如果您需要用到传统的插件,您必须像传统的原生开发那样,将插件的 `dll/so` 放入 `plugins` 文件夹,然后在`config.json`中配置`pawn.legacy_plugins`,并且通过 `pawno/qawno` 引入这些插件的`.inc` 文件,然后修改`pawn.main_scripts`为您编译的`.amx`文件。

由于插件有数种搭配可能性,所以`infernus-starter`只组合了常见的无 `raknet` 和带 `raknet` 的版本。

如果您没能以正确的方式使用插件,在服务器启动时通常你会收到类似的错误信息,也有一些插件是由于运行时的问题。

```
[Error] Function not registered: CA_DestroyObject
[Error] File or function is not found
```

## 包装开发

有关包装的实现请参考 `infernus` 的相关代码和 `samp-node``wiki`

由于一些可能是插件或`samp-node`,或`sampgdk`,又或是`omp`的底层实现,您有可能无法直接使用 `samp-node` 调用到插件/`omp` 组件的`native`函数,也可能无法直接注册回调函数。

例如 `raknet`无法被直接调用,所以`infernus`绕了很大的弯路,通过`polyfill`来实现调用。

如果您开发包装遇到类似的问题,可能需要参考 `raknet``polyfill` 绕弯路来实现,除非未来的某一天 `samp-node`和其他生态可以完全兼容`omp`

0 comments on commit 8d2e1ed

Please sign in to comment.