public void HandleTextEmote(ref IPacketReader packet, ref IWorldManager manager) { uint emote = packet.ReadUInt32(); ulong guid = packet.ReadUInt64(); uint emoteId = Emotes.Get((TextEmotes)emote); Character character = (Character)manager.Account.ActiveCharacter; PacketWriter pw = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_TEXT_EMOTE], "SMSG_TEXT_EMOTE"); pw.Write(character.Guid); pw.Write(emote); if (guid == character.Guid) { pw.WriteString(character.Name); } else { pw.WriteUInt8(0); } manager.Send(pw); switch ((TextEmotes)emote) { case TextEmotes.EMOTE_SIT: character.StandState = StandState.SITTING; manager.Send(character.BuildUpdate()); return; case TextEmotes.EMOTE_STAND: character.StandState = StandState.STANDING; manager.Send(character.BuildUpdate()); return; case TextEmotes.EMOTE_SLEEP: character.StandState = StandState.SLEEPING; manager.Send(character.BuildUpdate()); return; case TextEmotes.EMOTE_KNEEL: character.StandState = StandState.KNEEL; manager.Send(character.BuildUpdate()); return; } if (emoteId > 0) { pw = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_EMOTE], "SMSG_EMOTE"); pw.WriteUInt32(emoteId); pw.WriteUInt64(character.Guid); manager.Send(pw); } }
public void HandleTextEmote(ref IPacketReader packet, ref IWorldManager manager) { // I don't like to do this but since its the only packet change // it's really not worth creating a whole new plugin for it bool build_4211 = packet.Size == 22; uint emote = packet.ReadUInt32(), emotenum = 0; if (build_4211) { emotenum = packet.ReadUInt32(); } ulong guid = packet.ReadUInt64(); uint emoteId = Emotes.Get((TextEmotes)emote); Character character = (Character)manager.Account.ActiveCharacter; PacketWriter pw = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_TEXT_EMOTE], "SMSG_TEXT_EMOTE"); pw.Write(character.Guid); pw.Write(emote); if (build_4211) { pw.WriteInt64(0); } else { pw.WriteInt32(1); pw.WriteUInt8(0); } manager.Send(pw); switch ((TextEmotes)emote) { case TextEmotes.EMOTE_SIT: character.StandState = StandState.SITTING; manager.Send(character.BuildUpdate()); return; case TextEmotes.EMOTE_STAND: character.StandState = StandState.STANDING; manager.Send(character.BuildUpdate()); return; case TextEmotes.EMOTE_SLEEP: character.StandState = StandState.SLEEPING; manager.Send(character.BuildUpdate()); return; case TextEmotes.EMOTE_KNEEL: character.StandState = StandState.KNEEL; manager.Send(character.BuildUpdate()); return; } if (emoteId > 0) { pw = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_EMOTE], "SMSG_EMOTE"); pw.WriteUInt32(emoteId); pw.WriteUInt64(character.Guid); manager.Send(pw); } }
public async Task Price() { try { if (Context.Channel is IDMChannel) { await Discord.ReplyAsync(Context, message : "Please make this request in one of the official channels."); return; } if (!config.ChannelIds.Contains(Context.Channel.Id)) { return; } using (var a = Context.Channel.EnterTypingState()) { log.Info("Requesting prices and stats"); var newReq = new Request { Type = RequestType.Price, User = Context.User.ToString(), }; var req = await db.Requests .Where(x => x.Type == RequestType.Price && x.Response == RequestResponse.OK) .OrderByDescending(x => x.Date) .FirstOrDefaultAsync() .ConfigureAwait(false); if (req != null) { var secs = (req.Date.AddSeconds(config.RequestCooldown) - DateTime.UtcNow); if (secs.TotalSeconds > 0) { await Discord.ReplyAsync(Context, message : $"Requesting too fast. Please wait {Math.Ceiling(secs.TotalSeconds)} more seconds."); newReq.Response = RequestResponse.RateLimited; newReq.Date = DateTime.UtcNow; db.Add(newReq); await db.SaveChangesAsync().ConfigureAwait(false); log.Info("Request rate limited"); return; } } var emotes = new Emotes(Context); var dynamite = await emotes.Get(config.EmoteDynamite).ConfigureAwait(false); var item = await Data.Common.GetStats(db).ConfigureAwait(false); log.Debug($"Prices for stat group {item.Stat.Group} not found"); string title = $"Current Price and Statistics"; string footerText = $"{item.Price.Date.ToDate()}. Powered by Etherscan.io & CoinGecko APIs."; if (item.IsOutOfSync()) { footerText += " Stats might be out of sync. The admin has been contacted."; } var output = new EmbedBuilder(); output.WithColor(Color.DYNAMITE_RED) .WithAuthor(author => { author.WithName(title); }) .WithDescription($"**{item.Stat.BurnLast24H.FormatDyt()} DYT** have been burned in the last 24 hours! {dynamite}") .AddField($"— Market (Weighted Average)", "```ml\n" + $"Price/USD: ${item.Price.PriceUSD.FormatUsd()}\n" + $"Price/BTC: ₿{item.Price.PriceBTC.FormatBtc()}\n" + $"Price/ETH: Ξ{item.Price.PriceETH.FormatDyt(false)}\n" + $"Market Cap: ${item.Price.MarketCapUSD.FormatLarge()}\n" + $"Volume/24H: ${item.Price.VolumeUSD.FormatLarge()}" + "```") .AddField($"— Statistics (DYT)", "```ml\n" + $"Transactions: {item.Stat.Transactions.Format()}\n" + $"Total Supply: {item.Stat.Supply.FormatDyt()}\n" + $"Total Burned: {item.Stat.Burned.FormatDyt()} (Rate: {item.Stat.BurnAvgDay.FormatDyt()}/day)\n" + $"Burn/Last/1H: {item.Stat.BurnLast1H.FormatDyt()}\n" + $"Burn/Last/24H: {item.Stat.BurnLast24H.FormatDyt()}" + "```") .WithFooter(footer => { footer.WithText(footerText); }); await Discord.ReplyAsync(Context, output, deleteUserMessage : false).ConfigureAwait(false); newReq.Response = RequestResponse.OK; newReq.Date = DateTime.UtcNow; db.Add(newReq); await db.SaveChangesAsync().ConfigureAwait(false); log.Info("Prices and stats successfully sent"); } } catch (Exception ex) { log.Error(ex); throw ex; } }