mirror of
https://github.com/kuitoi/kuitoi-Server.git
synced 2026-04-14 11:56:16 +00:00
Add cn translations
This commit is contained in:
27
docs/cn/plugins/lua/example.lua
Normal file
27
docs/cn/plugins/lua/example.lua
Normal file
@@ -0,0 +1,27 @@
|
||||
print("example.lua")
|
||||
|
||||
--CreateTimer Testing
|
||||
local mytimer = MP.CreateTimer()
|
||||
--.--.--.--.--.--.--.
|
||||
|
||||
--GetOSName Testing
|
||||
print("OS Name: "..MP.GetOSName())
|
||||
--.--.--.--.--.--.-
|
||||
|
||||
--GetServerVersion Testing
|
||||
local major, minor, patch = MP.GetServerVersion()
|
||||
print("Server Version: "..major.."."..minor.."."..patch)
|
||||
--.--.--.--.--.--.--.--.--
|
||||
|
||||
--Events Testing--
|
||||
function handleChat(player_id, player_name, message)
|
||||
print("Lua handleChat:", player_id, player_name, message, "; Uptime: "..mytimer:GetCurrent())
|
||||
return 1
|
||||
end
|
||||
|
||||
MP.RegisterEvent("onChatMessage", "handleChat")
|
||||
--.--.--.--.--.--.
|
||||
|
||||
function onInit()
|
||||
print("Initializing ready!")
|
||||
end
|
||||
35
docs/cn/plugins/lua/readme.md
Normal file
35
docs/cn/plugins/lua/readme.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# BeamMP Lua反馈支持
|
||||
|
||||
KiuToi几乎完全支持BeamMP的lua插件,所有必要的方法都已经创建,测试显示以下细节:
|
||||
|
||||
在KiuToi中没有支持:`MP.Set()`
|
||||
|
||||
#### Economic Rework V2.0(付费,Discord(RU):[Hlebushek](https://discordapp.com/users/449634697593749516))
|
||||
|
||||
1. 要获取`pluginPath`,需要:`debug.getinfo(1).source:gsub("\\","/")` => `debug.getinfo(1).source:gsub("\\","/"):gsub("@", "")`,因为路径返回值中包含`@`,这破坏了插件。
|
||||
|
||||
#### 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")
|
||||
```
|
||||
|
||||
### 工作原理
|
||||
|
||||
插件加载经过几个阶段:
|
||||
|
||||
1. 扫描`plugins/`文件夹
|
||||
2. 如果文件夹不在PyPlugins中,并且文件夹中存在`*.lua`,则添加它,例如`plugins/LuaPlugin`
|
||||
3. 然后从该文件夹中进行`lua.loadfile({filename})`(这是lua中的标准方法)
|
||||
4. 最后调用事件和函数`onInit()`
|
||||
5. 如果在执行`onInit()`期间没有发生错误,则可以通过`lua_plugins`命令看到这样的消息:`Lua plugins: LuaPlugin:ok`
|
||||
Reference in New Issue
Block a user