Пример #1
0
        public void EnableEffect(int EffectId)
        {
            AvatarEffect Effect = this.GetEffect(EffectId, false);

            if (Effect != null && !Effect.HasExpired && !Effect.Activated && (this.GetClient() != null && this.GetClient().GetHabbo() != null))
            {
                Room class2 = this.GetUserRoom();
                if (class2 != null)
                {
                    RoomUser User = class2.GetRoomUserByHabbo(this.GetClient().GetHabbo().Id);
                    if (User.byte_1 <= 0 && User.Riding == null)
                    {
                        using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                        {
                            adapter.ExecuteQuery("UPDATE user_effects SET is_activated = '1', activated_stamp = '" + PhoenixEnvironment.GetUnixTimestamp() + "' WHERE user_id = '" + UserId + "' AND effect_id = '" + EffectId + "' LIMIT 1");
                        }
                        Effect.Activate();
                        ServerMessage Message = new ServerMessage(462);
                        Message.AppendInt32(Effect.EffectId);
                        Message.AppendInt32(Effect.TotalDuration);
                        this.GetClient().SendMessage(Message);
                    }
                }
            }
        }
Пример #2
0
        public void StopEffect(int EffectId)
        {
            AvatarEffect Effect = this.GetEffect(EffectId, true);

            if (Effect != null && Effect.HasExpired)
            {
                using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                {
                    adapter.ExecuteQuery("DELETE FROM user_effects WHERE user_id = '" + UserId + "' AND effect_id = '" + EffectId + "' AND is_activated = '1' LIMIT 1");
                }
                this.Effects.Remove(Effect);
                ServerMessage Message = new ServerMessage(463);
                Message.AppendInt32(EffectId);
                this.GetClient().SendMessage(Message);
                if (this.CurrentEffect >= 0)
                {
                    this.ApplyEffect(-1, false);
                }
            }
        }
Пример #3
0
        public AvatarEffectsInventoryComponent(uint UserId, GameClient pClient, HabboData UserData)
        {
            this.Session       = pClient;
            this.Effects       = new List <AvatarEffect>();
            this.UserId        = UserId;
            this.CurrentEffect = -1;
            this.Effects.Clear();

            DataTable     getUserEffects = UserData.GetUserEffects;
            StringBuilder QueryBuilder   = new StringBuilder();

            foreach (DataRow dataRow in getUserEffects.Rows)
            {
                AvatarEffect item = new AvatarEffect((int)dataRow["effect_id"], (int)dataRow["total_duration"], PhoenixEnvironment.EnumToBool(dataRow["is_activated"].ToString()), (double)dataRow["activated_stamp"]);
                if (item.HasExpired)
                {
                    QueryBuilder.Append(string.Concat(new object[]
                    {
                        "DELETE FROM user_effects WHERE user_id = '",
                        UserId,
                        "' AND effect_id = '",
                        item.EffectId,
                        "' LIMIT 1; "
                    }));
                }
                else
                {
                    this.Effects.Add(item);
                }
            }
            if (QueryBuilder.Length > 0)
            {
                using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                {
                    adapter.ExecuteQuery(QueryBuilder.ToString());
                }
            }
        }
		public AvatarEffectsInventoryComponent(uint UserId, GameClient pClient, HabboData UserData)
		{
			this.Session = pClient;
			this.Effects = new List<AvatarEffect>();
			this.UserId = UserId;
			this.CurrentEffect = -1;
			this.Effects.Clear();

			DataTable getUserEffects = UserData.GetUserEffects;
			StringBuilder QueryBuilder = new StringBuilder();
			foreach (DataRow dataRow in getUserEffects.Rows)
			{
				AvatarEffect item = new AvatarEffect((int)dataRow["effect_id"], (int)dataRow["total_duration"], PhoenixEnvironment.EnumToBool(dataRow["is_activated"].ToString()), (double)dataRow["activated_stamp"]);
				if (item.HasExpired)
				{
					QueryBuilder.Append(string.Concat(new object[]
					{
						"DELETE FROM user_effects WHERE user_id = '",
						UserId,
						"' AND effect_id = '",
						item.EffectId,
						"' LIMIT 1; "
					}));
				}
				else
				{
					this.Effects.Add(item);
				}
			}
			if (QueryBuilder.Length > 0)
			{
				using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
				{
					adapter.ExecuteQuery(QueryBuilder.ToString());
				}
			}
		}