static bool HandleGroupListCommand(StringArguments args, CommandHandler handler) { // Get ALL the variables! Player playerTarget; ObjectGuid guidTarget; string nameTarget; string zoneName = ""; string onlineState = ""; // Parse the guid to uint32... ObjectGuid parseGUID = ObjectGuid.Create(HighGuid.Player, args.NextUInt64()); // ... and try to extract a player out of it. if (Global.CharacterCacheStorage.GetCharacterNameByGuid(parseGUID, out nameTarget)) { playerTarget = Global.ObjAccessor.FindPlayer(parseGUID); guidTarget = parseGUID; } // If not, we return false and end right away. else if (!handler.extractPlayerTarget(args, out playerTarget, out guidTarget, out nameTarget)) { return(false); } // Next, we need a group. So we define a group variable. Group groupTarget = null; // We try to extract a group from an online player. if (playerTarget) { groupTarget = playerTarget.GetGroup(); } // If not, we extract it from the SQL. if (!groupTarget) { PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_GROUP_MEMBER); stmt.AddValue(0, guidTarget.GetCounter()); SQLResult resultGroup = DB.Characters.Query(stmt); if (!resultGroup.IsEmpty()) { groupTarget = Global.GroupMgr.GetGroupByDbStoreId(resultGroup.Read <uint>(0)); } } // If both fails, players simply has no party. Return false. if (!groupTarget) { handler.SendSysMessage(CypherStrings.GroupNotInGroup, nameTarget); return(false); } // We get the group members after successfully detecting a group. var members = groupTarget.GetMemberSlots(); // To avoid a cluster f**k, namely trying multiple queries to simply get a group member count... handler.SendSysMessage(CypherStrings.GroupType, (groupTarget.isRaidGroup() ? "raid" : "party"), members.Count); // ... we simply move the group type and member count print after retrieving the slots and simply output it's size. // While rather dirty codestyle-wise, it saves space (if only a little). For each member, we look several informations up. foreach (var slot in members) { // Check for given flag and assign it to that iterator string flags = ""; if (slot.flags.HasAnyFlag(GroupMemberFlags.Assistant)) { flags = "Assistant"; } if (slot.flags.HasAnyFlag(GroupMemberFlags.MainTank)) { if (!string.IsNullOrEmpty(flags)) { flags += ", "; } flags += "MainTank"; } if (slot.flags.HasAnyFlag(GroupMemberFlags.MainAssist)) { if (!string.IsNullOrEmpty(flags)) { flags += ", "; } flags += "MainAssist"; } if (string.IsNullOrEmpty(flags)) { flags = "None"; } // Check if iterator is online. If is... Player p = Global.ObjAccessor.FindPlayer(slot.guid); string phases = ""; if (p && p.IsInWorld) { // ... than, it prints information like "is online", where he is, etc... onlineState = "online"; phases = PhasingHandler.FormatPhases(p.GetPhaseShift()); AreaTableRecord area = CliDB.AreaTableStorage.LookupByKey(p.GetAreaId()); if (area != null) { AreaTableRecord zone = CliDB.AreaTableStorage.LookupByKey(area.ParentAreaID); if (zone != null) { zoneName = zone.AreaName[handler.GetSessionDbcLocale()]; } } } else { // ... else, everything is set to offline or neutral values. zoneName = "<ERROR>"; onlineState = "Offline"; } // Now we can print those informations for every single member of each group! handler.SendSysMessage(CypherStrings.GroupPlayerNameGuid, slot.name, onlineState, zoneName, phases, slot.guid.ToString(), flags, LFGQueue.GetRolesString(slot.roles)); } // And finish after every iterator is done. return(true); }