Forum C# no suitable method found to override?

no suitable method found to override?

Postby igli1 » July 11th, 2013, 1:19 am

Code: Select all
public override void GotMessage(Player player, Message message)
        {
            switch (message.Type)
            {
                case"search":
                    searchOpp(player);
                break;
            }
        }
        public override void searchOpp(Player player)
        {
             Broadcast("UserJoined", player.Id);
            Player opponent = null;
            if (PlayerCount >= 2)
            {
                foreach (Player p in Players)
                {
                    if (p != player)
                    {
                        opponent = p;
                        break;
                    }
                }
            }

            if (opponent != null)
            {
                string id = randomString(20);

                opponent.Send("gameFound", id);
                player.Send("gameFound", id);

                opponent.Disconnect();
                player.Disconnect();
            }
        }


Error 1 'MyGame.matchmakingCode.searchOpp(MyGame.Player)': no suitable method found to override
Any help? :roll:
igli1
 
Posts: 38
Joined: June 29th, 2013, 1:12 pm

Re: no suitable method found to override?

Postby Henrik » July 11th, 2013, 2:24 pm

igli1 wrote:Error 1 'MyGame.matchmakingCode.searchOpp(MyGame.Player)': no suitable method found to override
Any help? :roll:

Remove "override" since there is no method called searchOpp in the base class. Just like the error message says.
Henrik
.IO
 
Posts: 1822
Joined: January 4th, 2010, 1:53 pm

Re: no suitable method found to override?

Postby igli1 » July 11th, 2013, 3:20 pm

Henrik wrote:
igli1 wrote:Error 1 'MyGame.matchmakingCode.searchOpp(MyGame.Player)': no suitable method found to override
Any help? :roll:

Remove "override" since there is no method called searchOpp in the base class. Just like the error message says.

Ofc i tried that, but this error is shown :
“A project with an Output type of Class Library cannot be started directly”
In order to debug this project, add an executable project to this solution wich references the library project
igli1
 
Posts: 38
Joined: June 29th, 2013, 1:12 pm

Re: no suitable method found to override?

Postby Henrik » July 11th, 2013, 10:16 pm

Set the development server project as the startup project, then.

Or change the Output type of the project you tried to start to Console Application.
Henrik
.IO
 
Posts: 1822
Joined: January 4th, 2010, 1:53 pm

Re: no suitable method found to override?

Postby sebas77 » October 14th, 2013, 3:55 pm

sorry if I jump in this thread but I want to ask if

Code: Select all
opponent.Send("gameFound", id);
player.Send("gameFound", id);

opponent.Disconnect();
player.Disconnect();


is actually valid and I can do it as well....can I send a message and disconnect right after? Will the message actually be received?
sebas77
Paid Member
 
Posts: 137
Joined: June 25th, 2013, 12:09 pm

Re: no suitable method found to override?

Postby igli1 » October 14th, 2013, 9:39 pm

It works, it's all good
It was all my fault cuz sth like player.Disconnect() actually works :)
igli1
 
Posts: 38
Joined: June 29th, 2013, 1:12 pm


Return to C#



cron