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 = DateTimeOffset.UtcNow.ToUnixTimeSeconds() + Environment.TickCount; session.Send(GuildPacket.CheckInBegin()); Item guildCoins = new Item(30000861) { Amount = property.AttendGuildCoin }; InventoryController.Add(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)); }
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(30000861) { Rarity = 4, Amount = guildProperty.DonateGuildCoin * donateQuantity }; 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)); }