Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复: 玩家死亡时退出无法正常播报死亡倒计时的问题 #100

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ServerTools/Plugin.Online.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ private void _OnLeave(LeaveEventArgs args)
private void OnGreet(GreetPlayerEventArgs args)
{
var ply = TShock.Players[args.Who];
if(ply != null)
if (ply != null)
{
ActivePlayers.Add(ply);
ply.RespawnTimer = 0;
}

}

private void OnUpdatePlayerOnline(EventArgs args)
Expand Down
8 changes: 7 additions & 1 deletion ServerTools/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using MonoMod.RuntimeDetour;
using System.ComponentModel;
using Terraria;
using Terraria.GameContent.Creative;
using TerrariaApi.Server;
Expand Down Expand Up @@ -56,6 +55,7 @@ public override void Initialize()

#region 指令
Commands.ChatCommands.Add(new Command(Permissions.clear, Clear, "clp"));
Commands.ChatCommands.Add(new Command("servertool.query.exit", Exit, "退出"));
Commands.ChatCommands.Add(new Command("servertool.query.wall", WallQ, "查花苞"));
Commands.ChatCommands.Add(new Command("servertool.query.wall", RWall, "移除花苞"));
Commands.ChatCommands.Add(new Command("servertool.user.kick", SelfKick, "自踢"));
Expand Down Expand Up @@ -83,6 +83,11 @@ public override void Initialize()
HandleCommandLine(Environment.GetCommandLineArgs());
}

private void Exit(CommandArgs args)
{
args.Player.SendData(PacketTypes.ChestOpen, "", args.Player.Index, -1);
}

public static bool CommandHook(TSPlayer ply, string cmd)
{
CmdHook.Undo();
Expand Down Expand Up @@ -167,6 +172,7 @@ private void OnLeave(LeaveEventArgs args)
var ply = TShock.Players[args.Who];
if (ply == null)
return;
Deads.Remove(ply);
if (ply.Dead)
PlayerDeath[ply.Name] = DateTime.Now.AddSeconds(ply.RespawnTimer);
}
Expand Down
Loading