Diamond timer PLUSemu r2 3.4.3.0

Pollak

Active Member
Oct 12, 2017
161
51
I am looking for a way to put a value for diamonds in my database to give the user 1 diamond every 15minute, like i have for coins and duckets.
Simple xd use PlusEnvironment.GetDBConfig().DBData["name variable"]; and configure in server_settings (this if u want configure the value) or u dont know how add new function for diamonds?
 

alek980

New Member
Oct 7, 2019
27
1
Simple xd use PlusEnvironment.GetDBConfig().DBData["name variable"]; and configure in server_settings (this if u want configure the value) or u dont know how add new function for diamonds?

I struggle with getting the function i added to work. Tried several different codes i have found, but they didn't work. Have not found any for my specific version of plusemu thogh.
Post automatically merged:


I added this to my server settings-table:
user.currency_scheduler.diamond_reward
value 1


My habbo.cs looks like this:

public void CheckCreditsTimer()
{
try
{
this._creditsTickUpdate--;

if (this._creditsTickUpdate <= 0)
{
int CreditUpdate = Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("user.currency_scheduler.credit_reward"));
int DucketUpdate = Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("user.currency_scheduler.ducket_reward"));
int DiamondUpdate = Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("user.currency_scheduler.diamond_reward"));

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.SendPacket(new CreditBalanceComposer(this._credits));
this._client.SendPacket(new HabboActivityPointNotificationComposer(this._duckets, DucketUpdate));
this._client.SendPacket(new HabboActivityPointNotificationComposer(this.Diamonds, DiamondUpdate, 5));
this.CreditsUpdateTick = Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("user.currency_scheduler.tick"));
}
}
catch { }
}


My SubscriptionData.cs looks like this:


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;
}
}
}


My SubscriptionManager.cs looks like this
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:

Users who are viewing this thread

Top