mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
push broken mod
This commit is contained in:
parent
742f816d3d
commit
344e3bb6d6
12 changed files with 500 additions and 0 deletions
43
ChatBoxExtensions/Integrations/ChatBox.cs
Normal file
43
ChatBoxExtensions/Integrations/ChatBox.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using Kafe.ChatBox;
|
||||
|
||||
namespace NAK.Melons.ChatBoxExtensions.Integrations;
|
||||
|
||||
internal class ChatBoxCommands : CommandBase
|
||||
{
|
||||
public static void RegisterCommands()
|
||||
{
|
||||
bool awaitingPing = false;
|
||||
DateTime pingTime = DateTime.MinValue; // store the time when "ping" command was sent
|
||||
|
||||
Commands.RegisterCommand("ping",
|
||||
onCommandSent: (message, sound) =>
|
||||
{
|
||||
pingTime = DateTime.Now;
|
||||
awaitingPing = true;
|
||||
},
|
||||
onCommandReceived: (sender, message, sound) =>
|
||||
{
|
||||
RemoteCommandListenForSelf(message, args =>
|
||||
{
|
||||
ChatBox.SendMessage("/pong " + GetPlayerUsername(sender), false);
|
||||
});
|
||||
});
|
||||
|
||||
Commands.RegisterCommand("pong",
|
||||
onCommandSent: null,
|
||||
onCommandReceived: (sender, message, sound) =>
|
||||
{
|
||||
RemoteCommandListenForSelf(message, args =>
|
||||
{
|
||||
if (awaitingPing)
|
||||
{
|
||||
awaitingPing = false;
|
||||
TimeSpan timeSincePing = DateTime.Now - pingTime; // calculate the time difference
|
||||
ChatBox.SendMessage($"Time since ping: {timeSincePing.TotalMilliseconds}ms", false);
|
||||
return;
|
||||
}
|
||||
ChatBox.SendMessage($"You have to ping first, {GetPlayerUsername(sender)}!", false);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue