Hi there, so I'm working on a really simple multiplayer game where the server generates a grid of hexagons, then the players can join in and take these hexagons (so they control some space on that grid where other players want a piece of the cake!), but I'm having an annoying problem while sending the message where players request that they're taking a desired hexagon (by id).
The exception, as the title says is: This message has already been sent! Use NetPeer.SendMessage() to send to multiple recipients efficiently
I'm using NetPeer.SendToAll for this, this is my code at the moment:
case (byte)Client.ON_REQUEST_TAKE:
int takenHexagonId = incoming.ReadInt32();
Hexagon taken = hexagons.Find(h =>
h.id == takenHexagonId);
NetPlayer newOwner = players.Find(p => p.connection == incoming.SenderConnection);
if (newOwner != null && taken != null)
{
taken.playerOwnerID = newOwner.id;
// Broadcast to everyone
outgoing = server.CreateMessage();
outgoing.Write((byte)Server.ON_HEXAGON_TAKEN);
outgoing.Write((int)taken.playerOwnerID);
server.SendToAll(outgoing, NetDeliveryMethod.ReliableOrdered);
}
break;
What's happening?
And also if you can help me on another little thing, when the server kicks someone it sends a string with the disconnect message using NetPeer.Disconnect("whatever");, but on the player's end
the string isn't received completely, if for an example the message sent is "Disconnected because you're cheating" in the player's end it would appear "Disc".
The game is being developed in Unity 5.1, but I've been having this small problem since 4.x, I don't really know if it's a Unity problem or what, haven't tested using console clients or whatever.
Thanks in advance!