PlusEMU Diamond Timer

Supermario

Member
Jan 5, 2016
99
0
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
 

BIOS

ಠ‿ಠ
Apr 25, 2012
906
247
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
If it doesn't already exist in your emulator you could create a database cron to do this, see post.
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
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';
 

Supermario

Member
Jan 5, 2016
99
0
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';

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:

Supermario

Member
Jan 5, 2016
99
0
You'd have to change the field name to what it is in your database, "diamonds" was just an example field name

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:

BIOS

ಠ‿ಠ
Apr 25, 2012
906
247
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?
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;
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
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;
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.
 

Brad

Well-Known Member
Jun 5, 2012
2,319
992
show me the curre
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;
This would only work for those offline :p

give me 5 minutes and Ill code it for you.
 
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:

Supermario

Member
Jan 5, 2016
99
0
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.

show me the curre

This would only work for those offline :p

give me 5 minutes and Ill code it for you.
 
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);
        }
    }
}

Thank you for helping me. I really appreciate your help
 
Thank you for helping me. I really appreciate your help

@Brad After a few restarts, The Emulator gave me errors.
 

Meap

Don't need glasses if you C#
Nov 7, 2010
1,045
296
show me the curre

This would only work for those offline :p

give me 5 minutes and Ill code it for you.
 
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);
        }
    }
}
@Obbler found it for you
 

WanknessHD

Hardcore Habboer
Jun 13, 2011
48
5
show me the curre

This would only work for those offline :p

give me 5 minutes and Ill code it for you.
 
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);
        }
    }
}
Now how can I change the time so that every hour they get 1 diamond.
 

Meap

Don't need glasses if you C#
Nov 7, 2010
1,045
296
Now how can I change the time so that every hour they get 1 diamond.
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
 

WanknessHD

Hardcore Habboer
Jun 13, 2011
48
5
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
Oh okay so I just change the credit/pixel timer so that they all will give out every hour I can do that.
 

Meap

Don't need glasses if you C#
Nov 7, 2010
1,045
296
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
 

Users who are viewing this thread

Top