public void OnCommand(GameClient client, string[] args) { if (IsSpammingCommand(client.Player, "chatgroup")) { return; } if (args.Length < 2) { PrintHelp(client); return; } switch (args[1].ToLower()) { case "help": { PrintHelp(client); } break; case "invite": { if (args.Length < 3) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.UsageInvite"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } GameClient inviteeclient = WorldMgr.GetClientByPlayerName(args[2], false, true); if (inviteeclient == null || !GameServer.ServerRules.IsSameRealm(inviteeclient.Player, client.Player, true)) // allow priv level>1 to invite anyone { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.NoPlayer"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (client == inviteeclient) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.InviteYourself"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } ChatGroup oldchatgroup = (ChatGroup)inviteeclient.Player.TempProperties.getProperty <object>(ChatGroup.CHATGROUP_PROPERTY, null); if (oldchatgroup != null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.PlayerInChatgroup", inviteeclient.Player.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } ChatGroup mychatgroup = (ChatGroup)client.Player.TempProperties.getProperty <object>(ChatGroup.CHATGROUP_PROPERTY, null); if (mychatgroup == null) { mychatgroup = new ChatGroup(); mychatgroup.AddPlayer(client.Player, true); } else if (((bool)mychatgroup.Members[client.Player]) == false) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.LeaderInvite"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } inviteeclient.Player.TempProperties.setProperty(JOIN_CHATGROUP_PROPERTY, mychatgroup); inviteeclient.Player.Out.SendCustomDialog(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.JoinChatGroup", client.Player.Name), new CustomDialogResponse(JoinChatGroup)); } break; case "who": { ChatGroup mychatgroup = (ChatGroup)client.Player.TempProperties.getProperty <object>(ChatGroup.CHATGROUP_PROPERTY, null); if (mychatgroup == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.InChatGroup"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } int i = 0; StringBuilder text = new StringBuilder(64); foreach (GamePlayer player in mychatgroup.Members.Keys) { i++; text.Length = 0; text.Append(i); text.Append(") "); text.Append(player.Name); if (player.Guild != null) { text.Append(" <"); text.Append(player.GuildName); text.Append(">"); } text.Append(" ("); text.Append(player.CharacterClass.Name); text.Append(")"); client.Out.SendMessage(text.ToString(), eChatType.CT_System, eChatLoc.CL_SystemWindow); // TODO: make function formatstring } } break; case "remove": { ChatGroup mychatgroup = (ChatGroup)client.Player.TempProperties.getProperty <object>(ChatGroup.CHATGROUP_PROPERTY, null); if (mychatgroup == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.InChatGroup"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (args.Length < 3) { PrintHelp(client); } GameClient inviteeclient = WorldMgr.GetClientByPlayerName(args[2], false, false); if (inviteeclient == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.NoPlayer"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } mychatgroup.RemovePlayer(inviteeclient.Player); } break; case "leave": { ChatGroup mychatgroup = (ChatGroup)client.Player.TempProperties.getProperty <object>(ChatGroup.CHATGROUP_PROPERTY, null); if (mychatgroup == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.InChatGroup"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } mychatgroup.RemovePlayer(client.Player); } break; case "listen": { ChatGroup mychatgroup = (ChatGroup)client.Player.TempProperties.getProperty <object>(ChatGroup.CHATGROUP_PROPERTY, null); if (mychatgroup == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.InChatGroup"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if ((bool)mychatgroup.Members[client.Player] == false) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.LeaderCommand"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } mychatgroup.Listen = !mychatgroup.Listen; string message = LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.ListenMode") + (mychatgroup.Listen ? "on." : "off."); foreach (GamePlayer ply in mychatgroup.Members.Keys) { ply.Out.SendMessage(message, eChatType.CT_Chat, eChatLoc.CL_ChatWindow); } } break; case "leader": { ChatGroup mychatgroup = (ChatGroup)client.Player.TempProperties.getProperty <object>(ChatGroup.CHATGROUP_PROPERTY, null); if (mychatgroup == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.InChatGroup"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if ((bool)mychatgroup.Members[client.Player] == false) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.LeaderCommand"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (args.Length < 3) { PrintHelp(client); } string invitename = string.Join(" ", args, 2, args.Length - 2); GameClient inviteeclient = WorldMgr.GetClientByPlayerName(invitename, false, false); if (inviteeclient == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.NoPlayer"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } mychatgroup.Members[inviteeclient.Player] = true; string message = LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.Moderator", inviteeclient.Player.Name); foreach (GamePlayer ply in mychatgroup.Members.Keys) { ply.Out.SendMessage(message, eChatType.CT_Chat, eChatLoc.CL_ChatWindow); } } break; case "public": { ChatGroup mychatgroup = (ChatGroup)client.Player.TempProperties.getProperty <object>(ChatGroup.CHATGROUP_PROPERTY, null); if (mychatgroup == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.InChatGroup"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if ((bool)mychatgroup.Members[client.Player] == false) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.LeaderCommand"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (mychatgroup.IsPublic) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.PublicAlready"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } else { mychatgroup.IsPublic = true; string message = LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.Public"); foreach (GamePlayer ply in mychatgroup.Members.Keys) { ply.Out.SendMessage(message, eChatType.CT_Chat, eChatLoc.CL_ChatWindow); } } } break; case "private": { ChatGroup mychatgroup = (ChatGroup)client.Player.TempProperties.getProperty <object>(ChatGroup.CHATGROUP_PROPERTY, null); if (mychatgroup == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.InChatGroup"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if ((bool)mychatgroup.Members[client.Player] == false) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.LeaderCommand"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (!mychatgroup.IsPublic) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.PrivateAlready"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } else { mychatgroup.IsPublic = false; string message = LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.Private"); foreach (GamePlayer ply in mychatgroup.Members.Keys) { ply.Out.SendMessage(message, eChatType.CT_Chat, eChatLoc.CL_ChatWindow); } } } break; case "join": { if (args.Length < 3) { PrintHelp(client); return; } GameClient inviteeclient = WorldMgr.GetClientByPlayerName(args[2], false, false); if (inviteeclient == null || !GameServer.ServerRules.IsSameRealm(client.Player, inviteeclient.Player, true)) // allow priv level>1 to join anywhere { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.NoPlayer"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (client == inviteeclient) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.OwnChatGroup"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } ChatGroup mychatgroup = (ChatGroup)inviteeclient.Player.TempProperties.getProperty <object>(ChatGroup.CHATGROUP_PROPERTY, null); if (mychatgroup == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.NotChatGroupMember"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if ((bool)mychatgroup.Members[inviteeclient.Player] == false) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.NotChatGroupLeader"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (!mychatgroup.IsPublic) { if (args.Length == 4 && args[3] == mychatgroup.Password) { mychatgroup.AddPlayer(client.Player, false); } else { client.Player.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.NotPublic"), eChatType.CT_System, eChatLoc.CL_SystemWindow); } } else { mychatgroup.AddPlayer(client.Player, false); } } break; case "password": { ChatGroup mychatgroup = (ChatGroup)client.Player.TempProperties.getProperty <object>(ChatGroup.CHATGROUP_PROPERTY, null); if (mychatgroup == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.InChatGroup"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if ((bool)mychatgroup.Members[client.Player] == false) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.LeaderCommand"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (args.Length < 3) { if (mychatgroup.Password.Equals(string.Empty)) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.PasswordUnset", mychatgroup.Password), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } else { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.Password", mychatgroup.Password), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } } if (args[2] == "clear") { mychatgroup.Password = string.Empty; client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.PasswordClear", mychatgroup.Password), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } mychatgroup.Password = args[2]; client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Chatgroup.PasswordChanged", mychatgroup.Password), eChatType.CT_System, eChatLoc.CL_SystemWindow); } break; } }