添加插件: 设置重生点 1.0.0.1#273
Conversation
BedSet/Class1.cs
Outdated
There was a problem hiding this comment.
这文件名改一下不要。Class1.cs
BedSet/Class1.cs
Outdated
| { | ||
| GetDataHandlers.PlayerUpdate.Register(backbed);//使用回城物品 set | ||
| PlayerHooks.PlayerPostLogin += PlayerHooks_PlayerPostLogin;//登录返回床位置 login | ||
| GetDataHandlers.KillMe.Register(deadafter);//死亡返回床位置 death |
There was a problem hiding this comment.
不知道,不过改了之后用起来挺怪
应该放到Spawn事件处理,这样写不会一死就复活吧。
There was a problem hiding this comment.
不知道,不过改了之后用起来挺怪
应该放到Spawn事件处理,这样写不会一死就复活吧。
没一死就复活吧,毕竟我写了个while等着玩家复活(
There was a problem hiding this comment.
不知道,不过改了之后用起来挺怪
应该放到Spawn事件处理,这样写不会一死就复活吧。
测试了下只用spawn的,最大缺点是得等魔镜之类的使用时间结束才触发
第二只能把传送位置,记录位置,和清除位置放一起
1.先记录后传送,重进后马上记录了出生地而非床位置,直接废弃
2.先传送后记录,第一次会先传送到床位置清除再记录,但第二次甚至之后依旧只能传送到第一次传送的地方
因为没接触过spawn事件所以以上特性在我写的时候都没遇到(
There was a problem hiding this comment.
不知道,不过改了之后用起来挺怪
应该放到Spawn事件处理,这样写不会一死就复活吧。
测试了下只用spawn的,最大缺点是得等魔镜之类的使用时间结束才触发 第二只能把传送位置,记录位置,和清除位置放一起 1.先记录后传送,重进后马上记录了出生地而非床位置,直接废弃 2.先传送后记录,第一次会先传送到床位置清除再记录,但第二次甚至之后依旧只能传送到第一次传送的地方
因为没接触过spawn事件所以以上特性在我写的时候都没遇到(
1不在第1次触发时触发,2只在第1次触发可以互补,不过写起来应该和单独分成3个钩没差多少了
There was a problem hiding this comment.
PlayerSpawnContext判断这个
BedSet/Class1.cs
Outdated
| ) | ||
| { | ||
| await Task.Delay(300); | ||
| string path = $@".\重生点\{e.Player.Name}{Main.worldName}重生点.txt"; |
There was a problem hiding this comment.
?
路径用Path.Combine弄个变量
There was a problem hiding this comment.
? 路径用Path.Combine弄个变量
{e.Player.Name}{Main.worldName}已经是变量吧
There was a problem hiding this comment.
? 路径用Path.Combine弄个变量
{e.Player.Name}{Main.worldName}已经是变量吧
你不觉得重复太多代码了吗
正常做法是把这路径作为类属性使用。
There was a problem hiding this comment.
现在有个问题
你用魔境之类的物品去记录出生点
如果重进后魔晶的出生点依然是默认的点,当人物再次使用魔晶,那你是记录新的点还是传送到已经记录的点,如果记录新的点,OK那就变成记录世界默认出生点了,如果传送到已经记录的点那你这个魔境记录点变得没意义了,用死亡记录的话也有这种问题,所以这个解决方案不是一个好的方法。
BedSet/Class1.cs
Outdated
| } | ||
| if (!File.Exists(path)) | ||
| { | ||
| FileStream bed = File.Create($@".\重生点\{e.Player.Name}{Main.worldName}重生点.txt"); |
BedSet/Class1.cs
Outdated
| ) | ||
| ) | ||
| { | ||
| await Task.Delay(300); |
BedSet/Class1.cs
Outdated
| //login | ||
| private async void PlayerHooks_PlayerPostLogin(PlayerPostLoginEventArgs e) | ||
| { | ||
| while (true) |
BedSet/Class1.cs
Outdated
| { | ||
| if (disposing) | ||
| { | ||
| var asm = Assembly.GetExecutingAssembly(); |
BedSet/Class1.cs
Outdated
| if (disposing) | ||
| { | ||
| var asm = Assembly.GetExecutingAssembly(); | ||
| Commands.ChatCommands.RemoveAll(c => c.CommandDelegate.Method?.DeclaringType?.Assembly == asm); |
BedSet/Class1.cs
Outdated
BedSet/Class1.cs
Outdated
| } | ||
| } | ||
| //login | ||
| private async void PlayerHooks_PlayerPostLogin(PlayerPostLoginEventArgs e) |
BedSet/Class1.cs
Outdated
| await Task.Delay(1000); | ||
| if (e.Player.X != 0) | ||
| { | ||
| string path = $@".\重生点\{e.Player.Name}{Main.worldName}重生点.txt"; |
There was a problem hiding this comment.
这种SQL存可能会更好,而且路径不要放中文,不然任意爆掉,不要用worldName,用WorldID,也不要用PlayerName,用AccountID
BedSet/Class1.cs
Outdated
| private async void deadafter(object? sender, GetDataHandlers.KillMeEventArgs e) | ||
| { | ||
| while (true) | ||
| { |
BedSet/Class1.cs
Outdated
| { | ||
| await Task.Delay(500); | ||
| if (e.Player.Dead == false) | ||
| { |
There was a problem hiding this comment.
读取保存位置建议单独出一个方法,这里重复太多了,而且位置必须缓存
There was a problem hiding this comment.
读取保存位置建议单独出一个方法,这里重复太多了,而且位置必须缓存
位置确实)考虑到一个人物逛多个地图的情况
There was a problem hiding this comment.
不是,你缓存到内存里,不要一直从磁盘读数据,一般是建议服务器启动和Reload的时候才从文件读,其余全放内存里
|
如果改不来,可以把能改的先改了,等羽学giegie帮你优化 :( |
桀桀桀 |
|
我拉下来给你改了,然后你自己测 |
|
感觉会有一些别的问题 |
比如已经用魔晶记录了下次用魔晶是记录还是传送 |
No description provided.