public override void InitPopUp(GuildMember guildMember) { this.mGuildMember = guildMember; this.Refresh(); if (this.mGuildMember != null) { FriendData friendData = Globals.Instance.Player.FriendSystem.GetFriendData(this.mGuildMember.ID); if (friendData != null) { this.friendType = friendData.FriendType; } } }
public GuildObject(PlayerObject owner, string name) { Name = name; Rank Owner = new Rank() { Name = "Leader", Options = (RankOptions)255 , Index = 0}; GuildMember Leader = new GuildMember() { name = owner.Info.Name, Player = owner, Id = owner.Info.Index, LastLogin = Envir.Now, Online = true}; Owner.Members.Add(Leader); Ranks.Add(Owner); Membercount++; NeedSave = true; if (Level < Settings.Guild_ExperienceList.Count) MaxExperience = Settings.Guild_ExperienceList[Level]; if (Level < Settings.Guild_MembercapList.Count) MemberCap = Settings.Guild_MembercapList[Level]; }
/// <summary> /// Adds creature to the guild as applicant. /// </summary> /// <param name="creature"></param> /// <param name="guild"></param> public void Apply(Creature creature, Guild guild, string application) { if (guild.HasMember(creature.EntityId)) { throw new ArgumentException("Character is already a member of this guild. (" + creature.Name + ", " + guild.Name + ")"); } var member = new GuildMember(); member.GuildId = guild.Id; member.CharacterId = creature.EntityId; member.Rank = GuildMemberRank.Applied; member.JoinedDate = DateTime.Now; member.Application = application; creature.Guild = guild; creature.GuildMember = member; guild.AddMember(member); ChannelServer.Instance.Database.AddGuildMember(member); }
static void LoadGuild(Player player) { // in a guild? string guild = (string)ExecuteScalar("SELECT guild FROM character_guild WHERE character=@character", new SqliteParameter("@character", player.name)); if (guild != null) { // load guild info player.guildName = guild; List <List <object> > table = ExecuteReader("SELECT notice FROM guild_info WHERE name=@guild", new SqliteParameter("@guild", guild)); if (table.Count == 1) { List <object> row = table[0]; player.guild.notice = (string)row[0]; } // load members list List <GuildMember> members = new List <GuildMember>(); table = ExecuteReader("SELECT character, rank FROM character_guild WHERE guild=@guild", new SqliteParameter("@guild", player.guildName)); foreach (List <object> row in table) { GuildMember member = new GuildMember(); member.name = (string)row[0]; member.rank = (GuildRank)Convert.ToInt32((long)row[1]); member.online = Player.onlinePlayers.ContainsKey(member.name); if (member.name == player.name) { member.level = player.level; } else { object scalar = ExecuteScalar("SELECT level FROM characters WHERE name=@character", new SqliteParameter("@character", member.name)); member.level = scalar != null?Convert.ToInt32((long)scalar) : 1; } members.Add(member); } player.guild.members = members.ToArray(); // guild.AddMember each time is too slow because array resizing } }
private static void HandleGuildDonate(GameSession session, PacketReader packet) { int donateQuantity = packet.ReadInt(); int donationAmount = donateQuantity * 10000; Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id); if (guild == null) { return; } GuildPropertyMetadata guildProperty = GuildPropertyMetadataStorage.GetMetadata(guild.Exp); GuildMember member = guild.Members.First(x => x.Player == session.Player); if (member.DailyDonationCount >= guildProperty.DonationMax) { return; } if (!session.Player.Wallet.Meso.Modify(-donationAmount)) { session.Send(GuildPacket.ErrorNotice((byte)GuildErrorNotice.NotEnoughMesos)); return; } Item coins = new(id : 30000861, amount : guildProperty.DonateGuildCoin * donateQuantity, rarity : 4); session.Player.Inventory.AddItem(session, coins, true); int contribution = GuildContributionMetadataStorage.GetContributionAmount("donation"); member.DailyDonationCount += (byte)donateQuantity; member.AddContribution(contribution * donateQuantity); guild.ModifyFunds(session, guildProperty, donationAmount); session.Send(GuildPacket.UpdatePlayerDonation()); guild.BroadcastPacketGuild(GuildPacket.UpdatePlayerContribution(member, donateQuantity)); }
public void NewMember(PlayerObject newMember) { if (Ranks.Count < 2) { Ranks.Add(new GuildRank() { Name = "Members", Index = 1 }); } GuildRank lowestRank = Ranks[Ranks.Count - 1]; GuildMember member = new GuildMember() { Name = newMember.Info.Name, Player = newMember, Id = newMember.Info.Index, LastLogin = Envir.Now, Online = true }; lowestRank.Members.Add(member); PlayerLogged(newMember, true, true); Info.Membercount++; NeedSave = true; }
// Called when a member leaves the Discord server private void Discord_MemberRemoved(GuildMember member) { var steamId = API_GetSteam(member.user.id); // No user found if (steamId == null) { return; } if (config.Info.Deauthenticate) { Deauthenticate(steamId, member.user.id); member.user.CreateDM(Client, dm => dm.CreateMessage(Client, GetEmbed(Formatter.ToPlaintext(Lang("Discord-Deauthenticated", steamId, Client.DiscordServer.name)), 9905970))); return; } if (config.Info.RemovefromGroup) { permission.RemoveUserGroup(steamId, config.Info.Group); member.user.CreateDM(Client, dm => dm.CreateMessage(Client, GetEmbed(Formatter.ToPlaintext(Lang("Group Revoked", steamId, config.Info.Group)), 16098851))); } }
public bool ChangeMaster(GuildEntity guild, GuildMember newMaster, GuildMember oldMaster) { GuildMemberKey key = newMaster.Key; HeroesGuildUserType value = GuildMemberRank.Operator.ToGroupUserType(); int num = -1; try { HeroesGuildDBDataContext heroesGuildDBDataContext = new HeroesGuildDBDataContext(); num = heroesGuildDBDataContext.GuildGroupChangeMaster(new int?(GuildAPI.ServerCode), new int?(guild.GuildSN), new int?(key.NexonSN), new long?((long)key.CharacterSN), key.CharacterName, new int?((int)value)); } catch (Exception ex) { Log <HeroesGuildAPI> .Logger.Error("Error in ChangeMaster", ex); } if (num == 0) { GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, newMaster.Key.CID, OperationType.HeroesCore_ChangeMaster, GuildLedgerEventType.Success, guild.GuildInfo.MasterName, newMaster.Key.CharacterName)); return(true); } GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, newMaster.Key.CID, OperationType.HeroesCore_ChangeMaster, GuildLedgerEventType.DatabaseFail, guild.GuildInfo.MasterName, newMaster.Key.CharacterName)); return(false); }
/// <summary> /// This method checksif the discord user is member of a specified guild and has a mod role or higher as they are specified in the database. /// https://discord.com/developers/docs/resources/guild#get-guild-member /// </summary> /// <param name="guildId">guild that the user requestes for</param> /// <returns>the guildmember object if the current user could be found on that guild.</returns> public async Task <GuildMember> GetGuildMembership(string guildId) { if (GuildMemberships.ContainsKey(guildId)) { return(GuildMemberships[guildId]); } else { await ValidateBasicDetails(); if (DiscordUser == null) { return(null); } else { GuildMember guildMember = await discord.FetchMemberInfo(guildId, DiscordUser.Id); GuildMemberships.Add(guildId, guildMember); return(guildMember); } } }
private static void HandleGuildAlert(GameSession session, string message, ChatType type) { Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id); if (guild == null) { return; } GuildMember member = guild.Members.FirstOrDefault(x => x.Player == session.Player); if (member == null) { return; } if (!((GuildRights)guild.Ranks[member.Rank].Rights).HasFlag(GuildRights.CanGuildAlert)) { return; } guild.BroadcastPacketGuild(ChatPacket.Send(session.Player, message, type)); }
public static Packet MemberBroadcastJoinNotice(GuildMember member, string inviterName, bool displayNotice) { PacketWriter pWriter = PacketWriter.Of(SendOp.GUILD); pWriter.WriteEnum(GuildPacketMode.MemberBroadcastJoinNotice); pWriter.WriteUnicodeString(inviterName); pWriter.WriteUnicodeString(member.Player.Name); pWriter.WriteBool(displayNotice); pWriter.WriteByte(0x3); pWriter.WriteByte(member.Rank); pWriter.WriteLong(member.Player.CharacterId); WriteGuildMember(pWriter, member.Player); pWriter.WriteShort(); // unk, filler? pWriter.WriteLong(); // timestamp pWriter.WriteLong(); // timestamp pWriter.WriteLong(); // timestamp pWriter.WriteLong(); // unk pWriter.WriteLong(); // unk pWriter.WriteLong(); // unk pWriter.WriteLong(); // unk pWriter.WriteByte(); // unk return(pWriter); }
private static void HandleRankChange(GameSession session, PacketReader packet) { string memberName = packet.ReadUnicodeString(); byte rank = packet.ReadByte(); Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id); if (guild == null || session.Player.CharacterId != guild.LeaderCharacterId) { return; } GuildMember member = guild.Members.First(x => x.Player.Name == memberName); if (member == null || member.Rank == rank) { return; } member.Rank = rank; session.Send(GuildPacket.RankChangeConfirm(memberName, rank)); guild.BroadcastPacketGuild(GuildPacket.RankChangeNotice(session.Player.Name, memberName, rank)); }
void UpdatePlayerClan(GuildMember discordMember, ulong steamId, Channel channel) { pinVerification.Remove(steamId); IEnumerable <Clan> currentClans = Clan.AllClans.Where(x => x.Members.Contains(steamId)); for (int i = 0; i < currentClans.Count(); i++) { currentClans.ElementAt(i)?.RemoveMember(steamId); } Clan newClan = Clan.AllClans.FirstOrDefault(x => discordMember.roles.Any(c => c.Equals(x.DiscordRoleID))); // No Appropriate Clan Found. if (newClan == null) { channel?.CreateMessage(discordClient, $"You are not in any clans. Please choose your clan in #choose-your-clan before re-verifying."); return; } newClan.AddMember(steamId); channel?.CreateMessage(discordClient, $"Synced Discord clan with server clan."); }
private static void HandleCheckIn(GameSession session) { Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id); if (guild == null) { return; } GuildMember member = guild.Members.First(x => x.Player == session.Player); // Check if attendance timestamp is today DateTimeOffset date = DateTimeOffset.FromUnixTimeSeconds(member.AttendanceTimestamp); if (date == DateTime.Today) { return; } int contributionAmount = GuildContributionMetadataStorage.GetContributionAmount("attend"); GuildPropertyMetadata property = GuildPropertyMetadataStorage.GetMetadata(guild.Exp); member.AddContribution(contributionAmount); member.AttendanceTimestamp = TimeInfo.Now() + Environment.TickCount; session.Send(GuildPacket.CheckInBegin()); Item guildCoins = new(30000861) { Rarity = 4, Amount = property.AttendGuildCoin }; session.Player.Inventory.AddItem(session, guildCoins, true); guild.AddExp(session, property.AttendExp); guild.ModifyFunds(session, property, property.AttendFunds); guild.BroadcastPacketGuild(GuildPacket.UpdatePlayerContribution(member, contributionAmount)); session.Send(GuildPacket.FinishCheckIn(member)); }
public GuildObject(PlayerObject owner, string name) { Name = name; Rank Owner = new Rank() { Name = "Leader", Options = (RankOptions)255, Index = 0 }; GuildMember Leader = new GuildMember() { name = owner.Info.Name, Player = owner, Id = owner.Info.Index, LastLogin = Envir.Now, Online = true }; Owner.Members.Add(Leader); Ranks.Add(Owner); Membercount++; NeedSave = true; if (Level < Settings.Guild_ExperienceList.Count) { MaxExperience = Settings.Guild_ExperienceList[Level]; } if (Level < Settings.Guild_MembercapList.Count) { MemberCap = Settings.Guild_MembercapList[Level]; } if (Name == Settings.NewbieName) { MemberCap = 1000; } if (Name == Settings.NewbieName) { Level = 20; } FlagColour = Color.FromArgb(255, Envir.Random.Next(255), Envir.Random.Next(255), Envir.Random.Next(255)); }
private string BuildUpdateGuildMemberSQL(string theguildname, GuildMember guildmember) { StringBuilder sb = new StringBuilder(); sb.Clear(); sb.Append(String.Format("UPDATE PLAYERS SET PlayerName = '{0}', GuildName = '{1}', Class = '{2}', Gender = '{3}', Realm = '{4}', LastModifiedFromGuild = '{5}', LastModifiedReadableFromGuild = '{6}', Level = '{7}', Race = '{8}', GuildRank = '{9}', SpecName = '{10}', SpecRole = '{11}', CachedDateUnix = '{12}' WHERE PlayerName = '{13}'", guildmember.Character.Name, theguildname, Utility.ToTitleCase(guildmember.Character.Class.ToString()), Utility.ToTitleCase(guildmember.Character.Gender.ToString()), guildmember.Character.GuildRealm, guildmember.Character.LastModified, Utility.ConvertUnixToLocalTime(long.Parse(guildmember.Character.LastModified)), guildmember.Character.Level.ToString(), Utility.ToTitleCase(guildmember.Character.Race.ToString()), guildmember.Rank.ToString(), guildmember.Character.Specialization != null ? guildmember.Character.Specialization.Name : "UNKNOWN", guildmember.Character.Specialization != null ? guildmember.Character.Specialization.Role : "UNKNOWN", Utility.ConvertLocalTimeToUnix(DateTime.Now), guildmember.Character.Name )); return(sb.ToString()); }
void OnCloseReserveClick() { if (false == GameManager.gameManager.PlayerDataPool.IsHaveGuild()) { return; } Guild info = GameManager.gameManager.PlayerDataPool.GuildInfo; GuildMember mainPlayerGuildInfo = info.GetMainPlayerGuildInfo(); if (false == mainPlayerGuildInfo.IsValid()) { return; } if (false == info.IsHaveAuthority(mainPlayerGuildInfo.Job, (int)GameDefine_Globe.GUILD_ROUTINE.GUILD_ROUTINE_CHANGE_JOINREQ)) { GUIData.AddNotifyData("#{2513}"); return; } MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{10385}"), "", CloseReserveOK); }
public bool ChangeMaster(GuildEntity guild, GuildMember newMaster, GuildMember oldMaster) { if (!FeatureMatrix.IsEnable("EnableChangeGuildMaster")) { return(false); } GuildMemberKey key = newMaster.Key; Log <GuildAPI> .Logger.InfoFormat("ChangeMaster: Guild[{0}], newMasterKey[{1}], oldMasterKey[{2}]", guild.ToString(), key.ToString(), oldMaster.Key.ToString()); Log <GuildAPI> .Logger.InfoFormat("ChangeMaster: serverCode[{0}] guildSn[{1}] NexonSN[{2}] C_SN[{3}] Name[{4}] Rank[{5}]", new object[] { GuildAPI.ServerCode, guild.GuildSN, key.NexonSN, key.CharacterSN, key.CharacterName, GuildMemberRank.Operator.ToGroupUserType() }); HeroesGuildUserType type = GuildMemberRank.Operator.ToGroupUserType(); return(HeroesGuild.GroupChangeMaster(GuildAPI.ServerCode, guild.GuildSN, key.NexonSN, (long)key.CharacterSN, key.CharacterName, this.ConvertToGroupUserType(type))); }
/// <summary> /// Adds a member to the guild. /// </summary> /// <param name="player">The player.</param> /// <param name="rank">The starting rank.</param> /// <param name="update">A boolean determining whether the client of the player should be updated.</param> public void AddMember(Models.Entities.Player player, Enums.GuildRank rank, bool update = true) { var guildMember = new GuildMember(new Database.Models.DbGuildRank { GuildId = Guild.Id, PlayerId = player.DbPlayer.Id, PlayerName = player.Name, PlayerLevel = player.Level, SilverDonation = 0, CPDonation = 0, GuildRank = rank.ToString(), JoinDate = Drivers.Time.GetTime(Drivers.Time.TimeType.Day) }); if (guildMember.DbGuildRank.Create() && _members.TryAdd(player.DbPlayer.Id, guildMember)) { player.AddActionLog("JoinGuild", Guild.Id); guildMember.Player = player; player.Guild = Guild; player.GuildMember = guildMember; if (rank == Enums.GuildRank.GuildLeader) { Guild.GuildLeader = guildMember; } if (update) { player.UpdateClientGuild(); player.UpdateScreen(true); } } _cachedSortedMembers = null; }
public void DeleteMembers() {//carefull this can lead to guild with no ranks or members(or no leader) GuildMember Member = null; Rank MemberRank = null; for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { Member = Ranks[i].Members[j]; MemberRank = Ranks[i]; MemberDeleted(Member.name, (PlayerObject)Member.Player, true); if (Member.Player != null) { PlayerObject LeavingMember = (PlayerObject)Member.Player; LeavingMember.RefreshStats(); } MemberRank.Members.Remove(Member); NeedSave = true; Membercount--; } } }
/// <summary> /// Adds a member to <see cref="AldertoDbContext.GuildMembers"/> and, if needed, /// creates a guild in <see cref="AldertoDbContext.Guilds"/> and a member in <see cref="AldertoDbContext.Members"/> /// </summary> /// <param name="guildMember">New <see cref="GuildMember"/> to add.</param> public async Task AddGuildMemberAsync(GuildMember guildMember) { var guild = await _context.Guilds.FindAsync(guildMember.GuildId); // Check if guild exists, and if it doesn't - add one. // Otherwise the database will spew foreign key violation problems. if (guild == null) { guild = new Guild(guildMember.GuildId); await _context.Guilds.AddAsync(guild); } var member = await _context.Members.FindAsync(guildMember.MemberId); if (member == null) { member = new Member(guildMember.MemberId); await _context.Members.AddAsync(member); } await _context.GuildMembers.AddAsync(guildMember); await _context.SaveChangesAsync(); }
public override IEnumerable <object> Run() { base.Finished = true; if (!base.Entity.IsInitialized) { yield return(new OkMessage()); } else { GuildMember member = base.Entity.GetGuildMember(base.Operation.CharacterName); if (member != null) { member.SetLevel(base.Operation.Level); base.Entity.ReportGuildMemberChanged(member.Key); base.Entity.Sync(); yield return(new OkMessage()); } else { yield return(new FailMessage("[ReportGuildMemberChangedProcessor] member")); } } yield break; }
public bool AcceptJoin(GuildEntity guild, GuildMemberRank operatorRank, GuildMember targetMember, bool accept) { int num = -1; try { if (operatorRank.HasAcceptJoinPermission(targetMember.Rank)) { HeroesGuildDBDataContext heroesGuildDBDataContext = new HeroesGuildDBDataContext(); if (accept) { num = heroesGuildDBDataContext.GuildUserJoinApply(new int?(GuildAPI.ServerCode), new int?(guild.GuildSN), new int?(targetMember.Key.NexonSN), new long?((long)targetMember.Key.CharacterSN), targetMember.Key.CharacterName); } else { num = heroesGuildDBDataContext.GuildUserJoinReject(new int?(GuildAPI.ServerCode), new int?(guild.GuildSN), new int?(targetMember.Key.NexonSN), new long?((long)targetMember.Key.CharacterSN), targetMember.Key.CharacterName); } } } catch (Exception ex) { Log <HeroesGuildAPI> .Logger.Error("Error in AcceptJoin(GuildEntity guild, GuildMemberRank operatorRank, GuildMember targetMember, bool accept)", ex); } GuildLedgerEventType eventType; if (num == 0) { eventType = GuildLedgerEventType.Success; } else { eventType = GuildLedgerEventType.DatabaseFail; } GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, targetMember.Key.CID, OperationType.HeroesCore_ResponseJoin, eventType, string.Format("GuildSn: {0}, isAccept: {1}", guild.GuildSN, accept.ToString()), targetMember.Key.ToString())); return(num == 0); }
public static async Task AddGuildMemberAsync(Player player, int index, GuildMember member) { await using var stream = new MemoryStream(); using var writer = new BitWriter(stream); writer.Write((byte)Amf3Type.Array); writer.Write <byte>(1); Amf3Helper.WriteText(writer, "name"); writer.Write((byte)Amf3Type.String); Amf3Helper.WriteText(writer, member.Name); Amf3Helper.WriteText(writer, "zone"); writer.Write((byte)Amf3Type.String); Amf3Helper.WriteText(writer, member.Zone); Amf3Helper.WriteText(writer, "rank"); writer.Write((byte)Amf3Type.String); Amf3Helper.WriteText(writer, member.Rank); Amf3Helper.WriteText(writer, "online"); writer.Write((byte)(member.Online ? Amf3Type.True : Amf3Type.False)); Amf3Helper.WriteText(writer, "index"); writer.Write((byte)Amf3Type.Integer); Amf3Helper.WriteNumber2(writer, (uint)index); writer.Write((byte)Amf3Type.Null); player.Message(new UiMessageServerToSingleClientMessage { Associate = player, Content = stream.ToArray(), MessageName = "AddGuildMember" }); }
public void AddMemberItem(GuildMember member) { this.mMemberItemsTable.AddData(new GuildMemberItemData(member)); }
public bool DeleteMember(PlayerObject Kicker, string membername) {//carefull this can lead to guild with no ranks or members(or no leader) GuildMember Member = null; Rank MemberRank = null; if ((Kicker.MyGuild != this) || (Kicker.MyGuildRank == null)) { return(false); } for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { if (Ranks[i].Members[j].name == membername) { Member = Ranks[i].Members[j]; MemberRank = Ranks[i]; goto Found; } } } Found: if (Member == null) { return(false); } if (((Kicker.MyGuildRank.Index >= MemberRank.Index) && (Kicker.MyGuildRank.Index != 0)) && (Kicker.Info.Name != membername)) { Kicker.ReceiveChat("你的职位权限不够。", ChatType.System); return(false); } if (MemberRank.Index == 0) { if (MemberRank.Members.Count < 2) { Kicker.ReceiveChat("你不能离开行会,因为你是领导者。", ChatType.System); return(false); } for (int i = 0; i < MemberRank.Members.Count; i++) { if ((MemberRank.Members[i].Online) && (MemberRank.Members[i] != Member)) { goto AllOk; } } Kicker.ReceiveChat("需要至少1个行会领导在线。", ChatType.System); return(false); } AllOk: MemberDeleted(membername, (PlayerObject)Member.Player, Member.name == Kicker.Info.Name); if (Member.Player != null) { PlayerObject LeavingMember = (PlayerObject)Member.Player; LeavingMember.RefreshStats(); } MemberRank.Members.Remove(Member); NeedSave = true; Membercount--; return(true); }
void Update() { Player player = Player.localPlayer; if (player) { // hotkey (not while typing in chat, etc.) if (Input.GetKeyDown(hotKey) && !UIUtils.AnyInputActive()) { panel.SetActive(!panel.activeSelf); } // only update the panel if it's active if (panel.activeSelf) { Guild guild = player.guild; int memberCount = guild.members != null ? guild.members.Length : 0; // guild properties nameText.text = player.guild.name; masterText.text = guild.master; currentCapacityText.text = memberCount.ToString(); maximumCapacityText.text = GuildSystem.Capacity.ToString(); // notice edit button noticeEditButton.interactable = guild.CanNotify(player.name) && !noticeInput.interactable; noticeEditButton.onClick.SetListener(() => { noticeInput.interactable = true; }); // notice set button noticeSetButton.interactable = guild.CanNotify(player.name) && noticeInput.interactable && NetworkTime.time >= player.nextRiskyActionTime; noticeSetButton.onClick.SetListener(() => { noticeInput.interactable = false; if (noticeInput.text.Length > 0 && !string.IsNullOrWhiteSpace(noticeInput.text) && noticeInput.text != guild.notice) { player.CmdSetGuildNotice(noticeInput.text); } }); // notice input: copies notice while not editing it if (!noticeInput.interactable) { noticeInput.text = guild.notice ?? ""; } noticeInput.characterLimit = GuildSystem.NoticeMaxLength; // leave leaveButton.interactable = guild.CanLeave(player.name); leaveButton.onClick.SetListener(() => { player.CmdLeaveGuild(); }); // instantiate/destroy enough slots UIUtils.BalancePrefabs(slotPrefab.gameObject, memberCount, memberContent); // refresh all members for (int i = 0; i < memberCount; ++i) { UIGuildMemberSlot slot = memberContent.GetChild(i).GetComponent <UIGuildMemberSlot>(); GuildMember member = guild.members[i]; slot.onlineStatusImage.color = member.online ? onlineColor : offlineColor; slot.nameText.text = member.name; slot.levelText.text = member.level.ToString(); slot.rankText.text = member.rank.ToString(); slot.promoteButton.interactable = guild.CanPromote(player.name, member.name); slot.promoteButton.onClick.SetListener(() => { player.CmdGuildPromote(member.name); }); slot.demoteButton.interactable = guild.CanDemote(player.name, member.name); slot.demoteButton.onClick.SetListener(() => { player.CmdGuildDemote(member.name); }); slot.kickButton.interactable = guild.CanKick(player.name, member.name); slot.kickButton.onClick.SetListener(() => { player.CmdGuildKick(member.name); }); } } } else { panel.SetActive(false); } }
public MessageAuthor(DiscordUser user, GuildMember member) { User = user; Member = member; }
public override void Deserialize(ICustomDataInput reader) { m_member = new GuildMember(); m_member.Deserialize(reader); }
private void OnAddMemberUpdateEvent(GuildMember gdMb) { this.mGuildMemberTabLayer.AddMemberItem(gdMb); }
public void OnMsgGuildMemberUpdate(MemoryStream stream) { MS2C_GuildMemberUpdate mS2C_GuildMemberUpdate = Serializer.NonGeneric.Deserialize(typeof(MS2C_GuildMemberUpdate), stream) as MS2C_GuildMemberUpdate; GuildMember guildMember = this.GetMember(mS2C_GuildMemberUpdate.ID); if (guildMember == null) { if (mS2C_GuildMemberUpdate.ID == 0uL) { return; } guildMember = new GuildMember(); guildMember.ID = mS2C_GuildMemberUpdate.ID; guildMember.Level = mS2C_GuildMemberUpdate.Level; guildMember.TotalReputation = mS2C_GuildMemberUpdate.TotalReputation; guildMember.CurReputation = mS2C_GuildMemberUpdate.CurReputation; guildMember.Rank = mS2C_GuildMemberUpdate.Rank; guildMember.Flag = mS2C_GuildMemberUpdate.Flag; guildMember.LastOnlineTime = mS2C_GuildMemberUpdate.LastOnlineTime; guildMember.Name = mS2C_GuildMemberUpdate.Name; this.Members.Add(guildMember); if (this.AddMemberUpdateEvent != null) { this.AddMemberUpdateEvent(guildMember); } } else { if (mS2C_GuildMemberUpdate.Level != 0) { guildMember.Level = mS2C_GuildMemberUpdate.Level; } if (mS2C_GuildMemberUpdate.TotalReputation != 0) { guildMember.TotalReputation = mS2C_GuildMemberUpdate.TotalReputation; } if (mS2C_GuildMemberUpdate.CurReputation != 0) { if (mS2C_GuildMemberUpdate.CurReputation == -1) { guildMember.CurReputation = 0; } else { guildMember.CurReputation = mS2C_GuildMemberUpdate.CurReputation; } } if (mS2C_GuildMemberUpdate.Rank != 0) { guildMember.Rank = mS2C_GuildMemberUpdate.Rank; } if (mS2C_GuildMemberUpdate.Flag != 0) { guildMember.Flag = mS2C_GuildMemberUpdate.Flag; } if (this.MemberUpdateEvent != null) { this.MemberUpdateEvent(guildMember); } } }
public void NewMember(PlayerObject newmember) { if (Ranks.Count < 2) Ranks.Add(new Rank() { Name = "Members", Index = 1}); Rank currentrank = Ranks[Ranks.Count - 1]; GuildMember Member = new GuildMember() { name = newmember.Info.Name, Player = newmember, Id = newmember.Info.Index, LastLogin = Envir.Now, Online = true }; currentrank.Members.Add(Member); PlayerLogged(newmember, true, true); newmember.RefreshStats(); newmember.Enqueue(new ServerPackets.GuildBuffList() { ActiveBuffs = BuffList }); Membercount++; NeedSave = true; }
public virtual void InitPopUp(GuildMember guildMember) { }
private void DisplayChatMessage(string message, GuildMember member) { DamageNumberManager.DisplayMessage(message, member.gameObject.transform); ChatBox.Instance.AddChatMessage(string.Format("[{0}]{1}[-]: {2}", ColorToHex(member.Config.Color), member.Name, message)); }
protected override void Awake() { _guildMember = GetComponent<GuildMember>(); base.Awake(); }
public void NewMember(PlayerObject newmember) { if (Ranks.Count < 2) Ranks.Add(new Rank() { Name = "Members", Index = 1}); Rank currentrank = Ranks[Ranks.Count - 1]; GuildMember Member = new GuildMember() { name = newmember.Info.Name, Player = newmember, Id = newmember.Info.Index, LastLogin = Envir.Now, Online = true }; currentrank.Members.Add(Member); PlayerLogged(newmember, true, true); Membercount++; NeedSave = true; }
private void CancelApplication(HttpRequest req, Guild guild, GuildMember member, ref string success, ref string error) { member.Rank = GuildMemberRank.Declined; WebServer.Instance.Database.UpdateGuildMemberRank(member); success = "Your application will be canceled shortly."; }
public GuildInformationsMemberUpdateMessage(GuildMember member) { m_member = member; }
private void LeaveGuild(HttpRequest req, Guild guild, GuildMember member, ref string success, ref string error) { member.Rank = GuildMemberRank.Declined; WebServer.Instance.Database.UpdateGuildMemberRank(member); success = "You will be leaving the guild shortly."; }
public override bool TakeAction() { int nameLength = System.Text.Encoding.Default.GetByteCount(guildName); List <UserQueue> queueArray = new GameDataCacheSet <UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.TuiChuGongHui); if (queueArray.Count > 0 && queueArray[0].DoRefresh() > 0 && queueArray[0].IsSuspend == false) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St6006_GuildMemberNotDate; return(false); } int createGoinNum = ConfigEnvSet.GetInt("UserGuild.CreateGoinNum"); int createLv = ConfigEnvSet.GetInt("UserGuild.CreateUserLv"); if (ContextUser.UserLv < createLv) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_LevelNotEnough; return(false); } if (ContextUser.GameCoin < createGoinNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough; return(false); } if (guildName == "") { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St6017_GuildNameNotEmpty; return(false); } if (nameLength < 4 || nameLength > 12) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St6017_GuildNameTooLong; return(false); } List <GuildMember> memberArray = new ShareCacheStruct <GuildMember>().FindAll(m => m.UserID == ContextUser.UserID); if (memberArray.Count > 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St6017_UnionMembers; return(false); } List <UserGuild> guildArray = new ShareCacheStruct <UserGuild>().FindAll(u => u.GuildName == guildName); if (guildArray.Count > 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St6017_GuildRename; return(false); } List <UserGuild> userGuildArray = new ShareCacheStruct <UserGuild>().FindAll(); int rankID = 0; if (userGuildArray.Count > 0) { rankID = MathUtils.Addition(userGuildArray.Count, 1, int.MaxValue); } else { rankID = 1; } string guildID = Guid.NewGuid().ToString(); ContextUser.MercenariesID = guildID; ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, createGoinNum, 0); UserGuild userGuild = new UserGuild() { GuildID = guildID, UserID = ContextUser.UserID, GuildName = guildName, GuildLv = 1, GuildRank = rankID, WeekExperience = 0, CurrExperience = 0, CreateDate = DateTime.Now, }; new ShareCacheStruct <UserGuild>().Add(userGuild, GameEnvironment.CacheGlobalPeriod); GuildMember member = new GuildMember() { GuildID = guildID, UserID = ContextUser.UserID, PostType = PostType.Chairman, Contribution = 0, TotalContribution = 0, DevilNum = 0, SummonNum = 0, IsDevil = 0, IncenseNum = 0, InsertDate = DateTime.Now }; new ShareCacheStruct <GuildMember>().Add(member, GameEnvironment.CacheGlobalPeriod); var temp = new ShareCacheStruct <GuildMember>().FindKey(guildID, ContextUser.UserID); if (temp.HasChanged) { TraceLog.WriteInfo("6017 GuildMember update success."); } GuildIdol idolInfo = new GuildIdol() { GuildID = guildID, IdolLv = 1, CurrExperience = 0 }; new ShareCacheStruct <GuildIdol>().Add(idolInfo, GameEnvironment.CacheGlobalPeriod); return(true); }
private void DeclineApplication(HttpRequest req, Guild guild, GuildMember member, ref string success, ref string error) { member.Rank = GuildMemberRank.Declined; WebServer.Instance.Database.UpdateGuildMemberRank(member); success = string.Format("{0}'s application has been declined.", member.Name); }
private void SpawnGuildMembers(GuildMember.GuildMemberType type, int count, bool pug = false) { for (int i = 0; i < count; i++) { var position = transform.position; position.y += (_membersSpawned % 2) == 0 ? 0 : MemberSpacing + Random.Range(-0.1f, 0.1f); position.x += (_membersSpawned / 2) * MemberSpacing + Random.Range(-0.3f, 0.3f); var memberGo = (GameObject)Instantiate(Prefab, position, Quaternion.identity); var guildMember = memberGo.GetComponent<GuildMember>(); guildMember.MemberType = type; _membersSpawned++; if (pug) guildMember.PickUpGroup(); } }
private void RemoveMember(HttpRequest req, Guild guild, GuildMember member, ref string success, ref string error) { member.Rank = GuildMemberRank.Declined; WebServer.Instance.Database.UpdateGuildMemberRank(member); success = string.Format("{0} will get removed from the guild shortly.", member.Name); }
public bool ChangeRank(PlayerObject Self, string membername, byte RankIndex, string RankName = "Members") { if ((Self.MyGuild != this) || (Self.MyGuildRank == null)) { return(false); } if (RankIndex >= Ranks.Count) { return(false); } GuildMember Member = null; Rank MemberRank = null; for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { if (Ranks[i].Members[j].name == membername) { Member = Ranks[i].Members[j]; MemberRank = Ranks[i]; goto Found; } } } Found: if (Member == null) { return(false); } MirDatabase.CharacterInfo Character = Envir.GetCharacterInfo(membername); if (Character == null) { return(false); } if ((RankIndex == 0) && (Character.Level < Settings.Guild_RequiredLevel)) { Self.ReceiveChat(String.Format("行会领导者至少需要{0}级。", Settings.Guild_RequiredLevel), ChatType.System); return(false); } if ((MemberRank.Index >= Self.MyGuildRank.Index) && (Self.MyGuildRank.Index != 0)) { return(false); } if (MemberRank.Index == 0) { if (MemberRank.Members.Count <= 2) { Self.ReceiveChat("行会至少需要2名领导。", ChatType.System); return(false); } for (int i = 0; i < MemberRank.Members.Count; i++) { if ((MemberRank.Members[i].Player != null) && (MemberRank.Members[i] != Member)) { goto AllOk; } } Self.ReceiveChat("需要至少1个领导在线。", ChatType.System); return(false); } AllOk: Ranks[RankIndex].Members.Add(Member); MemberRank.Members.Remove(Member); MemberRank = Ranks[RankIndex]; List <Rank> NewRankList = new List <Rank>(); NewRankList.Add(Ranks[RankIndex]); NeedSave = true; PlayerObject player = (PlayerObject)Member.Player; if (player != null) { player.MyGuildRank = Ranks[RankIndex]; player.Enqueue(new ServerPackets.GuildMemberChange() { Name = Self.Info.Name, Status = (byte)8, Ranks = NewRankList }); player.BroadcastInfo(); } for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { if ((Ranks[i].Members[j].Player != null) && (Ranks[i].Members[j].Player != Member.Player)) { player = (PlayerObject)Ranks[i].Members[j].Player; player.Enqueue(new ServerPackets.GuildMemberChange() { Name = Member.name, Status = (byte)5, RankIndex = (byte)MemberRank.Index }); player.GuildMembersChanged = true; } } } return(true); }
public GuildMemberItemData(GuildMember gdm) { this.MemberData = gdm; }
public static MenuFlyout MakeVoiceMemberMenu(GuildMember member) { MenuFlyout menu = new MenuFlyout(); menu.MenuFlyoutPresenterStyle = (Style)App.Current.Resources["MenuFlyoutPresenterStyle1"]; // Add "Profile" button MenuFlyoutItem profile = new MenuFlyoutItem() { Text = App.GetString("/Flyouts/Profile"), Tag = member.User, Icon = new SymbolIcon(Symbol.ContactInfo) }; profile.Click += FlyoutManager.OpenProfile; menu.Items.Add(profile); // If member is not current user if (member.User.Id != LocalState.CurrentUser.Id) { // Add "Message" button MenuFlyoutItem message = new MenuFlyoutItem() { Text = App.GetString("/Flyouts/Message"), Tag = member.User.Id, Icon = new SymbolIcon(Symbol.Message) }; message.Click += FlyoutManager.MessageUser; menu.Items.Add(message); } // Add Separator MenuFlyoutSeparator sep1 = new MenuFlyoutSeparator(); menu.Items.Add(sep1); // If not current user if (member.User.Id != LocalState.CurrentUser.Id) { // Create "Invite to Server" sub item MenuFlyoutSubItem InviteToServer = new MenuFlyoutSubItem() { Text = App.GetString("/Flyouts/InviteToServer") //Tag = member.Raw.User.Id, //Icon = new SymbolIcon(Symbol.) }; // Check all Guilds foreach (KeyValuePair <string, LocalModels.Guild> guild in LocalState.Guilds) { // If can Create Instant Invite if (guild.Value.permissions.Administrator || guild.Value.permissions.CreateInstantInvite) { // Add Guild to list MenuFlyoutItem item = new MenuFlyoutItem() { Text = guild.Value.Raw.Name, Tag = new Tuple <string, string>(guild.Value.channels.FirstOrDefault().Value.raw.Id, member.User.Id) }; item.Click += FlyoutManager.InviteToServer; InviteToServer.Items.Add(item); } } // Add "Invite to Server" to menu menu.Items.Add(InviteToServer); } // Create "Add Friend" button MenuFlyoutItem addFriend = new MenuFlyoutItem() { Text = App.GetString("/Flyouts/AddFriend"), Tag = member.User.Id, Icon = new SymbolIcon(Symbol.AddFriend) }; addFriend.Click += FlyoutManager.AddFriend; // Create "Remove Friend" button MenuFlyoutItem removeFriend = new MenuFlyoutItem() { Text = App.GetString("/Flyouts/RemoveFriend"), Tag = member.User.Id, Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 71, 71)), Icon = new SymbolIcon(Symbol.ContactPresence) }; removeFriend.Click += FlyoutManager.RemoveFriend; // Create "Block" button MenuFlyoutItem block = new MenuFlyoutItem() { Text = App.GetString("/Flyouts/Block"), Tag = member.User.Id, Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 71, 71)), Icon = new SymbolIcon(Symbol.BlockContact) }; block.Click += FlyoutManager.BlockUser; // Create "Unblock" button MenuFlyoutItem unBlock = new MenuFlyoutItem() { Text = App.GetString("/Flyouts/Unblock"), Tag = member.User.Id, Icon = new SymbolIcon(Symbol.ContactPresence) }; unBlock.Click += FlyoutManager.RemoveFriend; // Create "Accept Friend Request" button MenuFlyoutItem acceptFriendRequest = new MenuFlyoutItem() { Text = App.GetString("/Flyouts/AcceptFriendRequest"), Tag = member.User.Id, Icon = new SymbolIcon(Symbol.AddFriend) }; acceptFriendRequest.Click += FlyoutManager.AddFriend; // Choose which buttons to show if (LocalState.Friends.ContainsKey(member.User.Id)) { switch (LocalState.Friends[member.User.Id].Type) { // No relation case 0: // Add "Add Friend" and "Block" buttons menu.Items.Add(addFriend); menu.Items.Add(block); break; // Friend case 1: // Add "Remove Friend" and "Block" buttons menu.Items.Add(removeFriend); menu.Items.Add(block); break; // Blocked case 2: // Add "Block" button menu.Items.Add(unBlock); break; // Incoming Friend Request case 3: // Add "Accept Friend Request" button menu.Items.Add(acceptFriendRequest); menu.Items.Add(block); break; // Outgoing Friend Request case 4: // Add "Block" button menu.Items.Add(block); break; } } // Member is current user else if (member.User.Id == LocalState.CurrentUser.Id) { // No buttons for current user } else { // Default to no relation menu.Items.Add(addFriend); menu.Items.Add(block); } // If member is not current user if (member.User.Id != LocalState.CurrentUser.Id) { MenuFlyoutSeparator sep2 = new MenuFlyoutSeparator(); menu.Items.Add(sep2); } // If can change user's nickname if (Permissions.CanChangeNickname(member.User.Id, App.CurrentGuildId)) { // Add "Change Nickname" button MenuFlyoutItem changeNickname = new MenuFlyoutItem() { Text = App.GetString("/Flyouts/ChangeNickname"), Tag = member.User.Id, Icon = new SymbolIcon(Symbol.Rename) }; changeNickname.Click += FlyoutManager.ChangeNickname; menu.Items.Add(changeNickname); } // If Current User has manage roles permission if (LocalState.Guilds[App.CurrentGuildId].permissions.Administrator || LocalState.Guilds[App.CurrentGuildId].permissions.ManageRoles) { // Create "Roles" subitem MenuFlyoutSubItem roles = new MenuFlyoutSubItem() { Text = App.GetString("/Flyouts/Roles") //Tag = member.Raw.User.Id, //Icon = new SymbolIcon(Symbol.) }; // Add Server's roles to Role SubItem foreach (DiscordAPI.SharedModels.Role role in LocalState.Guilds[App.CurrentGuildId].roles.Values.OrderByDescending(x => x.Position)) { ToggleMenuFlyoutItem roleItem = new ToggleMenuFlyoutItem() { Text = role.Name, Tag = new Tuple <string, string>(role.Id, member.User.Id), Foreground = Common.IntToColor(role.Color), IsChecked = member.Roles != null && member.Roles.Contains(role.Id), //Style = (Style)App.Current.Resources["ToggleOnlyCheckbox"], IsEnabled = LocalState.Guilds[App.CurrentGuildId].members[LocalState.CurrentUser.Id].Roles.FirstOrDefault() != null && role.Position < LocalState.Guilds[App.CurrentGuildId].roles[LocalState.Guilds[App.CurrentGuildId].members[LocalState.CurrentUser.Id].Roles.FirstOrDefault()].Position || LocalState.Guilds[App.CurrentGuildId].Raw.OwnerId == LocalState.CurrentUser.Id //TODO: Double check role system }; roleItem.Click += FlyoutManager.AddRole; if (role.Name != "@everyone") { roles.Items.Add(roleItem); } } // Add Roles subitem to menu menu.Items.Add(roles); } // If Current User has kick members permission if ((LocalState.Guilds[App.CurrentGuildId].permissions.Administrator || LocalState.Guilds[App.CurrentGuildId].permissions.KickMembers) && LocalState.Guilds[App.CurrentGuildId].GetHighestRole(member.Roles).Position < LocalState.Guilds[App.CurrentGuildId].GetHighestRole(LocalState.Guilds[App.CurrentGuildId].members[LocalState.CurrentUser.Id].Roles).Position || LocalState.Guilds[App.CurrentGuildId].Raw.OwnerId == LocalState.CurrentUser.Id && member.User.Id != LocalState.CurrentUser.Id) { // Add "Kick Member" button MenuFlyoutItem kickMember = new MenuFlyoutItem() { Text = App.GetString("/Flyouts/KickMember"), Tag = member.User.Id, Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 71, 71)), Icon = new SymbolIcon(Symbol.BlockContact) }; kickMember.Click += FlyoutManager.KickMember; menu.Items.Add(kickMember); } // If Member is current user and current user is not owner else if (member.User.Id == LocalState.CurrentUser.Id && LocalState.Guilds[App.CurrentGuildId].Raw.OwnerId != LocalState.CurrentUser.Id) { // Add "Leave Server" button MenuFlyoutItem leaveServer = new MenuFlyoutItem() { Text = App.GetString("/Flyouts/LeaveServer"), Tag = member.User.Id, Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 71, 71)), Icon = new SymbolIcon(Symbol.Remove) }; leaveServer.Click += FlyoutManager.LeaveServer; menu.Items.Add(leaveServer); } // If User has ban members permission if (((LocalState.Guilds[App.CurrentGuildId].permissions.Administrator || LocalState.Guilds[App.CurrentGuildId].permissions.BanMembers) && LocalState.Guilds[App.CurrentGuildId].GetHighestRole(member.Roles).Position < LocalState.Guilds[App.CurrentGuildId].GetHighestRole(LocalState.Guilds[App.CurrentGuildId].members[LocalState.CurrentUser.Id].Roles).Position) || LocalState.Guilds[App.CurrentGuildId].Raw.OwnerId == LocalState.CurrentUser.Id && member.User.Id != LocalState.CurrentUser.Id) { // Add "Ban Member" button MenuFlyoutItem banMember = new MenuFlyoutItem() { Text = App.GetString("/Flyouts/BanMember"), Tag = member.User.Id, Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 71, 71)), Icon = new SymbolIcon(Symbol.BlockContact) }; banMember.Click += FlyoutManager.BanMember; menu.Items.Add(banMember); } // If member is a bot if (member.User.Bot) { // Add Separator menu.Items.Add(new MenuFlyoutSeparator()); // Add extra bot specific stuff foreach (var feature in BotExtrasManager.GetBotFeatures(member.User.Id)) { MenuFlyoutItem link = new MenuFlyoutItem() { Text = feature.Name, Tag = feature.Url, Icon = new FontIcon() { Glyph = feature.Icon } }; link.Click += FlyoutManager.OpenURL; menu.Items.Add(link); } } return(menu); }
private void DisplayChatMessage(string[] messages, GuildMember member) { var message = messages[Random.Range(0, messages.Length)]; DamageNumberManager.DisplayMessage(message, member.gameObject.transform); ChatBox.Instance.AddChatMessage(string.Format("[{0}]{1}[-]: {2}", ColorToHex(member.Config.Color), member.Name, message)); }