1. Tired of not being able to see links? Want to chat with other members? Need help?

PlusEMU Diamond Timer

Discussion in 'Habbo Help & Support' started by Supermario, Jun 2, 2016.

  1. Supermario

    Supermario Member

    Hi,

    I am using PlusEMU and I'm wondering if anyone could show me how to put a loop timer on for diamonds (like the credits & duckets timer function). When you're on the hotel for a certain amount of time (15 minutes for example), I want it to reward 1 diamond for the amount of time I set it at.. Does this function already exist by any chance?

    Thanks,
    Matthew
     
  2. BIOS

    BIOS \r%20

    If it doesn't already exist in your emulator you could create a database cron to do this, see [ Want to see this link? Register ! ] post.
     
  3. JayCustom

    JayCustom echo "Web Developer";

    I have a way of going around this :)

    1) Enable Events by running this query
    Code:
    SET GLOBAL event_scheduler = ON;
    
    2) Open Navicat and go to the events tab, create a new event that executes every x minutes and set the definition as:
    Code:
    
    UPDATE users SET vip_points = vip_points + 1 WHERE online = '1';
    
     
  4. Supermario

    Supermario Member

    Thank you :D Isn't diamonds not vip_points?

    ~EDIT~

    I created the Event, and it never gave me the diamonds? ugh something happen
     
    Last edited: Jun 2, 2016
  5. JMG

    JMG wut wut Staff Member

    It does give you the diamonds but you would have to logout and then log back in
     
  6. Supermario

    Supermario Member

    I just logged out and logged back in, and it never gave me any diamonds?
     
  7. BIOS

    BIOS \r%20

    You'd have to change the field name to what it is in your database, "diamonds" was just an example field name
     
  8. Supermario

    Supermario Member

    I have logged out, and logged back in and I still don't have any "diamonds".

    Is there a way better way so it does it automatic without logging out and logging back in?
     
    Last edited: Jun 2, 2016
  9. BIOS

    BIOS \r%20

    Well the reason you have to logout is most likely because the diamonds are being cached, you'd probably have to create an emulator function for that.

    Run this query, it will give all online users a diamond every 15 minutes:
    Code:
    CREATE EVENT
        diamonds_timer
    ON
        SCHEDULE EVERY 15 MINUTE
    DO
        UPDATE yourDatabaseName.users
    SET
        vip_points = vip_points + 1 WHERE online = '1';
    
    If you haven't already enabled the scheduler run this query too:
    Code:
    SET GLOBAL event_scheduler = ON;
     
  10. JayCustom

    JayCustom echo "Web Developer";

    i just realized that this is a good idea, but it is not updating the credits. You would have to code this system into the emulator. There is premade variables for this in the server_settings table they just aren't linked up. Find where the timers are created, and get a new timer going and update it where it updates the AFK timer and have a variable for the minutes and add up the minutes and if they are greater than 15 than get the value from the database, loop through all online users giving them the credits + updating them.
     
  11. Westyy

    Westyy Moderator Staff Member

    show me the curre
    This would only work for those offline :p

    give me 5 minutes and Ill code it for you.
    --- Double Post Merged, Jun 3, 2016, Original Post Date: Jun 3, 2016 ---
    ok here goes.
    goto PlusStaticGameSettings.cs and add
    Code:
    public const int UserDiamondsUpdateAmount = 1;
    then goto habbo.cs & find public void CheckCreditsTimer() then change it to this.
    Code:
     public void CheckCreditsTimer()
            {
                try
                {
                    this._creditsTickUpdate--;
    
                    if (this._creditsTickUpdate <= 0)
                    {
                        int CreditUpdate = PlusStaticGameSettings.UserCreditsUpdateAmount;
                        int DucketUpdate = PlusStaticGameSettings.UserPixelsUpdateAmount;
                        int DiamondUpdate = PlusStaticGameSettings.UserDiamondsUpdateAmount;
                    
                        SubscriptionData SubData = null;
                        if (PlusEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(this._vipRank, out SubData))
                        {
                            CreditUpdate += SubData.Credits;
                            DucketUpdate += SubData.Duckets;
                            DiamondUpdate += SubData.Diamonds;
                        }
    
                        this._credits += CreditUpdate;
                        this._duckets += DucketUpdate;
                        this._diamonds += DiamondUpdate;
    
                        this._client.SendMessage(new CreditBalanceComposer(this._credits));
                        this._client.SendMessage(new HabboActivityPointNotificationComposer(this._duckets, DucketUpdate));
                        this._client.SendMessage(new HabboActivityPointNotificationComposer(this.Diamonds, DiamondUpdate, 5));
                        this.CreditsUpdateTick = PlusStaticGameSettings.UserCreditsUpdateTimer;
                    }
                }
                catch { }
            }
    Then goto SubscriptionData.cs and change it all to this.
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace Plus.HabboHotel.Subscriptions
    {
        public class SubscriptionData
        {
            public int Id { get; set; }
            public string Name { get; set; }
            public string Badge { get; set; }
            public int Credits { get; set; }
            public int Duckets { get; set; }
            public int Respects { get; set; }
            public int Diamonds { get; set; }
    
            public SubscriptionData(int Id, string Name, string Badge, int Credits, int Duckets, int Respects, int Diamonds)
            {
                this.Id = Id;
                this.Name = Name;
                this.Badge = Badge;
                this.Credits = Credits;
                this.Duckets = Duckets;
                this.Respects = Respects;
                this.Diamonds = Diamonds;
            }
        }
    }
    
    Then goto SubscriptionManager.cs and replace it all with this.
    Code:
    using log4net;
    using Plus.Database.Interfaces;
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace Plus.HabboHotel.Subscriptions
    {
        public class SubscriptionManager
        {
            private static ILog log = LogManager.GetLogger("Plus.HabboHotel.Subscriptions.SubscriptionManager");
    
            private readonly Dictionary<int, SubscriptionData> _subscriptions = new Dictionary<int, SubscriptionData>();
    
            public SubscriptionManager()
            {
            }
    
            public void Init()
            {
                if (this._subscriptions.Count > 0)
                    this._subscriptions.Clear();
    
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT * FROM `subscriptions`;");
                    DataTable GetSubscriptions = dbClient.getTable();
    
                    if (GetSubscriptions != null)
                    {
                        foreach (DataRow Row in GetSubscriptions.Rows)
                        {
                            if (!this._subscriptions.ContainsKey(Convert.ToInt32(Row["id"])))
                                this._subscriptions.Add(Convert.ToInt32(Row["id"]), new SubscriptionData(Convert.ToInt32(Row["id"]), Convert.ToString(Row["name"]), Convert.ToString(Row["badge_code"]), Convert.ToInt32(Row["credits"]), Convert.ToInt32(Row["duckets"]), Convert.ToInt32(Row["respects"]), Convert.ToInt32(Row["diamonds"])));
                        }
                    }
                }
    
                log.Info("Loaded " + this._subscriptions.Count + " subscriptions.");
            }
    
            public bool TryGetSubscriptionData(int Id, out SubscriptionData Data)
            {
                return this._subscriptions.TryGetValue(Id, out Data);
            }
        }
    }
    
     
    Last edited: Jun 4, 2016
    li4m, devJohan, WanknessHD and 6 others like this.
  12. Supermario

    Supermario Member

    Thank you for helping me. I really appreciate your help
    --- Double Post Merged, Jun 3, 2016 ---
    @Brad After a few restarts, The Emulator gave me errors. [ Want to see this link? Register ! ]
     
  13. Westyy

    Westyy Moderator Staff Member

    add the diamonds to the table `subscriptions`.
     
    Tensei and JMG like this.
  14. JMG

    JMG wut wut Staff Member

    Didn't even see your post - I've added your timer, no errors as of yet. Thanks man! +1
     
  15. Meap

    Meap Don't need glasses if you C#

    @Obbler found it for you
     
    Obbler likes this.
  16. WanknessHD

    WanknessHD Hardcore Habboer

    Now how can I change the time so that every hour they get 1 diamond.
     
  17. Iiam

    Iiam uHabbo Owner | uHabbo.org

    Through the database I believe or you know when you ran the code
    SCHEDULE EVERY 15 MINUTE
    Change that into 60min = 1hour
     
  18. Meap

    Meap Don't need glasses if you C#

    You'd have to either change the credit cycle to every hour or simply create a new cycle purely for the diamonds which is easy to do consisting all you have to do is copy and paste the current credit cycle and just edit it
     
  19. WanknessHD

    WanknessHD Hardcore Habboer

    Oh okay so I just change the credit/pixel timer so that they all will give out every hour I can do that.
     
  20. Meap

    Meap Don't need glasses if you C#

    yeah, just make a new line for it in plusstaticgamesettings and reference it in the new cycle , also remember to go into processcomponent and make another line under the credits one so it runs the process on the hour
     

Share This Page

Loading...