Files
EndlessHostRoles/Roles/Standard/Addons/Common/Talkative.cs
T
2026-04-16 09:31:43 +02:00

33 lines
1.2 KiB
C#

using System.Collections.Generic;
namespace EHR.Roles;
public class Talkative : IAddon
{
public AddonTypes Type => AddonTypes.Harmful;
private static OptionItem MaxMessagesPerMeeting;
public static Dictionary<byte, int> NumMessagesThisMeeting = [];
public void SetupCustomOption()
{
Options.SetupAdtRoleOptions(658050, CustomRoles.Talkative, canSetNum: true, teamSpawnOptions: true);
MaxMessagesPerMeeting = new IntegerOptionItem(658060, "Talkative.MaxMessagesPerMeeting", new(1, 100, 1), 5, TabGroup.Addons)
.SetParent(Options.CustomRoleSpawnChances[CustomRoles.Talkative])
.SetValueFormat(OptionFormat.Times);
}
public static void OnMessageSend(PlayerControl player)
{
if (NumMessagesThisMeeting.TryGetValue(player.PlayerId, out int sent) && sent >= MaxMessagesPerMeeting.GetInt())
{
player.RpcGuesserMurderPlayer();
Utils.SendMessage(string.Format(Translator.GetString("Talkative.Died"), player.PlayerId.ColoredPlayerName()), title: CustomRoles.Talkative.ToColoredString());
return;
}
NumMessagesThisMeeting[player.PlayerId] = ++sent;
}
}