Skip to content

Commit

Permalink
I hate cobalt: cobaltSysChar!!!!!!!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
SantaSpeen committed Jul 24, 2023
1 parent 6ccbe99 commit d92aae7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 36 deletions.
13 changes: 1 addition & 12 deletions docs/cn/plugins/lua/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,7 @@ KiuToi几乎完全支持BeamMP的lua插件,所有必要的方法都已经创
#### Cobalt Essentials V1.7.5(免费,[github ↗](https://github.com/prestonelam2003/CobaltEssentials/)

1. 要获取`pluginPath`,需要:`debug.getinfo(1).source:gsub("\\","/")` => `debug.getinfo(1).source:gsub("\\","/"):gsub("@", "")`,因为路径返回值中包含`@`,这破坏了插件。
2. 必须将所有的`require()`移动到`onInit`之后。
3. 在某些情况下,必须在函数声明之后注册`MP.RegisterEvent`,即:
```lua
--这样不正确,可能无法注册
MP.RegisterEvent("onPlayerAuth","onPlayerAuth")
function onPlayerAuth(name, role, isGuest)
-- Some plugin code
end

--这样就可以了
MP.RegisterEvent("onPlayerAuth","onPlayerAuth")
```
2. `cobaltSysChar`

### 工作原理

Expand Down
13 changes: 1 addition & 12 deletions docs/en/plugins/lua/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,7 @@ KiuToi does not support: `MP.Set()`
#### Cobalt Essentials V1.7.5 (Free, [github](https://github.com/prestonelam2003/CobaltEssentials/))

1. To obtain `pluginPath`, use: `debug.getinfo(1).source:gsub("\\","/")` => `debug.getinfo(1).source:gsub("\\","/"):gsub("@", "")` as the path returns with `@`, which broke the plugin.
2. All `require()` statements had to be moved after `onInit`.
3. In some cases, `MP.RegisterEvent` had to be moved after the function declaration, i.e.:
```lua
--This is incorrect, registration may fail
MP.RegisterEvent("onPlayerAuth","onPlayerAuth")
function onPlayerAuth(name, role, isGuest)
-- Some plugin code
end

--This is the correct version
MP.RegisterEvent("onPlayerAuth","onPlayerAuth")
```
2. `cobaltSysChar`

### A Little About How it Works

Expand Down
13 changes: 1 addition & 12 deletions docs/ru/plugins/lua/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,7 @@
#### Cobalt Essentials V1.7.5 (Бесплатный, [github](https://github.com/prestonelam2003/CobaltEssentials/))

1. Для получения `pluginPath` нужно: `debug.getinfo(1).source:gsub("\\","/")` => `debug.getinfo(1).source:gsub("\\","/"):gsub("@", "")` так как пусть возвращается с `@`, что сломало плагин.
2. Пришлось перенести все `require()` за `onInit`
3. В некоторых моментах пришлось перенести `MP.RegisterEvent` уже после объявления функции, т.е.:
```lua
--Вот так не правильно, может не пройти регистрация
MP.RegisterEvent("onPlayerAuth","onPlayerAuth")
function onPlayerAuth(name, role, isGuest)
-- Some plugin code
end

--Вот такой вариант пройдёт
MP.RegisterEvent("onPlayerAuth","onPlayerAuth")
```
2. `cobaltSysChar`

### Немного о принципе работы

Expand Down

0 comments on commit d92aae7

Please sign in to comment.