Esempio n. 1
0
        private void RPC_015(NetMessage arg1, PlayerMessageInfo arg2)
        {
            var message = default(ChatMsg);

            message.OnDeserialize(arg1);
            if (message.Icon != 0 && _user.Access < AccessLevel.Moderator)
            {
                message.Icon = 0;
            }
            if (message.Text.Sum(x => char.IsUpper(x) ? 1 : 0) > message.Text.Length / 4 + 4 || message.Time < _time)
            {
                _player.SystemMsg(Constants.ChatWarning);
            }
            else
            {
                message.CharID   = _user.Char;
                message.PlayerID = _player.Id;
                message.Name     = m_name ?? _user.Name;

                _time = message.Time.AddMilliseconds(SpamDelay);
                switch (message.Type)
                {
                case ChatType.Global:
                    _player.Server.AllPlayersRpc(15, message);
                    ServerLogger.LogChat(_user.Name, message.Name, message.Type, message.Text);
                    break;

                case ChatType.Herd:
                //break;
                case ChatType.Party:
                    _player.SystemMsg($"Chat type {message.Type} not yet implemented!");
                    break;

                case ChatType.Whisper:
                    if (_lastWhisper != null)
                    {
                        MasterPlayer player;
                        if (_server.TryGetByPonyName(_lastWhisper, out player))
                        {
                            _player.Whisper(player.Player, message);
                        }
                        else
                        {
                            _lastWhisper = null;
                        }
                    }
                    break;

                default:
                    _player.SystemMsg($"Chat type {message.Type} not allowed!");
                    break;
                }
            }
        }