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 Releases
Server Releases
[NEW] Lotto System
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="Pollak" data-source="post: 455635" data-attributes="member: 77990"><p style="text-align: center">Hii again xd! I'm sharing lotto system i coded.</p> <p style="text-align: center">I won't teach you how to do everything right. If you want to add this feature, have some idea how to add it in the emulator.</p> <p style="text-align: center"></p> <p style="text-align: center"><strong>1- </strong>Create a new file with the name: <strong>LottoParticipateCommand.cs</strong></p><p>[CODE=csharp]#region</p><p>using Saturn.HabboHotel.Lotto;</p><p>using Saturn.Communication.Packets.Outgoing.Inventory.Purse;</p><p>using Saturn.HabboHotel.GameClients;</p><p>using System;</p><p>#endregion</p><p></p><p>namespace Saturn.HabboHotel.Rooms.Chat.Commands.User</p><p>{</p><p> internal class LottoParticipateCommand : IChatCommand</p><p> {</p><p> public string PermissionRequired => "command_lotto_participate";</p><p></p><p> public string Parameters => "";</p><p></p><p> public string Description => "Join the lottery.";</p><p></p><p> public void Execute(GameClient Session, Room Room, string[] Params)</p><p> {</p><p> int LottoDiscount = Convert.ToInt32(SaturnEnvironment.GetDBConfig().DBData["lotto.discount.credits"]);</p><p> int LottoMaxParticipants = Convert.ToInt32(SaturnEnvironment.GetDBConfig().DBData["lotto.max.participants.per.user"]);</p><p> int LottoIdentificator = Convert.ToInt32(SaturnEnvironment.GetDBConfig().DBData["lotto.id"]);</p><p></p><p> LottoItem lotto = null;</p><p> if (SaturnEnvironment.GetGame().GetLotto().TryGet(LottoIdentificator, out lotto))</p><p> {</p><p> if (!lotto.Enabled)</p><p> {</p><p> Session.SendWhisper("Oops, the lottery is off!", 34);</p><p> return;</p><p> }</p><p></p><p> if (Session.GetHabbo().Credits < LottoDiscount)</p><p> {</p><p> Session.SendWhisper("Oops, you don't have enough credits!", 34);</p><p> return;</p><p> }</p><p></p><p> if (LottoDiscount > Session.GetHabbo().Credits)</p><p> {</p><p> Session.SendWhisper("Oops, you don't have enough credits!", 34);</p><p> return;</p><p> }</p><p></p><p> if (LottoDiscount <= 0)</p><p> return;</p><p></p><p> int count = 0;</p><p> if (lotto.Users.Contains(Session.GetHabbo().Id))</p><p> {</p><p> foreach(var howmuch in lotto.Users)</p><p> {</p><p> if (howmuch == Session.GetHabbo().Id)</p><p> count++;</p><p> }</p><p> }</p><p></p><p> if (count >= LottoMaxParticipants)</p><p> {</p><p> Session.SendWhisper("Oops, you can only participate in this Lottery " + LottoMaxParticipants + " times!", 3);</p><p> return;</p><p> }</p><p></p><p> Session.GetHabbo().Credits -= LottoDiscount;</p><p> Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits));</p><p></p><p> lotto.Users.Add(Session.GetHabbo().Id);</p><p></p><p> string users = "";</p><p> foreach (int userst in lotto.Users)</p><p> {</p><p> users += userst + ",";</p><p> }</p><p></p><p> if (!string.IsNullOrEmpty(users))</p><p> users = users.Substring(0, users.Length - 1);</p><p></p><p> Session.SendWhisper("Is participating in the Lottery " + lotto.LottoName + "! Cost " + LottoDiscount + " credits!", 34);</p><p></p><p> LottoManager.UpdatesInfos(LottoIdentificator, users, LottoDiscount, true, true);</p><p> SaturnEnvironment.GetGame().GetLotto().Init(SaturnEnvironment.GetDatabaseManager().GetQueryReactor());</p><p> }</p><p> else</p><p> {</p><p> Session.SendWhisper("Oops, the lottery is not available!", 34);</p><p> return;</p><p> }</p><p> }</p><p> }</p><p>}[/CODE]</p><p></p><p style="text-align: center"><strong>2- </strong>Create another file with name: <strong>LottoOpenCommand.cs</strong></p><p>[CODE=csharp]#region</p><p>using Saturn.Communication.Packets.Outgoing.Inventory.Purse;</p><p>using Saturn.Core;</p><p>using Saturn.HabboHotel.GameClients;</p><p>using Saturn.HabboHotel.Lotto;</p><p>using System;</p><p>using System.Collections.Generic;</p><p>#endregion</p><p></p><p>namespace Saturn.HabboHotel.Rooms.Chat.Commands.Administrator</p><p>{</p><p> class LottoOpenCommand : IChatCommand</p><p> {</p><p> public string PermissionRequired => "command_lotto_open";</p><p></p><p> public string Parameters => "";</p><p></p><p> public string Description => "Open the lottery pot.";</p><p></p><p> public void Execute(GameClient Session, Room Room, string[] Params)</p><p> {</p><p> int LottoIdentificator = Convert.ToInt32(SaturnEnvironment.GetDBConfig().DBData["lotto.id"]);</p><p></p><p> LottoItem lotto = null;</p><p> if (SaturnEnvironment.GetGame().GetLotto().TryGet(LottoIdentificator, out lotto))</p><p> {</p><p> if (!lotto.Enabled)</p><p> {</p><p> Session.SendWhisper("Oops, the lottery is off!", 34);</p><p> return;</p><p> }</p><p></p><p> try</p><p> {</p><p> var RANDOM_WIN = new List<int>();</p><p> int RandomUser = 0;</p><p> foreach (int user in lotto.Users)</p><p> {</p><p> if (!RANDOM_WIN.Contains(user))</p><p> RANDOM_WIN.Add(user);</p><p></p><p> RandomUser = new Random().Next(RANDOM_WIN.Count);</p><p> }</p><p></p><p> var TargetClient = SaturnEnvironment.GetHabboById(RANDOM_WIN[RandomUser]);</p><p></p><p> Session.SendWhisper("The random user was: " + TargetClient.Username + " ! Won " + lotto.ValueTotal + " credits!", 34);</p><p></p><p> LottoManager.Desactive(LottoIdentificator, true);</p><p> SaturnEnvironment.GetGame().GetLotto().Init(SaturnEnvironment.GetDatabaseManager().GetQueryReactor());</p><p></p><p> if (!TargetClient.Online)</p><p> {</p><p> LottoManager.UpdateTypesCoins(RANDOM_WIN[RandomUser], lotto.ValueTotal, true);</p><p> return;</p><p> }</p><p> else</p><p> {</p><p> TargetClient.Credits += lotto.ValueTotal;</p><p> TargetClient.GetClient().SendMessage(new CreditBalanceComposer(TargetClient.Credits));</p><p></p><p> TargetClient.GetClient().SendNotification("Hi! You won the lottery " + lotto.LottoName + " and with an amazing pot of " + lotto.ValueTotal + " credits!");</p><p> return;</p><p> }</p><p> }</p><p> catch (Exception e)</p><p> {</p><p> Logging.LogCriticalException(e.ToString());</p><p> }</p><p> }</p><p> else</p><p> {</p><p> Session.SendWhisper("Oops, the lottery is not available!", 34);</p><p> return;</p><p> }</p><p> }</p><p> }</p><p>}[/CODE]</p><p></p><p style="text-align: center"><strong>3- </strong>Now go to folder HabboHotel> and create new folder "<strong>Lotto</strong>"</p> <p style="text-align: center">Create a new file with the name: <strong>LottoItem.cs</strong></p><p>[CODE=csharp]using System;</p><p>using System.Collections.Generic;</p><p></p><p>namespace Saturn.HabboHotel.Lotto</p><p>{</p><p> internal class LottoItem</p><p> {</p><p> public int Id;</p><p> public string LottoName;</p><p> public List<int> Users;</p><p> public int ValueTotal;</p><p> public bool Enabled;</p><p></p><p> public LottoItem(int id, string lottoName, string users, int valueTotal, bool enabled)</p><p> {</p><p> this.Id = id;</p><p> this.LottoName = lottoName;</p><p> this.Users = new List<int>();</p><p> this.ValueTotal = valueTotal;</p><p> this.Enabled = enabled;</p><p></p><p> foreach (var userId in users.ToString().Split(','))</p><p> {</p><p> if (string.IsNullOrEmpty(userId.ToString()))</p><p> continue;</p><p></p><p> Users.Add(Convert.ToInt32(userId));</p><p> }</p><p> }</p><p> }</p><p>}[/CODE]</p><p></p><p style="text-align: center">Create new file with the name: <strong>LottoManager.cs</strong></p><p>[CODE=csharp]#region</p><p>using Saturn.Database.Interfaces;</p><p>using System;</p><p>using System.Collections.Generic;</p><p>using System.Data;</p><p>#endregion</p><p></p><p>namespace Saturn.HabboHotel.Lotto</p><p>{</p><p> internal class LottoManager</p><p> {</p><p> public Dictionary<int, LottoItem> lotto;</p><p></p><p> internal LottoManager()</p><p> {</p><p> lotto = new Dictionary<int, LottoItem>();</p><p> Init(SaturnEnvironment.GetDatabaseManager().GetQueryReactor());</p><p> }</p><p></p><p> internal void Init(IQueryAdapter dbClient)</p><p> {</p><p> if (lotto.Count > 0)</p><p> lotto.Clear();</p><p></p><p> dbClient.SetQuery("SELECT `id`, `lotto_name`, `users`, `value_total`, `enabled` FROM `lotto_config`");</p><p> DataTable GetLotto = dbClient.getTable();</p><p></p><p> if (GetLotto != null)</p><p> {</p><p> foreach(DataRow row in GetLotto.Rows)</p><p> {</p><p> lotto.Add(Convert.ToInt32(row["id"]), new LottoItem(Convert.ToInt32(row["id"]), Convert.ToString(row["lotto_name"]), Convert.ToString(row["users"]), Convert.ToInt32(row["value_total"]), SaturnEnvironment.EnumToBool(row["enabled"].ToString())));</p><p> }</p><p> }</p><p> }</p><p></p><p> public static string UpdatesInfos(int Id, string Users, int Discount, bool UpdateUsers, bool UpdateValueTotal)</p><p> {</p><p> string name = "";</p><p></p><p> if (UpdateUsers)</p><p> {</p><p> using (IQueryAdapter dbClient = SaturnEnvironment.GetDatabaseManager().GetQueryReactor())</p><p> {</p><p> dbClient.runFastQuery("UPDATE `lotto_config` SET `users`='" + Users + "' WHERE `id`=" + Id + "");</p><p> }</p><p> }</p><p></p><p> if (UpdateValueTotal)</p><p> {</p><p> using (IQueryAdapter dbClient = SaturnEnvironment.GetDatabaseManager().GetQueryReactor())</p><p> {</p><p> dbClient.runFastQuery("UPDATE `lotto_config` SET `value_total`=value_total + " + Discount + " WHERE `id`=" + Id + "");</p><p> }</p><p> }</p><p></p><p> return name;</p><p> }</p><p></p><p> public static int UpdateTypesCoins(int UserId, int ValueTotal, bool Credits)</p><p> {</p><p> int value = 0;</p><p></p><p> if (Credits)</p><p> {</p><p> using (IQueryAdapter dbClient = SaturnEnvironment.GetDatabaseManager().GetQueryReactor())</p><p> {</p><p> dbClient.runFastQuery("UPDATE `users` SET `credits`= credits + " + ValueTotal + " WHERE `id`=" + UserId + " LIMIT 1");</p><p> }</p><p> }</p><p></p><p> return value;</p><p> }</p><p></p><p> public static string Desactive(int Id, bool Desactive)</p><p> {</p><p> string name = "";</p><p></p><p> if (Desactive)</p><p> {</p><p> using (IQueryAdapter dbClient = SaturnEnvironment.GetDatabaseManager().GetQueryReactor())</p><p> {</p><p> dbClient.runFastQuery("UPDATE `lotto_config` SET `enabled`='0' WHERE `id`=" + Id + "");</p><p> }</p><p> }</p><p></p><p> return name;</p><p> }</p><p></p><p> public bool TryGet(int Id, out LottoItem Ident)</p><p> {</p><p> if (this.lotto.TryGetValue(Id, out Ident))</p><p> return true;</p><p> return false;</p><p> }</p><p> }</p><p>}[/CODE]</p><p></p><p style="text-align: center"><strong>4- </strong>Open the file Game.cs (Plus>HabboHotel)</p> <p style="text-align: center">and insert after:</p> <p style="text-align: center">public class Game</p> <p style="text-align: center">{</p> <p style="text-align: center">this:</p><p> [CODE] private readonly LottoManager _lottoM;[/CODE]</p><p></p><p style="text-align: center">After:</p> <p style="text-align: center">public Game()</p> <p style="text-align: center">{</p> <p style="text-align: center">add:</p><p>[CODE] this._lottoM = new LottoManager();</p><p>[/CODE]</p><p></p><p style="text-align: center">after public void StopGameLoop()</p> <p style="text-align: center">{</p> <p style="text-align: center">code etc..</p> <p style="text-align: center">}</p> <p style="text-align: center">add this:</p> <p style="text-align: center"></p> <p style="text-align: center"></p><p>[CODE]internal LottoManager GetLotto()</p><p> {</p><p> return _lottoM;</p><p> }[/CODE]</p><p></p><p style="text-align: center">Don't forget add the using</p><p>[CODE]using Saturn.HabboHotel.Lotto;</p><p>[/CODE]</p><p></p><p style="text-align: center"><strong>5- </strong>Open the file CommandManager.cs (commands xd)</p> <p style="text-align: center">After:</p> <p style="text-align: center">private void RegisterUser()</p> <p style="text-align: center">{</p> <p style="text-align: center">add:</p><p>[CODE] Register("plotto", new LottoParticipateCommand());</p><p>[/CODE]</p><p></p><p style="text-align: center">After:</p> <p style="text-align: center">private void RegisterAdministrator()</p> <p style="text-align: center">{</p> <p style="text-align: center">add:</p><p>[CODE] Register("lottopen", new LottoOpenCommand());</p><p>[/CODE]</p><p></p><p style="text-align: center"><strong>6- </strong>Add in your table permissions_commands:</p> <p style="text-align: center">command_lotto_participate and command_lotto_open</p> <p style="text-align: center"></p> <p style="text-align: center"><strong>7- </strong>Run this:</p><p>[CODE=sql]INSERT INTO `server_settings` (`variable`, `value`, `description`) VALUES ('lotto.id', '1', 'Lotto Identificator to use (id).');</p><p>INSERT INTO `server_settings` (`variable`, `value`, `description`) VALUES ('lotto.max.participants.per.user', '10', 'Limit participants per user (10).');</p><p>INSERT INTO `server_settings` (`variable`, `value`, `description`) VALUES ('lotto.discount.credits', '100', 'Discount credits (100).')[/CODE]</p><p></p><p style="text-align: center"><strong>8- </strong>Create the table:</p><p>[CODE]CREATE TABLE `lotto_config` (</p><p> `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,</p><p> `lotto_name` VARCHAR(125) NOT NULL,</p><p> `users` MEDIUMTEXT NOT NULL,</p><p> `value_total` INT(11) NOT NULL DEFAULT '0',</p><p> `enabled` ENUM('0','1') NOT NULL DEFAULT '1',</p><p> PRIMARY KEY (`id`),</p><p> UNIQUE INDEX `lotto_name` (`lotto_name`)</p><p>)</p><p>COLLATE='latin1_swedish_ci'</p><p>ENGINE=InnoDB</p><p>AUTO_INCREMENT=2</p><p>;</p><p>[/CODE]</p><p style="text-align: center"></p> <p style="text-align: center">Debug and be happy!</p> <p style="text-align: center"></p> <p style="text-align: center"><strong>Credits:</strong></p> <p style="text-align: center"><strong>Pollak (Snaiker)</strong></p> <p style="text-align: center"></p></blockquote><p></p>
[QUOTE="Pollak, post: 455635, member: 77990"] [CENTER]Hii again xd! I'm sharing lotto system i coded. I won't teach you how to do everything right. If you want to add this feature, have some idea how to add it in the emulator. [B]1- [/B]Create a new file with the name: [B]LottoParticipateCommand.cs[/B][/CENTER] [CODE=csharp]#region using Saturn.HabboHotel.Lotto; using Saturn.Communication.Packets.Outgoing.Inventory.Purse; using Saturn.HabboHotel.GameClients; using System; #endregion namespace Saturn.HabboHotel.Rooms.Chat.Commands.User { internal class LottoParticipateCommand : IChatCommand { public string PermissionRequired => "command_lotto_participate"; public string Parameters => ""; public string Description => "Join the lottery."; public void Execute(GameClient Session, Room Room, string[] Params) { int LottoDiscount = Convert.ToInt32(SaturnEnvironment.GetDBConfig().DBData["lotto.discount.credits"]); int LottoMaxParticipants = Convert.ToInt32(SaturnEnvironment.GetDBConfig().DBData["lotto.max.participants.per.user"]); int LottoIdentificator = Convert.ToInt32(SaturnEnvironment.GetDBConfig().DBData["lotto.id"]); LottoItem lotto = null; if (SaturnEnvironment.GetGame().GetLotto().TryGet(LottoIdentificator, out lotto)) { if (!lotto.Enabled) { Session.SendWhisper("Oops, the lottery is off!", 34); return; } if (Session.GetHabbo().Credits < LottoDiscount) { Session.SendWhisper("Oops, you don't have enough credits!", 34); return; } if (LottoDiscount > Session.GetHabbo().Credits) { Session.SendWhisper("Oops, you don't have enough credits!", 34); return; } if (LottoDiscount <= 0) return; int count = 0; if (lotto.Users.Contains(Session.GetHabbo().Id)) { foreach(var howmuch in lotto.Users) { if (howmuch == Session.GetHabbo().Id) count++; } } if (count >= LottoMaxParticipants) { Session.SendWhisper("Oops, you can only participate in this Lottery " + LottoMaxParticipants + " times!", 3); return; } Session.GetHabbo().Credits -= LottoDiscount; Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits)); lotto.Users.Add(Session.GetHabbo().Id); string users = ""; foreach (int userst in lotto.Users) { users += userst + ","; } if (!string.IsNullOrEmpty(users)) users = users.Substring(0, users.Length - 1); Session.SendWhisper("Is participating in the Lottery " + lotto.LottoName + "! Cost " + LottoDiscount + " credits!", 34); LottoManager.UpdatesInfos(LottoIdentificator, users, LottoDiscount, true, true); SaturnEnvironment.GetGame().GetLotto().Init(SaturnEnvironment.GetDatabaseManager().GetQueryReactor()); } else { Session.SendWhisper("Oops, the lottery is not available!", 34); return; } } } }[/CODE] [CENTER][B]2- [/B]Create another file with name: [B]LottoOpenCommand.cs[/B][/CENTER] [CODE=csharp]#region using Saturn.Communication.Packets.Outgoing.Inventory.Purse; using Saturn.Core; using Saturn.HabboHotel.GameClients; using Saturn.HabboHotel.Lotto; using System; using System.Collections.Generic; #endregion namespace Saturn.HabboHotel.Rooms.Chat.Commands.Administrator { class LottoOpenCommand : IChatCommand { public string PermissionRequired => "command_lotto_open"; public string Parameters => ""; public string Description => "Open the lottery pot."; public void Execute(GameClient Session, Room Room, string[] Params) { int LottoIdentificator = Convert.ToInt32(SaturnEnvironment.GetDBConfig().DBData["lotto.id"]); LottoItem lotto = null; if (SaturnEnvironment.GetGame().GetLotto().TryGet(LottoIdentificator, out lotto)) { if (!lotto.Enabled) { Session.SendWhisper("Oops, the lottery is off!", 34); return; } try { var RANDOM_WIN = new List<int>(); int RandomUser = 0; foreach (int user in lotto.Users) { if (!RANDOM_WIN.Contains(user)) RANDOM_WIN.Add(user); RandomUser = new Random().Next(RANDOM_WIN.Count); } var TargetClient = SaturnEnvironment.GetHabboById(RANDOM_WIN[RandomUser]); Session.SendWhisper("The random user was: " + TargetClient.Username + " ! Won " + lotto.ValueTotal + " credits!", 34); LottoManager.Desactive(LottoIdentificator, true); SaturnEnvironment.GetGame().GetLotto().Init(SaturnEnvironment.GetDatabaseManager().GetQueryReactor()); if (!TargetClient.Online) { LottoManager.UpdateTypesCoins(RANDOM_WIN[RandomUser], lotto.ValueTotal, true); return; } else { TargetClient.Credits += lotto.ValueTotal; TargetClient.GetClient().SendMessage(new CreditBalanceComposer(TargetClient.Credits)); TargetClient.GetClient().SendNotification("Hi! You won the lottery " + lotto.LottoName + " and with an amazing pot of " + lotto.ValueTotal + " credits!"); return; } } catch (Exception e) { Logging.LogCriticalException(e.ToString()); } } else { Session.SendWhisper("Oops, the lottery is not available!", 34); return; } } } }[/CODE] [CENTER][B]3- [/B]Now go to folder HabboHotel> and create new folder "[B]Lotto[/B]" Create a new file with the name: [B]LottoItem.cs[/B][/CENTER] [CODE=csharp]using System; using System.Collections.Generic; namespace Saturn.HabboHotel.Lotto { internal class LottoItem { public int Id; public string LottoName; public List<int> Users; public int ValueTotal; public bool Enabled; public LottoItem(int id, string lottoName, string users, int valueTotal, bool enabled) { this.Id = id; this.LottoName = lottoName; this.Users = new List<int>(); this.ValueTotal = valueTotal; this.Enabled = enabled; foreach (var userId in users.ToString().Split(',')) { if (string.IsNullOrEmpty(userId.ToString())) continue; Users.Add(Convert.ToInt32(userId)); } } } }[/CODE] [CENTER]Create new file with the name: [B]LottoManager.cs[/B][/CENTER] [CODE=csharp]#region using Saturn.Database.Interfaces; using System; using System.Collections.Generic; using System.Data; #endregion namespace Saturn.HabboHotel.Lotto { internal class LottoManager { public Dictionary<int, LottoItem> lotto; internal LottoManager() { lotto = new Dictionary<int, LottoItem>(); Init(SaturnEnvironment.GetDatabaseManager().GetQueryReactor()); } internal void Init(IQueryAdapter dbClient) { if (lotto.Count > 0) lotto.Clear(); dbClient.SetQuery("SELECT `id`, `lotto_name`, `users`, `value_total`, `enabled` FROM `lotto_config`"); DataTable GetLotto = dbClient.getTable(); if (GetLotto != null) { foreach(DataRow row in GetLotto.Rows) { lotto.Add(Convert.ToInt32(row["id"]), new LottoItem(Convert.ToInt32(row["id"]), Convert.ToString(row["lotto_name"]), Convert.ToString(row["users"]), Convert.ToInt32(row["value_total"]), SaturnEnvironment.EnumToBool(row["enabled"].ToString()))); } } } public static string UpdatesInfos(int Id, string Users, int Discount, bool UpdateUsers, bool UpdateValueTotal) { string name = ""; if (UpdateUsers) { using (IQueryAdapter dbClient = SaturnEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `lotto_config` SET `users`='" + Users + "' WHERE `id`=" + Id + ""); } } if (UpdateValueTotal) { using (IQueryAdapter dbClient = SaturnEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `lotto_config` SET `value_total`=value_total + " + Discount + " WHERE `id`=" + Id + ""); } } return name; } public static int UpdateTypesCoins(int UserId, int ValueTotal, bool Credits) { int value = 0; if (Credits) { using (IQueryAdapter dbClient = SaturnEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `credits`= credits + " + ValueTotal + " WHERE `id`=" + UserId + " LIMIT 1"); } } return value; } public static string Desactive(int Id, bool Desactive) { string name = ""; if (Desactive) { using (IQueryAdapter dbClient = SaturnEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `lotto_config` SET `enabled`='0' WHERE `id`=" + Id + ""); } } return name; } public bool TryGet(int Id, out LottoItem Ident) { if (this.lotto.TryGetValue(Id, out Ident)) return true; return false; } } }[/CODE] [CENTER][B]4- [/B]Open the file Game.cs (Plus>HabboHotel) and insert after: public class Game { this:[/CENTER] [CODE] private readonly LottoManager _lottoM;[/CODE] [CENTER]After: public Game() { add:[/CENTER] [CODE] this._lottoM = new LottoManager(); [/CODE] [CENTER]after public void StopGameLoop() { code etc.. } add this: [/CENTER] [CODE]internal LottoManager GetLotto() { return _lottoM; }[/CODE] [CENTER]Don't forget add the using[/CENTER] [CODE]using Saturn.HabboHotel.Lotto; [/CODE] [CENTER][B]5- [/B]Open the file CommandManager.cs (commands xd) After: private void RegisterUser() { add:[/CENTER] [CODE] Register("plotto", new LottoParticipateCommand()); [/CODE] [CENTER]After: private void RegisterAdministrator() { add:[/CENTER] [CODE] Register("lottopen", new LottoOpenCommand()); [/CODE] [CENTER][B]6- [/B]Add in your table permissions_commands: command_lotto_participate and command_lotto_open [B]7- [/B]Run this:[/CENTER] [CODE=sql]INSERT INTO `server_settings` (`variable`, `value`, `description`) VALUES ('lotto.id', '1', 'Lotto Identificator to use (id).'); INSERT INTO `server_settings` (`variable`, `value`, `description`) VALUES ('lotto.max.participants.per.user', '10', 'Limit participants per user (10).'); INSERT INTO `server_settings` (`variable`, `value`, `description`) VALUES ('lotto.discount.credits', '100', 'Discount credits (100).')[/CODE] [CENTER][B]8- [/B]Create the table:[/CENTER] [CODE]CREATE TABLE `lotto_config` ( `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, `lotto_name` VARCHAR(125) NOT NULL, `users` MEDIUMTEXT NOT NULL, `value_total` INT(11) NOT NULL DEFAULT '0', `enabled` ENUM('0','1') NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE INDEX `lotto_name` (`lotto_name`) ) COLLATE='latin1_swedish_ci' ENGINE=InnoDB AUTO_INCREMENT=2 ; [/CODE] [CENTER] Debug and be happy! [B]Credits: Pollak (Snaiker)[/B] [/CENTER] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Releases
Server Releases
[NEW] Lotto System
Top