Exemple #1
0
        public void AddTrade(int RPId, int UserOne, int UserTwo, string UserNameOne, string UserNameTwo)
        {
            RolePlayerManager RPManager = ButterflyEnvironment.GetGame().GetRoleplayManager().GetRolePlay(RPId);

            if (RPManager == null)
            {
                return;
            }

            RolePlayer PlayerOne = RPManager.GetPlayer(UserOne);
            RolePlayer PlayerTwo = RPManager.GetPlayer(UserTwo);

            if (PlayerOne == null || PlayerTwo == null || PlayerOne.TradeId != 0 || PlayerTwo.TradeId != 0)
            {
                return;
            }

            TradeId++;
            this.Troc.TryAdd(TradeId, new RPTroc(TradeId, RPId, UserOne, UserTwo));

            PlayerOne.TradeId = TradeId;
            PlayerOne.SendWebPacket(new RpTrocStartComposer(UserTwo, UserNameTwo));

            PlayerTwo.TradeId = TradeId;
            PlayerTwo.SendWebPacket(new RpTrocStartComposer(UserOne, UserNameOne));
        }
Exemple #2
0
        private void CloseTrade(RPTroc Troc)
        {
            RolePlayerManager RPManager = ButterflyEnvironment.GetGame().GetRoleplayManager().GetRolePlay(Troc.RPId);

            if (RPManager == null)
            {
                return;
            }

            RolePlayer PlayerOne = RPManager.GetPlayer(Troc.UserOne.UserId);

            if (PlayerOne != null)
            {
                PlayerOne.TradeId = 0;
                PlayerOne.SendWebPacket(new RpTrocStopComposer());
            }

            RolePlayer PlayerTwo = RPManager.GetPlayer(Troc.UserTwo.UserId);

            if (PlayerTwo != null)
            {
                PlayerTwo.TradeId = 0;
                PlayerTwo.SendWebPacket(new RpTrocStopComposer());
            }

            this.Troc.TryRemove(Troc.Id, out Troc);
        }
Exemple #3
0
        public void AddItem(int TradeId, int UserId, int ItemId)
        {
            RPTroc Troc = GetTroc(TradeId);

            if (Troc == null)
            {
                return;
            }

            if (Troc.AllAccepted || Troc.AllConfirmed)
            {
                return;
            }

            RPTrocUser TrocUser = Troc.GetUser(UserId);

            if (TrocUser == null || TrocUser.Accepted || TrocUser.Confirmed)
            {
                return;
            }

            RPItem RpItem = ButterflyEnvironment.GetGame().GetRoleplayManager().GetItemManager().GetItem(ItemId);

            if (RpItem == null || RpItem.Category == RPItemCategory.QUETE || !RpItem.AllowStack)
            {
                return;
            }

            RolePlayerManager RPManager = ButterflyEnvironment.GetGame().GetRoleplayManager().GetRolePlay(Troc.RPId);

            if (RPManager == null)
            {
                return;
            }

            RolePlayer Player = RPManager.GetPlayer(UserId);

            if (Player == null)
            {
                return;
            }
            RolePlayInventoryItem Item = Player.GetInventoryItem(ItemId);

            if (Item == null)
            {
                return;
            }
            if (TrocUser.GetCountItem(ItemId) >= Item.Count)
            {
                return;
            }

            TrocUser.AddItemId(ItemId);

            this.SendPacketUsers(new RpTrocUpdateItemsComposer(UserId, TrocUser.ItemIds), Troc);
        }
Exemple #4
0
        public Room(RoomData Data)
        {
            RolePlayerManager RPManager = ButterflyEnvironment.GetGame().GetRoleplayManager().GetRolePlay(Data.OwnerId);

            if (RPManager != null)
            {
                this.RpRoom            = true;
                this.Pvp               = true;
                this.RpCycleHourEffect = true;
                this.RpTimeSpeed       = false;
                this.RpHour            = -1;
            }

            this.SaveTimer          = 0;
            this.Disposed           = false;
            this.Bans               = new Dictionary <int, double>();
            this.Mutes              = new Dictionary <int, double>();
            this.ActiveTrades       = new List <Trade>();
            this.mCycleEnded        = false;
            this.HeightMapLoaded    = false;
            this.RoomData           = Data;
            this.EveryoneGotRights  = Data.AllowRightsOverride;
            this.IdleTime           = 0;
            this.RoomMuted          = false;
            this.PushPullAllowed    = true;
            this.RoomIngameChat     = false;
            this.gamemap            = new Gamemap(this);
            this.roomItemHandling   = new RoomItemHandling(this);
            this.roomUserManager    = new RoomUserManager(this);
            this.wiredHandler       = new WiredHandler(this);
            this.projecctileManager = new ProjectileManager(this);
            this.chatMessageManager = new ChatMessageManager();
            this.chatMessageManager.LoadRoomChatlogs(this.Id);
            this.LoadRights();
            this.GetRoomItemHandler().LoadFurniture();
            if (this.RoomData.OwnerName == "WibboGame")
            {
                this.GetRoomItemHandler().LoadFurniture(5400713);
            }

            this.GetGameMap().GenerateMaps();
            this.LoadBots();
            this.InitPets();
            this.lastTimerReset = DateTime.Now;
        }
Exemple #5
0
        private void SendPacketUsers(IServerPacket packet, RPTroc Troc)
        {
            RolePlayerManager RPManager = ButterflyEnvironment.GetGame().GetRoleplayManager().GetRolePlay(Troc.RPId);

            if (RPManager == null)
            {
                return;
            }

            RolePlayer PlayerOne = RPManager.GetPlayer(Troc.UserOne.UserId);

            if (PlayerOne != null)
            {
                PlayerOne.SendWebPacket(packet);
            }

            RolePlayer PlayerTwo = RPManager.GetPlayer(Troc.UserTwo.UserId);

            if (PlayerTwo != null)
            {
                PlayerTwo.SendWebPacket(packet);
            }
        }
Exemple #6
0
        private bool EndTrade(RPTroc Troc)
        {
            RolePlayerManager RPManager = ButterflyEnvironment.GetGame().GetRoleplayManager().GetRolePlay(Troc.RPId);

            if (RPManager == null)
            {
                return(false);
            }

            RolePlayer PlayerOne = RPManager.GetPlayer(Troc.UserOne.UserId);

            if (PlayerOne == null)
            {
                return(false);
            }

            RolePlayer PlayerTwo = RPManager.GetPlayer(Troc.UserTwo.UserId);

            if (PlayerTwo == null)
            {
                return(false);
            }

            foreach (KeyValuePair <int, int> entry in Troc.UserOne.ItemIds)
            {
                RolePlayInventoryItem Item = PlayerOne.GetInventoryItem(entry.Key);
                if (Item == null)
                {
                    return(false);
                }
                if (Item.Count < entry.Value)
                {
                    return(false);
                }
            }
            foreach (KeyValuePair <int, int> entry in Troc.UserTwo.ItemIds)
            {
                RolePlayInventoryItem Item = PlayerTwo.GetInventoryItem(entry.Key);
                if (Item == null)
                {
                    return(false);
                }
                if (Item.Count < entry.Value)
                {
                    return(false);
                }
            }

            foreach (KeyValuePair <int, int> entry in Troc.UserOne.ItemIds)
            {
                RolePlayInventoryItem Item = PlayerOne.GetInventoryItem(entry.Key);
                if (Item == null)
                {
                    return(false);
                }

                PlayerOne.RemoveInventoryItem(entry.Key, entry.Value);
                PlayerTwo.AddInventoryItem(entry.Key, entry.Value);
            }

            foreach (KeyValuePair <int, int> entry in Troc.UserTwo.ItemIds)
            {
                PlayerTwo.RemoveInventoryItem(entry.Key, entry.Value);
                PlayerOne.AddInventoryItem(entry.Key, entry.Value);
            }

            return(true);
        }
Exemple #7
0
        public void OnDisconnect()
        {
            if (this.Disconnected)
            {
                return;
            }

            this.Disconnected = true;

            ButterflyEnvironment.GetGame().GetClientManager().UnregisterClient(this.Id, this.Username);

            if (this.Langue == Language.FRANCAIS)
            {
                ButterflyEnvironment.onlineUsersFr--;
            }
            else if (this.Langue == Language.ANGLAIS)
            {
                ButterflyEnvironment.onlineUsersEn--;
            }
            else if (this.Langue == Language.PORTUGAIS)
            {
                ButterflyEnvironment.onlineUsersBr--;
            }

            if (this.HasFuse("fuse_mod"))
            {
                ButterflyEnvironment.GetGame().GetClientManager().RemoveUserStaff(this.Id);
            }

            Logging.WriteLine(this.Username + " has logged out.");

            if (!this.HabboinfoSaved)
            {
                this.HabboinfoSaved = true;
                TimeSpan TimeOnline    = DateTime.Now - this.OnlineTime;
                int      TimeOnlineSec = (int)TimeOnline.TotalSeconds;
                using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    queryreactor.RunQuery("UPDATE users SET online = '0', last_online = '" + ButterflyEnvironment.GetUnixTimestamp() + "', activity_points = " + this.Duckets + ", activity_points_lastupdate = '" + this.LastActivityPointsUpdate + "', credits = " + this.Credits + " WHERE id = " + this.Id + " ;");
                    queryreactor.RunQuery("UPDATE user_stats SET groupid = " + this.FavouriteGroupId + ",  OnlineTime = OnlineTime + " + TimeOnlineSec + ", quest_id = '" + this.CurrentQuestId + "', Respect = '" + this.Respect + "', DailyRespectPoints = '" + this.DailyRespectPoints + "', DailyPetRespectPoints = '" + this.DailyPetRespectPoints + "' WHERE id = " + this.Id + " ;");
                }
            }

            if (this.InRoom && this.CurrentRoom != null)
            {
                this.CurrentRoom.GetRoomUserManager().RemoveUserFromRoom(this.mClient, false, false);
            }

            if (this.RolePlayId > 0)
            {
                RolePlayerManager RPManager = ButterflyEnvironment.GetGame().GetRoleplayManager().GetRolePlay(this.RolePlayId);
                if (RPManager != null)
                {
                    RolePlayer Rp = RPManager.GetPlayer(this.Id);
                    if (Rp != null)
                    {
                        RPManager.RemovePlayer(this.Id);
                    }
                }
                this.RolePlayId = 0;
            }

            if (this.GuideOtherUserId != 0)
            {
                GameClient requester = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(this.GuideOtherUserId);
                if (requester != null)
                {
                    ServerPacket message = new ServerPacket(ServerPacketHeader.OnGuideSessionEnded);
                    message.WriteInteger(1);
                    requester.SendPacket(message);

                    requester.GetHabbo().GuideOtherUserId = 0;
                }
            }
            if (this.OnDuty)
            {
                ButterflyEnvironment.GetGame().GetGuideManager().RemoveGuide(this.Id);
            }

            if (this.Messenger != null)
            {
                this.Messenger.AppearOffline = true;
                this.Messenger.Destroy();
            }

            if (this.InventoryComponent != null)
            {
                this.InventoryComponent.Destroy();
                this.InventoryComponent = null;
            }

            if (this.BadgeComponent != null)
            {
                this.BadgeComponent.Destroy();
                this.BadgeComponent = null;
            }

            if (this.UsersRooms != null)
            {
                this.UsersRooms.Clear();
            }

            if (this.RoomRightsList != null)
            {
                this.RoomRightsList.Clear();
            }

            if (this.FavoriteRooms != null)
            {
                this.FavoriteRooms.Clear();
            }

            this.mClient = (GameClient)null;
        }
Exemple #8
0
        public void OnCycle(RoomUser User, RolePlayerManager RPManager)
        {
            /*this._energyTimer--;
             * if(this._energyTimer <= 0)
             * {
             *  this._energyTimer = 120;
             *  if (this._energy > 0)
             *  {
             *      this._energy--;
             *      this.SendUpdate();
             *  }
             * }*/

            if (this.SlowTimer > 0)
            {
                this.SlowTimer--;
                User.breakwalk = true;
            }
            else
            {
                User.breakwalk = false;
            }

            if (this.GunLoadTimer > 0)
            {
                this.GunLoadTimer--;
                if (this.GunLoadTimer == 0)
                {
                    this.GunLoad = 6;
                }
            }
            else
            {
                if (this.GunLoad == 0)
                {
                    this.GunLoadTimer = 6;
                    User.OnChat("*Recharge mon arme*");
                }
            }


            if (this.AggroTimer > 0)
            {
                this.AggroTimer--;
            }

            if (this.SendPrison)
            {
                if (this.PrisonTimer > 0)
                {
                    this.PrisonTimer--;
                }
                else
                {
                    this.SendPrison = false;
                    User.GetClient().GetHabbo().IsTeleporting     = true;
                    User.GetClient().GetHabbo().TeleportingRoomID = RPManager.PrisonId;
                    User.GetClient().GetHabbo().PrepareRoom(RPManager.PrisonId);
                }
            }

            if (this.Dead)
            {
                if (this.DeadTimer > 0)
                {
                    this.DeadTimer--;
                }
                else
                {
                    this.Dead = false;
                    User.GetClient().GetHabbo().IsTeleporting     = true;
                    User.GetClient().GetHabbo().TeleportingRoomID = RPManager.HopitalId;
                    User.GetClient().GetHabbo().PrepareRoom(RPManager.HopitalId);
                }
            }

            if (this.NeedUpdate)
            {
                this.NeedUpdate = false;
                this.SendWebPacket(new RpStatsComposer((!this.Dispose) ? this._rpId : 0, this.Health, this.HealthMax, this.Energy, this.Money, this.Munition, this.Level));
            }
        }