Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
Convert Diamonds
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Joe" data-source="post: 390558" data-attributes="member: 18160"><p>Hey,</p><p></p><p>I'm looking for a convert diamonds command, it's probably very straight forward but I don't really have any experience with C#.</p><p></p><p>Here's the ConvertCreditsCommand</p><p>[SPOILER="ConvertCreditsCommand"]</p><p>[CODE]using System;</p><p>using System.Linq;</p><p>using System.Text;</p><p>using System.Collections.Generic;</p><p>using System.Data;</p><p></p><p>using Plus.HabboHotel.Items;</p><p>using Plus.Communication.Packets.Outgoing.Inventory.Purse;</p><p>using Plus.Database.Interfaces;</p><p></p><p>namespace Plus.HabboHotel.Rooms.Chat.Commands.User</p><p>{</p><p> class ConvertCreditsCommand : IChatCommand</p><p> {</p><p> public string PermissionRequired</p><p> {</p><p> get { return "command_convert_credits"; }</p><p> }</p><p></p><p> public string Parameters</p><p> {</p><p> get { return ""; }</p><p> }</p><p></p><p> public string Description</p><p> {</p><p> get { return "Convert your exchangeable furniture into actual credits."; }</p><p> }</p><p></p><p> public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)</p><p> {</p><p> int TotalValue = 0;</p><p></p><p> try</p><p> {</p><p> DataTable Table = null; </p><p> using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())</p><p> {</p><p> dbClient.SetQuery("SELECT `id` FROM `items` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND (`room_id`= '0' OR `room_id` = '')");</p><p> Table = dbClient.getTable();</p><p> }</p><p></p><p> if (Table == null)</p><p> {</p><p> Session.SendWhisper("You currently have no items in your inventory!");</p><p> return;</p><p> }</p><p></p><p> foreach (DataRow Row in Table.Rows)</p><p> {</p><p> Item Item = Session.GetHabbo().GetInventoryComponent().GetItem(Convert.ToInt32(Row[0]));</p><p> if (Item == null)</p><p> continue;</p><p></p><p> if (!Item.GetBaseItem().ItemName.StartsWith("CF_") && !Item.GetBaseItem().ItemName.StartsWith("CFC_"))</p><p> continue;</p><p></p><p> if (Item.RoomId > 0)</p><p> continue;</p><p></p><p> string[] Split = Item.GetBaseItem().ItemName.Split('_');</p><p> int Value = int.Parse(Split[1]);</p><p> </p><p> using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())</p><p> {</p><p> dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + Item.Id + "' LIMIT 1");</p><p> }</p><p></p><p> Session.GetHabbo().GetInventoryComponent().RemoveItem(Item.Id);</p><p></p><p> TotalValue += Value;</p><p></p><p> if (Value > 0)</p><p> {</p><p> Session.GetHabbo().Credits += Value;</p><p> Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits));</p><p> }</p><p> }</p><p></p><p> if (TotalValue > 0)</p><p> Session.SendNotification("All credits have successfully been converted!\r\r(Total value: " + TotalValue + " credits!");</p><p> else</p><p> Session.SendNotification("It appears you don't have any exchangeable items!");</p><p> }</p><p> catch</p><p> {</p><p> Session.SendNotification("Oops, an error occoured whilst converting your credits!");</p><p> }</p><p> }</p><p> }</p><p>}</p><p>[/CODE]</p><p>[/SPOILER]</p></blockquote><p></p>
[QUOTE="Joe, post: 390558, member: 18160"] Hey, I'm looking for a convert diamonds command, it's probably very straight forward but I don't really have any experience with C#. Here's the ConvertCreditsCommand [SPOILER="ConvertCreditsCommand"] [CODE]using System; using System.Linq; using System.Text; using System.Collections.Generic; using System.Data; using Plus.HabboHotel.Items; using Plus.Communication.Packets.Outgoing.Inventory.Purse; using Plus.Database.Interfaces; namespace Plus.HabboHotel.Rooms.Chat.Commands.User { class ConvertCreditsCommand : IChatCommand { public string PermissionRequired { get { return "command_convert_credits"; } } public string Parameters { get { return ""; } } public string Description { get { return "Convert your exchangeable furniture into actual credits."; } } public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params) { int TotalValue = 0; try { DataTable Table = null; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `id` FROM `items` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND (`room_id`= '0' OR `room_id` = '')"); Table = dbClient.getTable(); } if (Table == null) { Session.SendWhisper("You currently have no items in your inventory!"); return; } foreach (DataRow Row in Table.Rows) { Item Item = Session.GetHabbo().GetInventoryComponent().GetItem(Convert.ToInt32(Row[0])); if (Item == null) continue; if (!Item.GetBaseItem().ItemName.StartsWith("CF_") && !Item.GetBaseItem().ItemName.StartsWith("CFC_")) continue; if (Item.RoomId > 0) continue; string[] Split = Item.GetBaseItem().ItemName.Split('_'); int Value = int.Parse(Split[1]); using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + Item.Id + "' LIMIT 1"); } Session.GetHabbo().GetInventoryComponent().RemoveItem(Item.Id); TotalValue += Value; if (Value > 0) { Session.GetHabbo().Credits += Value; Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits)); } } if (TotalValue > 0) Session.SendNotification("All credits have successfully been converted!\r\r(Total value: " + TotalValue + " credits!"); else Session.SendNotification("It appears you don't have any exchangeable items!"); } catch { Session.SendNotification("Oops, an error occoured whilst converting your credits!"); } } } } [/CODE] [/SPOILER] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
Convert Diamonds
Top