using GTANetworkAPI;
using ReallifeGamemode.Server.Services;
using System.Text.RegularExpressions;

namespace ReallifeGamemode.Server.Events
{
    public class Chat : Script
    {
        [ServerEvent(Event.ChatMessage)]
        public void ChatEvent(Client player, string message)
        {
            string serverMsg = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
            if (serverMsg.Trim().Length == 0) return;
            NAPI.Player.GetPlayersInRadiusOfPlayer(10, player).ForEach(p =>
            {
                ChatService.SendMessage(p, $"{player.Name} sagt: {serverMsg}");
            });
        }
    }
}