Exemplo n.º 1
0
        public void OnTrigger(GameClients.GameClient Session, RoomItem Item, int Request, bool HasRights)
        {
            if (Session == null)
            {
                return;
            }
            RoomUser User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);


            if (Item.InteractingUser2 != User.UserId)
            {
                Item.InteractingUser2 = User.UserId;
            }

            if (User == null)
            {
                return;
            }

            if (!Gamemap.TilesTouching(User.X, User.Y, Item.X, Item.Y))
            {
                User.MoveTo(Item.SquareInFront);
                return;
            }

            if (RoleplayManager.EmptyTrashCans.ContainsKey(Item.Id))
            {
                DateTime nowTime  = DateTime.Now;
                DateTime LastTime = RoleplayManager.EmptyTrashCans[Item.Id];
                TimeSpan span     = nowTime.Subtract(LastTime);
                int      timeleft = 5 - Convert.ToInt32(span.Minutes);

                if (timeleft > 0)
                {
                    User.GetClient().SendWhisper("This item has recently been interacted with.");
                    return;
                }
            }

            int Cash         = new Random().Next(1, 350);
            int Weed         = new Random().Next(1, 100);
            int Bullets      = new Random().Next(1, 50);
            int PhoneCredits = new Random().Next(1, 1000);

            #region Trash Can Items

            List <string> trash = new List <string>();
            trash.Add("[CASH]");
            trash.Add("[CASH]");
            trash.Add("[CASH]");
            trash.Add("[WEED]");
            trash.Add("[WEED]");
            trash.Add("[WEED]");
            trash.Add("[WEED]");
            trash.Add("[WEED]");
            trash.Add("[AMMO]");
            trash.Add("[AMMO]");
            trash.Add("[AMMO]");
            trash.Add("[AMMO]");
            trash.Add("[AMMO]");
            trash.Add("[PHONEC]");
            trash.Add("[PHONEC]");
            trash.Add("[PHONEC]");
            trash.Add("[PHONEC]");
            trash.Add("[PHONEC]");
            trash.Add("[VESTS]");
            trash.Add("[VESTS]");
            trash.Add("[VESTS]");
            trash.Add("[VESTS]");
            trash.Add("[VESTS]");
            trash.Add("[HOBO]");
            trash.Add("[HOBO]");
            trash.Add("[HOBO]");
            trash.Add("[HOBO]");
            trash.Add("[HOBO]");
            trash.Add("[HOBO]");
            trash.Add("[HOBO]");
            trash.Add("[HOBO]");
            trash.Add("[HOBO]");

            #endregion

            int    tc        = new Random().Next(trash.Count);
            string foundItem = trash[tc];
            string foundmsg  = "*Fails to find anything in the bin*";

            #region Rummage in bin task

            RoleplayManager.Shout(User.GetClient(), "*Begins to rummage in the bin*");
            User.ApplyEffect(4);

            if (RoleplayManager.EmptyTrashCans.ContainsKey(Item.Id))
            {
                DateTime trashJunk;
                RoleplayManager.EmptyTrashCans.TryRemove(Item.Id, out trashJunk);
            }

            RoleplayManager.EmptyTrashCans.TryAdd(Item.Id, DateTime.Now);
            Item.ExtraData = "1";
            Item.UpdateState(false, true);
            Item.ReqUpdate(4, true);

            int time = 300;
            time = time * 1000;
            System.Timers.Timer dispatcherTimer = new System.Timers.Timer(time);
            dispatcherTimer.Interval = time;
            dispatcherTimer.Elapsed += delegate
            {
                Item.InteractingUser = 0;
                Item.ExtraData       = "0";
                Item.UpdateState(false, true);
                Item.ReqUpdate(4, true);
            };
            dispatcherTimer.Start();
            System.Threading.Thread.Sleep(2000);
            User.ApplyEffect(0);

            #endregion

            #region Rummage in bin completion (found items?)

            if (foundItem.Equals("[CASH]"))
            {
                foundmsg = "*Finds $" + Cash + " in the bin*";
                RoleplayManager.GiveMoney(Session, +Cash);
            }
            else if (foundItem.Equals("[WEED]"))
            {
                foundmsg = "*Finds " + Weed + "g of Weed in the bin*";
                Session.GetRoleplay().Weed += Weed;
                Session.GetRoleplay().SaveQuickStat("weed", "" + Session.GetRoleplay().Weed);
            }
            else if (foundItem.Equals("[AMMO]"))
            {
                foundmsg = "*Finds " + Bullets + " Bullets in the bin*";
                Session.GetRoleplay().Bullets += Bullets;
                Session.GetRoleplay().SaveQuickStat("bullets", "" + Session.GetRoleplay().Bullets);
            }
            else if (foundItem.Equals("[VESTS]"))
            {
                foundmsg = "*Finds an old kevlar vest in the bin*";
                Session.GetRoleplay().Vests += 1;
                Session.GetRoleplay().SaveQuickStat("vests", "" + Session.GetRoleplay().Vests);
                Session.SendWhisper("Use :ba to use your kevlar vest!");
            }
            else if (foundItem.Equals("[PHONEC]"))
            {
                foundmsg = "*Finds $" + PhoneCredits + " worth of phone credits in the bin*";
                RoleplayManager.GiveCredit(Session, +PhoneCredits);
            }
            else if (foundItem.Equals("[HOBO]"))
            {
                //Credits in hand stealer
                HabboHotel.RoomBots.RoomBot NewParamedic = RoleplayManager.MakeQuickBot("[HOBO] Jim", HabboHotel.RoomBots.AIType.MiscBot, User.GetClient().GetHabbo().CurrentRoomId, "hr-676-61.cp-3207-62-1408.ca-3292-110.lg-275-1408.hd-3103-97541.fa-1205-110.ch-255-1331.he-1601-62", Item.X, Item.Y, 0, "M");
                NewParamedic.InteractingWith = User;
                RoleplayManager.SendBotToRoom(NewParamedic, User.GetClient().GetHabbo().CurrentRoomId);

                //Credits in bank stealer
                HabboHotel.RoomBots.RoomBot NewParamedicBank = RoleplayManager.MakeQuickBot("[HOBO 2] John", HabboHotel.RoomBots.AIType.MiscBot, User.GetClient().GetHabbo().CurrentRoomId, "hr-676-61.cp-3207-62-1408.ca-3292-110.lg-275-1408.hd-3103-97541.fa-1205-110.ch-255-1331.he-1601-62", Item.X, Item.Y, 0, "M");
                NewParamedicBank.InteractingWith = User;
                RoleplayManager.SendBotToRoom(NewParamedicBank, User.GetClient().GetHabbo().CurrentRoomId);
            }

            RoleplayManager.Shout(Session, foundmsg);

            #endregion
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sends the instant message.
        /// </summary>
        /// <param name="toId">To identifier.</param>
        /// <param name="message">The message.</param>
        internal void SendInstantMessage(uint toId, string message)
        {
            int credit = new Random().Next(1, 15);

            if (!GetClient().GetHabbo().HasFuse("fuse_owner") && AntiPublicistas.CheckPublicistas(message))
            {
                GetClient().PublicistCount++;
                GetClient().HandlePublicista(message);
                return;
            }
            if (!FriendshipExists(toId))
            {
                DeliverInstantMessageError(6, toId);
                return;
            }

            if (GetClient().GetRoleplay().Phone == 0)
            {
                GetClient().SendWhisperBubble("Você não tem telefone! Você pode comprar um na loja de telefone! [Room ID: 5]", 1);
                return;
            }
            if (GetClient().GetHabbo().ActivityPoints < credit)
            {
                GetClient().SendWhisperBubble("Você tem fundos de crédito insuficientes! Você pode comprar mais na loja de telefone! [Room ID: 5]", 1);
                return;
            }

            if (toId == 0) // Staff Chat
            {
                var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ConsoleChatMessageComposer"));
                serverMessage.AppendInteger(0); //userid
                serverMessage.AppendString(GetClient().GetHabbo().UserName + " : " + message);
                serverMessage.AppendInteger(0);
                Plus.GetGame().GetClientManager().StaffAlert(serverMessage, GetClient().GetHabbo().Id);
            }
            else
            {
                var clientByUserId = Plus.GetGame().GetClientManager().GetClientByUserId(toId);
                if (clientByUserId == null || clientByUserId.GetHabbo().GetMessenger() == null)
                {
                    if (Plus.OfflineMessages.ContainsKey(toId))
                    {
                        Plus.OfflineMessages[toId].Add(new OfflineMessage(GetClient().GetHabbo().Id, message,
                                                                          Plus.GetUnixTimeStamp()));
                    }
                    else
                    {
                        Plus.OfflineMessages.Add(toId, new List <OfflineMessage>());
                        Plus.OfflineMessages[toId].Add(new OfflineMessage(GetClient().GetHabbo().Id, message,
                                                                          Plus.GetUnixTimeStamp()));
                    }
                    OfflineMessage.SaveMessage(Plus.GetDatabaseManager().GetQueryReactor(), toId,
                                               GetClient().GetHabbo().Id, message);
                    return;
                }
                if (GetClient().GetHabbo().Muted)
                {
                    DeliverInstantMessageError(4, toId);
                    return;
                }
                if (clientByUserId.GetHabbo().Muted)
                {
                    DeliverInstantMessageError(3, toId);
                }
                if (message == "")
                {
                    return;
                }
                clientByUserId.GetHabbo().GetMessenger().DeliverInstantMessage(message, _userId);

                #region Whisper
                if (GetClient().GetHabbo().CurrentRoomId != 0)
                {
                    var      roomUserByRank = GetClient().GetHabbo().CurrentRoom.GetRoomUserManager().GetRoomUserByRank(2);
                    RoomUser u  = GetClient().GetHabbo().GetRoomUser();
                    RoomUser u2 = clientByUserId.GetHabbo().GetRoomUser();

                    foreach (var current2 in roomUserByRank)
                    {
                        if (current2 != null && current2.HabboId != u2.HabboId &&
                            current2.HabboId != u.HabboId && current2.GetClient() != null)
                        {
                            if (RoleplayManager.BypassRights(current2.GetClient()))
                            {
                                var whispStaff = new ServerMessage(LibraryParser.OutgoingRequest("WhisperMessageComposer"));
                                whispStaff.AppendInteger(u.VirtualId);
                                whispStaff.AppendString(string.Format("PM to {0}: {1}", clientByUserId.GetHabbo().UserName, message));
                                whispStaff.AppendInteger(0);
                                whispStaff.AppendInteger(0);
                                whispStaff.AppendInteger(0);
                                whispStaff.AppendInteger(-1);
                                current2.GetClient().SendMessage(whispStaff);
                            }
                        }
                    }
                }
                #endregion

                RoleplayManager.GiveCredit(GetClient(), -credit);
            }
            LogPM(_userId, toId, message);
        }