[ChatBoxExtensions] Updated for the latest API.

This commit is contained in:
kafeijao 2023-04-26 19:38:28 +01:00
parent 62eb612d73
commit 37ad5a8f9c
No known key found for this signature in database
GPG key ID: E99978723E454B4C
9 changed files with 88 additions and 40 deletions

View file

@ -10,22 +10,22 @@ internal class ChatBoxCommands : CommandBase
DateTime pingTime = DateTime.MinValue; // store the time when "ping" command was sent
Commands.RegisterCommand("ping",
onCommandSent: (message, sound) =>
onCommandSent: (message, sound, displayMsg) =>
{
pingTime = DateTime.Now;
awaitingPing = true;
},
onCommandReceived: (sender, message, sound) =>
onCommandReceived: (sender, message, sound, displayMsg) =>
{
RemoteCommandListenForSelf(message, args =>
{
ChatBox.SendMessage("/pong " + GetPlayerUsername(sender), false);
API.SendMessage("/pong " + GetPlayerUsername(sender), false, true);
});
});
Commands.RegisterCommand("pong",
onCommandSent: null,
onCommandReceived: (sender, message, sound) =>
onCommandReceived: (sender, message, sound, displayMsg) =>
{
RemoteCommandListenForSelf(message, args =>
{
@ -33,11 +33,11 @@ internal class ChatBoxCommands : CommandBase
{
awaitingPing = false;
TimeSpan timeSincePing = DateTime.Now - pingTime; // calculate the time difference
ChatBox.SendMessage($"Time since ping: {timeSincePing.TotalMilliseconds}ms", false);
API.SendMessage($"Time since ping: {timeSincePing.TotalMilliseconds}ms", false, true);
return;
}
ChatBox.SendMessage($"You have to ping first, {GetPlayerUsername(sender)}!", false);
API.SendMessage($"You have to ping first, {GetPlayerUsername(sender)}!", false, true);
});
});
}
}
}