public bool Invite(WorldClient client, string name) { try { WorldClient t_client = (WorldClient)(WorldServer.GetClientByName(name)); if (t_client != null) { if (!Users.Contains(t_client)) { BinWriter w = new BinWriter(); w.Write((byte)CHANNEL.INVITE); w.Write((string)name); w.Write(client.Player.GUID); t_client.Send(SMSG.CHANNEL_NOTIFY, w); Join(t_client); } else { BinWriter w = new BinWriter(); w.Write((byte)CHANNEL.ALREADYON); w.Write((string)name); w.Write(t_client.Player.GUID); client.Send(SMSG.CHANNEL_NOTIFY, w); } return(true); } return(false); } catch (Exception e) { Console.WriteLine("Channel Exception (Invite): " + e.Message); return(false); } }
public bool Part(WorldClient client) { try { int index; if ((index = Users.IndexOf(client)) != -1) { Users.RemoveAt(index); Flags.RemoveAt(index); if (client.Player.InWorld) { BinWriter w = new BinWriter(); w.Write((byte)CHANNEL.LEFT2); w.Write(name); client.Send(SMSG.CHANNEL_NOTIFY, w); } if (announcment) { BinWriter w2 = new BinWriter(); w2.Write((byte)CHANNEL.LEFT1); w2.Write(name); w2.Write(client.Player.GUID); int nb_users = NbUsers(); Console.WriteLine("miyu: " + nb_users); for (int i = 0; i < nb_users; i++) { Console.WriteLine("miyu!"); ((WorldClient)Users[i]).Send(SMSG.CHANNEL_NOTIFY, w2); } } return(true); } return(false); } catch (Exception e) { Console.WriteLine("Channel Exception (Part): " + e.Message); return(false); } }
public bool Talk(WorldClient client, string msg) { try { int index = Users.IndexOf(client); if (!((RightFlag)Flags[index]).IsMute() || (moderate && (!((RightFlag)Flags[index]).IsModo() || !((RightFlag)Flags[index]).IsVoice()))) { BinWriter w = new BinWriter(); w.Write((byte)CHATMESSAGETYPE.CHANNEL); w.Write((int)0); w.Write((string)name); w.Write(client.Player.GUID); w.Write((int)msg.Length + 1); // chat fix w.Write((string)msg); w.Write((byte)0); int nb_users = NbUsers(); for (int i = 0; i < nb_users; i++) { ((WorldClient)Users[i]).Send(SMSG.MESSAGECHAT, w); } return(true); } else { BinWriter w = new BinWriter(); w.Write((byte)CHANNEL.CANNOTSPEAK); w.Write((string)name); client.Send(SMSG.CHANNEL_NOTIFY, w); return(false); } } catch (Exception e) { Console.WriteLine("Channel Exception (Talk): " + e.Message); return(false); } }
} /* * * public bool Ban(WorldClient client) * { * try * { * int index; * if ( (index = Users.IndexOf(client)) != -1) * { * if( Banned.IndexOf(client.Player.GUID) == -1 ) * { * Banned.Add(client.Player.GUID); * return true; * } * } * return false; * } * catch(Exception e) * { * Console.WriteLine("Channel Exception : "+e.Message); * return false; * } * } * * public bool UnBan(WorldClient client) * { * try * { * int index; * if ( (index = Users.IndexOf(client)) != -1) * { * if( Banned.IndexOf(client.Player.GUID) != -1) * { * Banned.Remove(client.Player.GUID); * return true; * } * } * return false; * } * catch(Exception e) * { * Console.WriteLine("Channel Exception : "+e.Message); * return false; * } * } */ public bool List(WorldClient client) { try { int nb_users = NbUsers(); BinWriter w = new BinWriter(); w.Write((string)name); w.Write((byte)0x00); w.Write((int)nb_users); for (int i = 0; i < nb_users; i++) { w.Write(((WorldClient)(Users[i])).Player.GUID); w.Write((byte)((RightFlag)(Flags[i])).GetRightFlag()); } client.Send(SMSG.CHANNEL_LIST, w); return(true); } catch (Exception e) { Console.WriteLine("Channel Exception (List): " + e.Message); return(false); } }
public bool Join(WorldClient client) { try { IEnumerator ienum = Users.GetEnumerator(); int index = 0; while (ienum.MoveNext()) { if (((WorldClient)ienum.Current).Player.Name == client.Player.Name) { Users.RemoveAt(index); Flags.RemoveAt(index); break; } index++; } BinWriter w = new BinWriter(); w.Write((byte)CHANNEL.JOIN2); w.Write((string)name); if (Users.Count == 0) { w.Write((byte)0x00); } else { w.Write((byte)0x01); } w.Write((byte)0x00); w.Write((byte)0x00); w.Write((byte)0x00); client.Send(SMSG.CHANNEL_NOTIFY, w); Users.Add(client); int nb_users = NbUsers(); if (client.Player.AccessLvl >= ACCESSLEVEL.GM || nb_users == 1) { Flags.Add(new RightFlag((string)"o")); } else { Flags.Add(new RightFlag()); } BinWriter w3 = new BinWriter(); w3.Write((byte)CHANNEL.JOIN1); w3.Write((string)name); w3.Write(client.Player.GUID); BinWriter w2 = new BinWriter(); w2.Write((string)name); w2.Write((byte)0x00); w2.Write((int)nb_users); for (int i = 0; i < nb_users; i++) { w2.Write(((WorldClient)(Users[i])).Player.GUID); w2.Write((byte)((RightFlag)(Flags[i])).GetRightFlag()); if (announcment) { ((WorldClient)Users[i]).Send(SMSG.CHANNEL_NOTIFY, w3); } } client.Send(SMSG.CHANNEL_LIST, w2); return(true); } catch (Exception e) { Console.WriteLine("Channel Exception (Join): " + e.Message); return(false); } }