dp-s_doc/Start/Example/7.md

48 lines
1.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 公会讲话互通 (贡献者: 凌众)
> 首先我们先在dp_s文件夹中建立一个项目文件夹 MyProject 方便管理
![Alt text](../../image/6.png)
> 然后我们建立一个新文件 公会讲话互通.nut 用于编写我们的代码
![Alt text](../../image/28.png)
> 然后我们在公会讲话互通.nut中写入以下代码
```
//本例子由凌众提供
//输入hook
Cb_Server_Chat_Log_Leave_Func.RindroGHHT <- function(args) {
local type = args[2];
local SUser = User(args[1]);
local msg = args[3];
if (type == 6) {
local guildName = SUser.GetGuildName();
local name = SUser.GetCharacName();
//遍历在线玩家
local users = World.GetOnlinePlayer()
users.apply(function(Value) {
local onguildName = Value.GetGuildName();
if (guildName != onguildName) {
Value.SendNotiPacketMessage(name + "[" + guildName + "] " + msg, 6)
}
});
}
return null;
}
```
> 最后我们回到dp_s文件夹中打开Main.nut 加载我们刚才编写的逻辑
```
sq_RunScript("MyProject/公会讲话互通.nut");
```
> 至此一个简单的公会讲话互通的逻辑就写完了,这样其他公会的人也能互相看到了