I hate cobalt: cobaltSysChar!!!!!!!!!

This commit is contained in:
Maxim Khomutov 2023-07-24 04:54:55 +03:00
parent 6ccbe99d47
commit d92aae7c47
3 changed files with 3 additions and 36 deletions

View File

@ -11,18 +11,7 @@ KiuToi几乎完全支持BeamMP的lua插件所有必要的方法都已经创
#### Cobalt Essentials V1.7.5(免费,[github ↗](https://github.com/prestonelam2003/CobaltEssentials/) #### Cobalt Essentials V1.7.5(免费,[github ↗](https://github.com/prestonelam2003/CobaltEssentials/)
1. 要获取`pluginPath`,需要:`debug.getinfo(1).source:gsub("\\","/")` => `debug.getinfo(1).source:gsub("\\","/"):gsub("@", "")`,因为路径返回值中包含`@`,这破坏了插件。 1. 要获取`pluginPath`,需要:`debug.getinfo(1).source:gsub("\\","/")` => `debug.getinfo(1).source:gsub("\\","/"):gsub("@", "")`,因为路径返回值中包含`@`,这破坏了插件。
2. 必须将所有的`require()`移动到`onInit`之后。 2. `cobaltSysChar`
3. 在某些情况下,必须在函数声明之后注册`MP.RegisterEvent`,即:
```lua
--这样不正确,可能无法注册
MP.RegisterEvent("onPlayerAuth","onPlayerAuth")
function onPlayerAuth(name, role, isGuest)
-- Some plugin code
end
--这样就可以了
MP.RegisterEvent("onPlayerAuth","onPlayerAuth")
```
### 工作原理 ### 工作原理

View File

@ -11,18 +11,7 @@ KiuToi does not support: `MP.Set()`
#### Cobalt Essentials V1.7.5 (Free, [github](https://github.com/prestonelam2003/CobaltEssentials/)) #### 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. 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`. 2. `cobaltSysChar`
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")
```
### A Little About How it Works ### A Little About How it Works

View File

@ -11,18 +11,7 @@
#### Cobalt Essentials V1.7.5 (Бесплатный, [github](https://github.com/prestonelam2003/CobaltEssentials/)) #### Cobalt Essentials V1.7.5 (Бесплатный, [github](https://github.com/prestonelam2003/CobaltEssentials/))
1. Для получения `pluginPath` нужно: `debug.getinfo(1).source:gsub("\\","/")` => `debug.getinfo(1).source:gsub("\\","/"):gsub("@", "")` так как пусть возвращается с `@`, что сломало плагин. 1. Для получения `pluginPath` нужно: `debug.getinfo(1).source:gsub("\\","/")` => `debug.getinfo(1).source:gsub("\\","/"):gsub("@", "")` так как пусть возвращается с `@`, что сломало плагин.
2. Пришлось перенести все `require()` за `onInit` 2. `cobaltSysChar`
3. В некоторых моментах пришлось перенести `MP.RegisterEvent` уже после объявления функции, т.е.:
```lua
--Вот так не правильно, может не пройти регистрация
MP.RegisterEvent("onPlayerAuth","onPlayerAuth")
function onPlayerAuth(name, role, isGuest)
-- Some plugin code
end
--Вот такой вариант пройдёт
MP.RegisterEvent("onPlayerAuth","onPlayerAuth")
```
### Немного о принципе работы ### Немного о принципе работы