No entanto, a estrutura permaneceu a mesma desde PRODUÇÃO-201610312204-296063264 e talvez até antes disso. Foi essa compilação quando criei pela primeira vez, então sei com certeza que não mudou desde então.
Eu não codifiquei "Force Open", mas se você quiser, o id do pacote é 2799 e a estrutura é string, int. A string é o nome do evento (xmas16) e o int é o id do dia. Não há nenhum uso nisso e eu sou preguiçoso! xD - Se você quiser, basta editar o presente aberto e remover a verificação do tempo e verificar se o usuário é um administrador.
Agora você vai querer abrir o GameClient.cs e encontrar
Código:
_habbo.InitProcess();
Código:
if (PlusStaticGameSettings.CampaignCalendarEnabled)
SendMessage(new CampaignCalendarDataComposer(_habbo.GetStats().openedGifts));
Código:
using Plus.Communication.Packets.Outgoing.Campaigns;
Código:
public const bool NewUserTutorialBotEnabled = true;
Código:
public const bool CampaignCalendarEnabled = true;
Código:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Plus.Communication.Packets.Outgoing.Campaigns
{
class CampaignCalendarDataComposer : ServerPacket
{
public CampaignCalendarDataComposer(List OpenedGifts)
: base(ServerPacketHeader.CampaignCalendarDataMessageComposer)
{
int currentDate = DateTime.Now.Day - 1;
base.WriteString("xmas16"); //eventTrigger
base.WriteString(string.Empty); //idk? same as habbo ;P
base.WriteInteger(currentDate); //currentDate
base.WriteInteger(25); //totalAmountOfDays
base.WriteInteger(OpenedGifts.Count); //countOpenGifts
foreach (int Opened in OpenedGifts)
{
base.WriteInteger(Opened); //giftDay
}
List MissedGifts = Enumerable.Range(0, (currentDate - 2)).Where(Day => !OpenedGifts.Contains(Day)).ToList();
base.WriteInteger(MissedGifts.Count); //countMissedGifts
foreach (int Missed in MissedGifts)
{
base.WriteInteger(Missed); //giftDay
}
}
}
}
Código:
public const int CampaignCalendarDataMessageComposer = 2740; //updated
public const int CampaignCalendarGiftMessageComposer = 163; //updated
Código:
using Plus.Communication.Packets.Outgoing.Inventory.Furni;
using Plus.Communication.Packets.Outgoing.LandingView;
using Plus.Database.Interfaces;
using Plus.HabboHotel.Items;
using Plus.HabboHotel.Users;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Plus.Communication.Packets.Incoming.LandingView
{
class OpenCalendarBoxEvent : IPacketEvent
{
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
{
string eventName = Packet.PopString();
int giftDay = Packet.PopInt();
HabboStats habboStats = Session?.GetHabbo()?.GetStats();
int currentDay = DateTime.Now.Day - 1;
if (!PlusStaticGameSettings.CampaignCalendarEnabled || habboStats == null ||
habboStats.openedGifts.Contains(giftDay) || giftDay < (currentDay-2) ||
giftDay > currentDay || eventName != "xmas16")
{
return;
}
Item newItem = null;
if(!PlusEnvironment.GetGame().GetLandingManager().GenerateCalendarItem(
Session.GetHabbo(), eventName, giftDay, out newItem))
{
return;
}
habboStats.addOpenedGift(giftDay);
Session.GetHabbo().GetInventoryComponent().TryAddItem(newItem);
Session.SendMessage(new FurniListUpdateComposer());
Session.SendMessage(new CampaignCalendarGiftComposer(newItem.Data.ItemName));
}
}
}
Código:
this._incomingPackets.Add(ClientPacketHeader.GetPromoArticlesMessageEvent, new GetPromoArticlesEvent());
Código:
this._incomingPackets.Add(ClientPacketHeader.OpenCalendarBoxMessageEvent, new OpenCalendarBoxEvent());
Código:
this._packetNames.Add(ClientPacketHeader.GetPromoArticlesMessageEvent, "RefreshPromoEvent");
Código:
this._packetNames.Add(ClientPacketHeader.OpenCalendarBoxMessageEvent, "CampaignCalendarGiftEvent");
Código:
public const int UseWallItemMessageEvent = 3940;
Código:
public const int OpenCalendarBoxMessageEvent = 3214; //updated
Código:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Plus.Communication.Packets.Outgoing.LandingView
{
class CampaignCalendarGiftComposer : ServerPacket
{
public CampaignCalendarGiftComposer(string iconName = "throne")
: base(ServerPacketHeader.CampaignCalendarGiftMessageComposer)
{
base.WriteBoolean(true); // never bothered to check
base.WriteString("xmas14_starfish"); //productName
base.WriteString(""); //customImage
base.WriteString(iconName); //iconName
}
}
}
Em seguida, você quer ir para LandingViewManager.cs e adicionar a seguinte função (eles devem ser armazenados em cache, mas eu sou preguiçoso xD e isso foi feito por diversão, não uma versão pública)
Código:
public bool GenerateCalendarItem(Habbo Habbo, string eventName, int eventDate, out Item newItem)
{
newItem = null;
using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
{
dbClient.SetQuery("SELECT `item_id` FROM `campaign_calendar_gifts` WHERE `event_name` = @eventName AND `base_id` = @dayId LIMIT 1");
dbClient.AddParameter("eventName", eventName);
dbClient.AddParameter("dayId", eventDate);
DataRow row = dbClient.getRow();
ItemData itemData = null;
if (row?["item_id"] != null &&
PlusEnvironment.GetGame().GetItemManager().GetItem((string)row["item_id"], out itemData))
{
newItem = ItemFactory.CreateSingleItemNullable(itemData, Habbo, "", "");
return newItem != null;
}
return false;
}
}
Código:
public bool GetItem(int Id, out ItemData Item)
Código:
public bool GetItem(string itemName, out ItemData item)
{
item = this._items.Values.Where(x => x.ItemName == itemName).FirstOrDefault();
return item != null;
}
Código:
public int ForumPosts { get; set; }
Código:
public List openedGifts { get; private set; }
public void addOpenedGift(int eventDate)
{
if (this.openedGifts.Contains(eventDate))
{
return;
}
this.openedGifts.Add(eventDate);
string[] giftData = this.openedGifts.Select(giftDay => giftDay.ToString()).ToArray();
using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
{
dbClient.SetQuery("UPDATE `user_stats` SET `calendar_gifts` = @giftData WHERE `id` = @habboId LIMIT 1");
dbClient.AddParameter("giftData", string.Join(",", giftData));
dbClient.AddParameter("habboId", habboId);
dbClient.RunQuery();
}
}
Código:
this.ForumPosts = ForumPosts;
Código:
this.openedGifts = new List();
foreach (string subStr in openedGifts.Split(','))
{
int openedDay = 0;
if (int.TryParse(subStr, out openedDay))
{
this.openedGifts.Add(openedDay);
}
}
Código:
public HabboStats(
Código:
, string openedGifts
Código:
this._habboStats = new HabboStats(
Código:
Convert.ToString(StatRow["calendar_gifts"])
Aqui está o banco de dados
Código:
/*
Navicat MySQL Data Transfer
Source Server : local
Source Server Version : 50505
Source Host : localhost:3306
Source Database : plus
Target Server Type : MYSQL
Target Server Version : 50505
File Encoding : 65001
Date: 2016-12-19 18:30:09
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `campaign_calendar_gifts`
-- ----------------------------
DROP TABLE IF EXISTS `campaign_calendar_gifts`;
CREATE TABLE `campaign_calendar_gifts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`event_name` varchar(225) NOT NULL,
`base_id` int(11) NOT NULL,
`item_id` varchar(225) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of campaign_calendar_gifts
-- ----------------------------
INSERT INTO `campaign_calendar_gifts` VALUES ('1', 'xmas16', '1', 'throne');
INSERT INTO `campaign_calendar_gifts` VALUES ('2', 'xmas16', '2', 'typingmachine');
INSERT INTO `campaign_calendar_gifts` VALUES ('3', 'xmas16', '3', 'spyro');
INSERT INTO `campaign_calendar_gifts` VALUES ('4', 'xmas16', '4', 'rare_daffodil_rug');
INSERT INTO `campaign_calendar_gifts` VALUES ('5', 'xmas16', '5', 'rare_beehive_bulb');
INSERT INTO `campaign_calendar_gifts` VALUES ('6', 'xmas16', '6', 'rare_elephant_statue');
INSERT INTO `campaign_calendar_gifts` VALUES ('7', 'xmas16', '7', 'rare_stand');
INSERT INTO `campaign_calendar_gifts` VALUES ('8', 'xmas16', '8', 'rare_xmas_screen');
INSERT INTO `campaign_calendar_gifts` VALUES ('9', 'xmas16', '9', 'djesko_turntable');
INSERT INTO `campaign_calendar_gifts` VALUES ('10', 'xmas16', '10', 'rare_vdoll');
INSERT INTO `campaign_calendar_gifts` VALUES ('11', 'xmas16', '11', 'rare_mmmth');
INSERT INTO `campaign_calendar_gifts` VALUES ('12', 'xmas16', '12', 'rare_trex');
INSERT INTO `campaign_calendar_gifts` VALUES ('13', 'xmas16', '13', 'rare_ironmaiden');
INSERT INTO `campaign_calendar_gifts` VALUES ('14', 'xmas16', '14', 'rare_fountain_niko');
INSERT INTO `campaign_calendar_gifts` VALUES ('15', 'xmas16', '15', 'rare_dragonlamp_pink');
INSERT INTO `campaign_calendar_gifts` VALUES ('16', 'xmas16', '16', 'rare_trex');
INSERT INTO `campaign_calendar_gifts` VALUES ('17', 'xmas16', '17', 'rare_elephant_statue');
INSERT INTO `campaign_calendar_gifts` VALUES ('18', 'xmas16', '18', 'typingmachine');
INSERT INTO `campaign_calendar_gifts` VALUES ('19', 'xmas16', '19', 'rare_dragonlamp_pink');
INSERT INTO `campaign_calendar_gifts` VALUES ('20', 'xmas16', '20', 'typingmachine');
INSERT INTO `campaign_calendar_gifts` VALUES ('21', 'xmas16', '21', 'throne');
INSERT INTO `campaign_calendar_gifts` VALUES ('22', 'xmas16', '22', 'djesko_turntable');
INSERT INTO `campaign_calendar_gifts` VALUES ('23', 'xmas16', '23', 'pillow_bronze');
INSERT INTO `campaign_calendar_gifts` VALUES ('24', 'xmas16', '24', 'pillow_silver');
INSERT INTO `campaign_calendar_gifts` VALUES ('25', 'xmas16', '25', '0');
Créditos:
Core
DevBest
0 Comentários
Fique a vontade no comentário, estaremos respondendo todas dúvidas por aqui! Aproveite e use nossos emoji's para comentários :)