Sign in to follow this  
#Patow

Chat error

Recommended Posts

Hi!

I have a problem when i open the chat and put any word, i dont know where is the problem.

This is the exception:

System.ArgumentNullException: Value cannot be null.
Parameter name: source
   at IEnumerable<TResult> System.Linq.Enumerable.Select<TSource, TResult>(IEnumerable<TSource> source, Func<TSource, TResult> selector)

 

I have this script for Event.ChatMessage: 

[ServerEvent(Event.ChatMessage)]
        public void OnChatMessage(Client player, string mensaje)
        {
            if (player.HasData(EntityData.USUARIO_LOGUEADO))
            {
                Chat.playerChating(player, mensaje, Constants.MESSAGE_TALK, 10.0f, false);
            } else
            {
                player.SendChatMessage("~r~ ¡Should be logged in!");
            }
        }

And in another class: 

public static void playerChating(Client player, string message, int type, float range, bool excludePlayer)
        {
            foreach (Client target in NAPI.Pools.GetAllPlayers())
            {
                if (player.Dimension == target.Dimension)
                {
                    if (player != target || (player == target && !excludePlayer))
                    {
                        float distance = player.Position.DistanceTo(target.Position);

                        if (distance < range)
                        {
                            if (type == Constants.MESSAGE_TALK)
                            {
                                target.SendChatMessage(player.GetData(EntityData.USUARIO_PERSONAJE) + " dice: " + message);
                            }

                            if(type == Constants.MESSAGE_ME)
                            {
                                target.SendChatMessage(Constants.COLOR_CHAT_ME +" * " + player.GetData(EntityData.USUARIO_PERSONAJE) +" "+ message);
                            }
                        }
                    }
                }
            }
        }

Thanks!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.