예제 #1
0
        private void RPC_016(NetMessage arg1, PlayerMessageInfo arg2)
        {
            string   targetName = arg1.ReadString();
            string   text       = arg1.ReadString();
            ChatIcon icon       = (ChatIcon)arg1.ReadByte();

            if (targetName == _user.Name || targetName == m_name)
            {
                return;
            }
            if (icon != ChatIcon.None && _user.Access < AccessLevel.Moderator)
            {
                icon = ChatIcon.None;
            }
            MasterPlayer player;

            if (_server.TryGetByPonyName(targetName, out player))
            {
                var message = default(ChatMsg);
                message.Icon     = icon;
                message.Text     = text;
                message.Time     = DateTime.Now;
                message.CharID   = _user.Char;
                message.PlayerID = _player.Id;
                message.Type     = ChatType.Whisper;
                message.Name     = m_name ?? _user.Name;
                _lastWhisper     = player.Char?.Pony.Name;
                //_player.PlayerRpc(15, ChatType.Whisper, _message.Name ?? _user.Name, message, time, _user.Char, icon, (int)_player.Id);
                player.Player.PlayerRpc(15, message);
            }
            else
            {
                _lastWhisper = null;
            }
        }
예제 #2
0
        private void RPC_150(NetMessage arg1, PlayerMessageInfo arg2)
        {
            switch (arg1.ReadByte())
            {
            case 10:
                Guid guid = arg1.ReadGuid(); Room room;
                if (_server.Server.TryGetRoom(guid, out room))
                {
                    _player.ChangeRoom(room);
                }
                else
                {
                    _player.SystemMsg($"Couldn't find room {guid.ToString().Normalize(8)}");
                }
                break;

            case 11:
                Room[] rooms;
                if (_server.Server.TryGetRooms(_player.Room.RoomId, out rooms))
                {
                    _player.PlayerSubRpc(150, 11, new SER_RoomInfo(rooms));
                }
                break;

            default:
                break;
            }
        }
예제 #3
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;
                }
            }
        }