private static void HandleChatEmoticonAdd(GameSession session, Item item) { long expiration = long.MaxValue; if (item.Function.ChatEmoticonAdd.Duration > 0) { expiration = item.Function.ChatEmoticonAdd.Duration + TimeInfo.Now(); } // sticker exists and no expiration if (session.Player.ChatSticker.Any(p => p.GroupId == item.Function.ChatEmoticonAdd.Id && p.Expiration == long.MaxValue)) { return; } // Add time if the sticker is already in the list ChatSticker sticker = session.Player.ChatSticker.FirstOrDefault(p => p.GroupId == item.Function.ChatEmoticonAdd.Id); if (sticker is not null && sticker.Expiration != long.MaxValue) { expiration += sticker.Expiration - TimeInfo.Now(); } session.Send(ChatStickerPacket.AddSticker(item.Id, item.Function.ChatEmoticonAdd.Id, expiration)); session.Player.ChatSticker.Add(new((byte)item.Function.ChatEmoticonAdd.Id, expiration)); session.Player.Inventory.ConsumeItem(session, item.Uid, 1); }
/// <summary> /// Broadcasts ChatSticker in range of creature, activating the sticker. /// </summary> /// <param name="creature"></param> /// <param name="sticker"></param> /// <param name="end"></param> public static void ChatSticker(Creature creature, ChatSticker sticker, DateTime end) { var packet = new Packet(Op.ChatSticker, creature.EntityId); packet.PutInt((int)sticker); packet.PutLong(end); creature.Region.Broadcast(packet, creature); }
/// <summary> /// Activates the sticker for the given duration. /// </summary> /// <param name="sticker">Sticker to activate.</param> /// <param name="duration">Duration in seconds.</param> protected void ActivateChatSticker(Creature creature, ChatSticker sticker, int duration) { var end = DateTime.Now.AddSeconds(duration); creature.Vars.Perm["ChatStickerId"] = (int)sticker; creature.Vars.Perm["ChatStickerEnd"] = end; Send.ChatSticker(creature, sticker, end); Send.Notice(creature, Localization.Get("You carefully attach the sticker to your Chat Bubble.")); }