internal void SerializeBody(ServerMessage message) { message.AppendUInt(Id); // id message.AppendInt32(TabId); // state message.AppendInt32(7); // type (3 or 4 for new style) message.AppendInt32(Type); // cat id message.AppendInt32((OtanixEnvironment.GetUnixTimestamp() - (int)Timestamp) * 1000); // issueAgeInMilliseconds message.AppendInt32(Score); // priority message.AppendUInt(1); // ensures that more tickets of the same reporter/reported user get merged message.AppendUInt(SenderId); // caller_user_info message.AppendString(SenderName); message.AppendInt32(ReportedId); // reported id message.AppendString(ReportedName); message.AppendUInt((Status == TicketStatus.PICKED) ? ModeratorId : 0); // mod id message.AppendString(ModName); message.AppendString(Message); // issue message message.AppendUInt(0); // roomid message.AppendInt32(Chats.Length); foreach (string str in Chats) { message.AppendString(str); // pattern message.AppendInt32(-1); // startIndex message.AppendInt32(-1); // endIndex } }
internal GroupPost(uint id, uint subpostid, string issue, string message, uint ownerid, string username, double unixcreated, uint groupid, bool closed, bool disabled, int hiddenmode, int subforumcount, string hiddenby, bool loadlastest) { this.Id = id; this.SubPostId = subpostid; this.Issue = issue; this.Message = message; this.OwnerId = ownerid; this._username = username; this.UnixCreated = unixcreated; this.GroupId = groupid; this.Closed = closed; this.Disabled = disabled; this.HiddenMode = hiddenmode; this.HiddenBy = hiddenby; this.LastOwnerId = 0; this.LastOwnerName = ""; this.LastUnix = OtanixEnvironment.GetUnixTimestamp(); this.subPosts = new Dictionary <uint, GroupSubPost>(); this.subPosts.Add(this.Id, new GroupSubPost(this.Id, this.SubPostId, this.Issue, this.Message, this.OwnerId, this.Username, "", this.UnixCreated, this.GroupId, this.HiddenMode, 0, this.HiddenBy)); this.SubPostsCount = subforumcount; if (loadlastest) { this.LoadLast(); } }
internal ServerMessage SerializeTargetedOffer(TargetedOffer to) { ServerMessage targetedOffer = new ServerMessage(Outgoing.TargetedOfferMessageComposer); targetedOffer.AppendInt32(1); // 0,5,6: maximizeMallOffer || 2: return || default: MallOfferMinimizedView targetedOffer.AppendUInt(to.Id); // offerId targetedOffer.AppendString(to.Identifier); // identifier targetedOffer.AppendString(to.Identifier2); // targetedOffer.AppendUInt(to.PriceInCredits); // priceInCredits targetedOffer.AppendUInt(to.PriceInDiamonds); // priceInDiamonds targetedOffer.AppendInt32(to.ActivityPointType); // activityPointType -1 = moedas, 0 = duckets , 5 = diamantes targetedOffer.AppendUInt(to.PurchaseLimit); // purchaseLimit targetedOffer.AppendInt32(to.ExpirationTime - OtanixEnvironment.GetUnixTimestamp()); // expirationTime (seconds) targetedOffer.AppendString(to.Title); // title targetedOffer.AppendString(to.Description); // description targetedOffer.AppendString(to.ImageUrl); // imageUrl targetedOffer.AppendString(to.BmpIcon); // bmp_icon targetedOffer.AppendInt32(0); // type targetedOffer.AppendInt32(to.Items.Count); // items foreach (uint itemId in to.Items.Keys) { Item item = OtanixEnvironment.GetGame().GetItemManager().GetItem(itemId); targetedOffer.AppendString(item == null ? "" : item.Name); // itemName } return(targetedOffer); }
public static string SpecialReplace(string baseMessage, RoomUser user) { string message = baseMessage.ToString(); Room room = OtanixEnvironment.GetGame().GetRoomManager().GetRoom(user.RoomId); string tempoprisao = OtanixEnvironment.UnixTimeStampToDateTime(user.GetTempoPreso()).ToString(); message = message.Replace("%username%", user.GetUsername()); message = message.Replace("%name%", user.GetUsername()); message = message.Replace("%userid%", user.HabboId.ToString()); if (user.GetTempoPreso() > OtanixEnvironment.GetUnixTimestamp()) { message = message.Replace("%tempoprisao%", tempoprisao); } else { message = message.Replace("%tempoprisao%", ""); } message = message.Replace("%usersonline%", OtanixEnvironment.GetGame().GetClientManager().connectionCount.ToString()); message = message.Replace("%roomname%", room.RoomData.Name); message = message.Replace("%roomid%", room.RoomData.Id.ToString()); message = message.Replace("%user_count%", room.RoomData.UsersNow.ToString()); message = message.Replace("%floor_item_count%", room.GetRoomItemHandler().mFloorItems.Count.ToString()); message = message.Replace("%wall_item_count%", room.GetRoomItemHandler().mWallItems.Count.ToString()); message = message.Replace("%roomowner%", room.RoomData.Owner); message = message.Replace("%owner%", room.RoomData.Owner); message = message.Replace("%item_count%", (room.GetRoomItemHandler().mFloorItems.Count + room.GetRoomItemHandler().mWallItems.Count).ToString()); return(message); }
internal void AddMute(uint pId, int Time) { if (!Mutes.ContainsKey(pId)) { Mutes.Add(pId, new MuteUser(pId, OtanixEnvironment.GetUnixTimestamp() + (Time * 60))); } }
internal void AddBan(uint pId, int Time) { if (!Bans.ContainsKey(pId)) { Bans.Add(pId, OtanixEnvironment.GetUnixTimestamp() + Time); } }
internal void AddUserMute(uint pId, double minutes) { if (!UserIsMuted(pId)) { this.UsersMuted.Add(pId, new MuteUser(pId, OtanixEnvironment.GetUnixTimestamp() + (minutes * 60))); } }
private Boolean isCorrectInt(RoomUser user) { if (user.GetClient().GetHabbo().WiredRewards.ContainsKey(item.Id)) { if (Type == 0) { return(false); } else if (Type == 1 || Type == 2) { WiredActReward wiredAct = user.GetClient().GetHabbo().WiredRewards[item.Id]; if ((OtanixEnvironment.GetUnixTimestamp() > (wiredAct.LastUpdate + ((Type == 1) ? 86400 : 3600))) || wiredAct.OriginalInt != nInt) { wiredAct.OriginalInt = nInt; wiredAct.ActualRewards = nInt; wiredAct.LastUpdate = OtanixEnvironment.GetUnixTimestamp(); } if (wiredAct.ActualRewards > 0) { wiredAct.ActualRewards--; return(true); } } } else { WiredActReward wiredAct = new WiredActReward(item.Id, OtanixEnvironment.GetUnixTimestamp(), (nInt - 1), nInt); user.GetClient().GetHabbo().WiredRewards.Add(item.Id, wiredAct); return(true); } return(false); }
internal void AddOrExtendSubscription(GameClient Session, string SubscriptionId, int DurationSeconds, uint Cost, int MonthProgress) { SubscriptionId = SubscriptionId.ToLower(); var clientByUserId = OtanixEnvironment.GetGame().GetClientManager().GetClientByUserID(UserID); if (clubSubscriptions.ContainsKey(SubscriptionId)) { Club Club = clubSubscriptions[SubscriptionId]; if (Club.IsValid) { Club.ExtendSubscription(DurationSeconds); } else { Club.SetEndTime(OtanixEnvironment.GetUnixTimestamp() + DurationSeconds); } using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("UPDATE user_subscriptions SET timestamp_expire = timestamp_expire + " + DurationSeconds + " WHERE user_id = " + UserID + " AND subscription_id = '" + Club.SubscriptionId + "'"); } OtanixEnvironment.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(clientByUserId, MonthProgress); } else { int TimestampActivated = OtanixEnvironment.GetUnixTimestamp(); int TimestampExpire = OtanixEnvironment.GetUnixTimestamp() + DurationSeconds; using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("INSERT INTO user_subscriptions (subscription_id, user_id, timestamp_activated, timestamp_expire) VALUES (@subscription_id, @user_id, @timestamp_activated, @timestamp_expire)"); dbClient.addParameter("user_id", UserID); dbClient.addParameter("subscription_id", SubscriptionId); dbClient.addParameter("timestamp_activated", TimestampActivated); dbClient.addParameter("timestamp_expire", TimestampExpire); dbClient.runQuery(); dbClient.runFastQuery("UPDATE users SET spent_credits = spent_credits + " + Cost + " WHERE id = " + Session.GetHabbo().Id); } clubSubscriptions.Add(SubscriptionId, new Club(SubscriptionId, TimestampActivated, TimestampExpire, false)); Session.GetHabbo().SpentCredits += Cost; var fuse = new ServerMessage(Outgoing.Fuserights); fuse.AppendInt32(Session.GetHabbo().GetClubManager().UserHasSubscription("club_habbo") ? 2 : 1); // normal|hc|vip fuse.AppendUInt(Session.GetHabbo().Rank); fuse.AppendBoolean(Session.GetHabbo().HasFuse("fuse_ambassador")); // embajador ? // fuserights.AppendInt32(0); // New Identity (1 == 1 min and Alert!) Session.SendMessage(fuse); OtanixEnvironment.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(clientByUserId, MonthProgress); } Session.GetHabbo().UpdateHabboClubStatus(); Session.GetMessageHandler().ClubCenterData(); }
internal static void UpdateClubCycleExpiration(GameClient Session) { int seconds = 0; if (Session.GetHabbo().GetClubManager().UserHasSubscription("club_habbo")) { if (Session.GetHabbo().GetClubManager().GetSubscription("club_habbo").DaysLeft >= 1) { seconds = 86400; } else if (Session.GetHabbo().GetClubManager().GetSubscription("club_habbo").HoursLeft >= 1 && Session.GetHabbo().GetClubManager().GetSubscription("club_habbo").DaysLeft < 1) { seconds = 3600; } else if (Session.GetHabbo().GetClubManager().GetSubscription("club_habbo").MinutesLeft >= 1 && Session.GetHabbo().GetClubManager().GetSubscription("club_habbo").HoursLeft < 1) { seconds = 60; } } if ((OtanixEnvironment.GetUnixTimestamp() - Session.GetHabbo().ClubExpirationCycleUpdate) > seconds || !Session.GetHabbo().GetClubManager().UserHasSubscription("club_habbo")) { Session.GetHabbo().UpdateHabboClubStatus(); } }
public bool AllowsExecution(RoomUser user) { Int32 actualUnix = OtanixEnvironment.GetUnixTimestamp(); if (actualUnix >= startDate && actualUnix <= endDate) { return(true); } return(false); }
internal TargetedOffer GetRoomIdTargetedOffer(uint RoomId) { foreach (TargetedOffer to in targetedOffers) { if (to.roomId == RoomId && to.ExpirationTime > OtanixEnvironment.GetUnixTimestamp()) { return(to); } } return(null); }
internal void DeliverInstantMessage(string message, uint convoID, int timeSended = 0) { var InstantMessage = new ServerMessage(Outgoing.InstantChat); InstantMessage.AppendUInt(convoID); InstantMessage.AppendString(message); InstantMessage.AppendInt32(timeSended == 0 ? 0 : OtanixEnvironment.GetUnixTimestamp() - timeSended); if (GetClient() != null) { GetClient().SendMessage(InstantMessage); } }
public PacketsUserLogs() { // Iniciamos la variable que se utilizará como caché. PacketsList = new Dictionary <int, double>(); // Calculamos el tiempo actual. double actualUnix = OtanixEnvironment.GetUnixTimestamp(); // Establecemos valores. foreach (int IncomingId in PacketsCollapsed.PacketsList.Keys) { PacketsList.Add(IncomingId, actualUnix); } }
internal int HasMuteExpired(uint pId) { if (!UserIsMuted(pId)) { return(0); } else if (OtanixEnvironment.GetUnixTimestamp() >= Mutes[pId].ExpireTime) { RemoveMute(pId); return(-1); } return((int)(Mutes[pId].ExpireTime - OtanixEnvironment.GetUnixTimestamp())); }
internal void PickTicket(GameClient Session, uint TicketId) { var Ticket = GetTicket(TicketId); if (Ticket == null || Ticket.Status != TicketStatus.OPEN) { return; } Ticket.Status = TicketStatus.PICKED; Ticket.ModeratorId = Session.GetHabbo().Id; Ticket.Timestamp = OtanixEnvironment.GetUnixTimestamp(); SendTicketToModerators(Ticket); }
internal void BuyTargetedOffer() { uint TargetedId = Request.PopWiredUInt(); TargetedOffer to = OtanixEnvironment.GetGame().GetTargetedOfferManager().GetTargetedOffer(TargetedId); if (to == null) { return; } uint Amount = Request.PopWiredUInt(); if (Session.GetHabbo().TargetedOffers.ContainsKey(TargetedId) && Session.GetHabbo().TargetedOffers[TargetedId] + Amount > to.PurchaseLimit) { return; // ya has alcanzado el límite. } if (Session.GetHabbo().Diamonds < to.PriceInDiamonds) { return; // no tienes suficientes diamantes. } if (OtanixEnvironment.GetUnixTimestamp() > to.ExpirationTime) { return; // fecha finalizada. } Session.GetHabbo().Diamonds -= to.PriceInDiamonds; Session.GetHabbo().UpdateExtraMoneyBalance(); if (Session.GetHabbo().TargetedOffers.ContainsKey(TargetedId)) { Session.GetHabbo().TargetedOffers[TargetedId] += Amount; } else { Session.GetHabbo().TargetedOffers.Add(TargetedId, Amount); } foreach (KeyValuePair <uint, uint> Item in to.Items) { Item item = OtanixEnvironment.GetGame().GetItemManager().GetItem(Item.Key); if (item != null) { for (int i = 0; i < Item.Value; i++) { OtanixEnvironment.GetGame().GetCatalog().DeliverItems(Session, item, 1, "", false, 0); } } } Session.GetHabbo().GetInventoryComponent().UpdateItems(false); }
internal static void MostraNotificacaoUser(GameClient Session) { int UltimaNoti = (OtanixEnvironment.GetUnixTimestamp() - Session.GetHabbo().UltimaNotificacao); if (UltimaNoti > 1800) { Session.GetHabbo().exibeNotifi = true; Session.GetHabbo().UltimaNotificacao = OtanixEnvironment.GetUnixTimestamp(); concluiNotificacao(Session); } else { Session.GetHabbo().exibeNotifi = false; } }
internal static void GiveCycleDiamonds(GameClient Session) { if (EmuSettings.DIAMONDS_ENABLED == false) { return; } if ((OtanixEnvironment.GetUnixTimestamp() - Session.GetHabbo().DiamondsCycleUpdate) > EmuSettings.DIAMONDS_MINUTES * 60) { int DiamondsAmount = (int)(Session.GetHabbo().IsPremium() ? EmuSettings.DIAMONDS_AMOUNT * 2 : EmuSettings.DIAMONDS_AMOUNT); Session.GetHabbo().DiamondsCycleUpdate = OtanixEnvironment.GetUnixTimestamp(); Session.GetHabbo().GiveUserDiamonds(DiamondsAmount); } }
internal static void GiveCycleMoedas(GameClient Session) { if (EmuSettings.HOTEL_LUCRATIVO == false || EmuSettings.HOTEL_LUCRATIVO_DARMOEDAS == false) { return; } if ((OtanixEnvironment.GetUnixTimestamp() - Session.GetHabbo().MoedasCycleUpdate) > EmuSettings.HOTEL_LUCRATIVO_MOEDAS_TEMPO * 60) { int qtdMoedas = (int)(Session.GetHabbo().IsPremium() ? EmuSettings.HOTEL_LUCRATIVO_QUANTIDADE_MOEDAS * 2 : EmuSettings.HOTEL_LUCRATIVO_QUANTIDADE_MOEDAS); Session.GetHabbo().MoedasCycleUpdate = OtanixEnvironment.GetUnixTimestamp(); Session.GetHabbo().darMoedas(qtdMoedas); } }
internal void SerializeSubPost(ServerMessage Message) { Message.AppendUInt(this.Id); Message.AppendInt32(this.PostOrderID); Message.AppendUInt(this.OwnerId); Message.AppendString(this.Username); Message.AppendString(this.Look); Message.AppendInt32((int)(OtanixEnvironment.GetUnixTimestamp() - this.UnixCreated)); Message.AppendString(this.Message); Message.AppendByted(this.HiddenMode); Message.AppendInt32(0); Message.AppendString(this.HiddenBy); Message.AppendUInt(this.Id); Message.AppendUInt(OtanixEnvironment.GetGame().GetGroup().GetTotalPosts(this.OwnerId)); }
private static bool SubscriptionEnds(double PremiumEnds, uint UserId) { if (PremiumEnds < OtanixEnvironment.GetUnixTimestamp()) { using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("DELETE FROM items_premium WHERE user_id = " + UserId); dbClient.runFastQuery("DELETE FROM user_premiums WHERE user_id = " + UserId); } return(true); } return(false); }
internal Boolean HasBanExpired(uint pId) { if (!UserIsBanned(pId)) { return(true); } var diff = Bans[pId] - OtanixEnvironment.GetUnixTimestamp(); if (diff > 0) { return(false); } return(true); }
internal void ReportarAcosoMessage() { uint UserReportedId = Request.PopWiredUInt(); GameClient _client = OtanixEnvironment.GetGame().GetClientManager().GetClientByUserID(UserReportedId); // podemos usar esto para si está online uint RoomId = Request.PopWiredUInt(); var Room = OtanixEnvironment.GetGame().GetRoomManager().GetRoom(RoomId); if (Room == null) { return; } ServerMessage message = new ServerMessage(Outgoing.ReportAcosoMessage); if (_client != null && _client.GetHabbo() != null && _client.GetHabbo().GetChatMessageManager().messageCount <= 0) { message.AppendInt32(2); } else if (OtanixEnvironment.GetGame().GetModerationTool().UsersHasPendingTicket(Session.GetHabbo().Id) || OtanixEnvironment.GetGame().GetAlfaManager().GetBullyManager().UserStartedBully(Session.GetHabbo().Id)) { message.AppendInt32(3); } else { if (OtanixEnvironment.GetUnixTimestamp() - Session.GetHabbo().LastAlfaSend < 1200) { Session.GetMessageHandler().GetResponse().Init(Outgoing.onGuideSessionError); Session.GetMessageHandler().GetResponse().AppendInt32(0); Session.GetMessageHandler().SendResponse(); return; } Bully bully = new Bully(Session.GetHabbo().Id, UserReportedId, Room.GetChatMessageManager().GetRoomChatMessage()); if (!bully.SearchGuardian()) { bully.SerializeNoGuardians(); return; } OtanixEnvironment.GetGame().GetAlfaManager().GetBullyManager().AddBullie(bully); message.AppendInt32(0); } Session.SendMessage(message); }
internal void LoadBans(IQueryAdapter dbClient) { bannedMachinedId.Clear(); bannedUsernames.Clear(); dbClient.setQuery("SELECT bantype, value, reason, expire FROM bans"); DataTable dTable = dbClient.getTable(); foreach (DataRow dRow in dTable.Rows) { string variable = (string)dRow["value"]; string reason = (string)dRow["reason"]; double expire = (double)dRow["expire"]; string rawvar = (string)dRow["bantype"]; if (expire < OtanixEnvironment.GetUnixTimestamp()) { continue; } switch (rawvar) { case "user": { Ban ban = new Ban(ModerationBanType.USERNAME, variable, reason, expire); if (!bannedUsernames.ContainsKey(variable)) { bannedUsernames.Add(variable, ban); } break; } case "machine": { Ban ban = new Ban(ModerationBanType.MACHINEID, variable, reason, expire); if (!bannedMachinedId.ContainsKey(variable)) { bannedMachinedId.Add(variable, ban); } break; } } } }
internal void RefreshBans() { List <uint> pExpired = new List <uint>(); foreach (KeyValuePair <uint, double> bb in Bans) { if (bb.Value <= OtanixEnvironment.GetUnixTimestamp()) { pExpired.Add(bb.Key); } } foreach (uint userId in pExpired) { RemoveBan(userId); } pExpired.Clear(); pExpired = null; }
internal void BuyServerCameraPhoto() { if ((OtanixEnvironment.GetUnixTimestamp() - Session.GetHabbo().UltimaFotoComprada) < 20) { Session.SendNotif("Você deve esperar 20 segundos antes de comprar outra foto."); return; } if (!Session.GetHabbo().lastPhotoPreview.Contains("-")) { return; } string roomId = Session.GetHabbo().lastPhotoPreview.Split('-')[0]; string timestamp = Session.GetHabbo().lastPhotoPreview.Split('-')[1]; string md5image = URLPost.GetMD5(Session.GetHabbo().lastPhotoPreview); Item Item = OtanixEnvironment.GetGame().GetItemManager().GetItem(EmuSettings.CAMERA_BASEID); if (Item == null) { return; } ServerMessage Message = new ServerMessage(Outgoing.BuyPhoto); Session.SendMessage(Message); OtanixEnvironment.GetGame().GetCatalog().DeliverItems(Session, Item, 1, "{\"timestamp\":\"" + timestamp + "\", \"id\":\"" + md5image + "\"}", true, 0); Session.GetHabbo().GetInventoryComponent().UpdateItems(false); OtanixEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Session.GetHabbo().Id, "ACH_CameraPhotoCount", 1); using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("REPLACE INTO items_camera VALUES (@id, '" + Session.GetHabbo().Id + "',@creator_name, '" + roomId + "','" + timestamp + "')"); dbClient.addParameter("id", md5image); dbClient.addParameter("creator_name", Session.GetHabbo().Username); dbClient.runQuery(); } Session.GetHabbo().UltimaFotoComprada = OtanixEnvironment.GetUnixTimestamp(); }
internal void Serialize(ServerMessage Message) { Message.AppendUInt(this.Id); Message.AppendUInt(this.OwnerId); Message.AppendString(this.Username); Message.AppendString(this.Issue); Message.AppendBoolean(this.Disabled); Message.AppendBoolean(this.Closed); Message.AppendInt32((Int32)(OtanixEnvironment.GetUnixTimestamp() - this.UnixCreated)); // tiempo desde creación Message.AppendInt32(this.SubPostsCount); // mensajes count Message.AppendInt32(0); // no leídos Message.AppendInt32(1); Message.AppendUInt(this.LastOwnerId); // ultimo mensaje OwnerID Message.AppendString(this.LastOwnerName); // último mensaje Username Message.AppendInt32((int)(OtanixEnvironment.GetUnixTimestamp() - this.LastUnix)); // último mensaje hace: Message.AppendByted(this.HiddenMode); Message.AppendInt32(0); Message.AppendString(this.HiddenBy); Message.AppendUInt(this.Id); // Message.AppendUInt(OtanixEnvironment.GetGame().GetGroup().GetTotalPosts(this.OwnerId)); }
public void PlaySong() { if (mSongQueuePosition >= mPlaylist.Count) { mSongQueuePosition = 0; } if (mPlaylist.Count == 0) { Stop(); return; } if (!mPlaylist.ContainsKey(mSongQueuePosition)) { mSongQueuePosition = 0; } mSong = mPlaylist[mSongQueuePosition]; mStartedPlayingTimestamp = OtanixEnvironment.GetUnixTimestamp(); mBroadcastNeeded = true; }
public bool CanReceivePacket(int PacketId) { // Si el packet no pertenece a la prioridad, se puede recibir sin problemas. if (!PacketsList.ContainsKey(PacketId)) { return(true); } // Calculamos el tiempo actual. double actualUnix = OtanixEnvironment.GetUnixTimestamp(); // Si ha pasado más de X segundos desde que recibimos este packet. bool value = (actualUnix - PacketsList[PacketId]) > PacketsCollapsed.PacketsList[PacketId]; // Si ha pasado, actualizamos el valor. if (value) { PacketsList[PacketId] = actualUnix; } // Devolvemos V/F. return(value); }