/// <summary>
/// Sends already connected clients to the connecting one
/// </summary>
/// <param name="id"></param>
/// <param name="p"></param>
static void NotifyMainPlayerOfAlreadyConnected(int id) // sends already connected to players current player
{
for (int i = 0; i < 20; i++)
{
if (Globals.clients[i] != null && Globals.clients[i].Connected)
{
if (i != id)
{
Console.WriteLine(i);
ByteBuffer buffer = new ByteBuffer();
buffer.WriteInt((int)Enums.AllEnums.SSendingAlreadyConnectedToMain);
buffer.WriteString(Globals.dicPlayers[i].uName);
buffer.WriteString(Globals.dicPlayers[i].cName);
buffer.WriteInt(Globals.dicPlayers[i].head);
buffer.WriteInt(Globals.dicPlayers[i].body);
buffer.WriteInt(Globals.dicPlayers[i].cloths);
buffer.WriteFloat(Globals.dicPlayers[i].cX);
buffer.WriteFloat(Globals.dicPlayers[i].cY);
buffer.WriteFloat(Globals.dicPlayers[i].cZ);
Thread.Sleep(1000); //If the thread doesnt sleep, the packet is not sent
//Console.WriteLine(buffer.ToArray().Length+" to "+id);
try
{
Globals.clients[id].GetStream().Write(buffer.ToArray(), 0, buffer.ToArray().Length);
}
catch (Exception) { continue; }
}
}
}
}