NAK_CVR_Mods/.Deprecated/ChatBoxExtensions/Integrations/PlayerRagdollMod.cs
2025-04-03 03:03:24 -05:00

89 lines
2.7 KiB
C#

using ml_prm;
namespace NAK.ChatBoxExtensions.Integrations;
internal class PlayerRagdollModCommands : CommandBase
{
public static void RegisterCommands()
{
Commands.RegisterCommand("unragdoll",
onCommandSent: (message, sound, displayMsg) =>
{
LocalCommandIgnoreOthers(message, (args) =>
{
if (RagdollController.Instance.IsRagdolled())
{
RagdollController.Instance.SwitchRagdoll();
}
});
},
onCommandReceived: (sender, message, sound, displayMsg) =>
{
RemoteCommandListenForAll(message, (args) =>
{
if (RagdollController.Instance.IsRagdolled())
{
RagdollController.Instance.SwitchRagdoll();
}
});
});
Commands.RegisterCommand("ragdoll",
onCommandSent: (message, sound, displayMsg) =>
{
LocalCommandIgnoreOthers(message, (args) =>
{
bool switchRagdoll = true;
if (args.Length > 0 && bool.TryParse(args[0], out bool state))
{
switchRagdoll = state != RagdollController.Instance.IsRagdolled();
}
if (switchRagdoll)
{
RagdollController.Instance.SwitchRagdoll();
}
});
},
onCommandReceived: (sender, message, sound, displayMsg) =>
{
RemoteCommandListenForAll(message, (args) =>
{
bool switchRagdoll = true;
if (args.Length > 1 && bool.TryParse(args[1], out bool state))
{
switchRagdoll = state != RagdollController.Instance.IsRagdolled();
}
if (switchRagdoll)
{
RagdollController.Instance.SwitchRagdoll();
}
});
});
Commands.RegisterCommand("kill",
onCommandSent: (message, sound, displayMsg) =>
{
LocalCommandIgnoreOthers(message, (args) =>
{
if (!RagdollController.Instance.IsRagdolled())
{
RagdollController.Instance.SwitchRagdoll();
}
});
},
onCommandReceived: (sender, message, sound, displayMsg) =>
{
RemoteCommandListenForAll(message, (args) =>
{
if (!RagdollController.Instance.IsRagdolled())
{
RagdollController.Instance.SwitchRagdoll();
}
});
});
}
}