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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.