SOUL
┼ ┼ ┼
- Nov 10, 2015
- 224
- 45
Yo,
Releasing this as thought it would be a nice share anyhow...
How does this work?
Upon the user executing command in the format :jail username time the TargetClient will be sent to jail to the given time. A timer is then activated & disposed upon disconnection / completion of the timer.
The user cannot talk , leave the room , use the navigator , follow their friends nor message their friends until their timer is completed
Why the fuck are you storing it in the DB?
This was done a while ago keep in mind caching also uses a bit of RAM & CPU Usage , although thats no excuse to store it in the database rather than in memory.
Not going to fix what ain't broken , in regards to your MySQL server this will put slight strain on it but not to any extent where it's going to damage or slow down your MySQL server so disregard any bullshit comments in regards to this.
Adding this to PlusEMU
Run both of these SQLS
Go to Habbo.cs and find private int _id; under this put
At the top of Habbo.cs put
Find private int _friendCount; under this put
Next find
At the end add
Under the { add
Find
Under this add
Then find
And replace it with
Find
Under this insert
Okay we're done with this class , now go to Authenticator.cs
Change Convert.ToInt32(Row["rank_vip"])); to Convert.ToInt32(Row["rank_vip"]), and add the following code next to it
Go to UserDataFactory.cs & Find
And replace with
Find
Replace with
Go to HabboHotel > Rooms > Chat > Commands > Administrator
Right click then click "Add new class" and call it JailUserCommand
Delete everything in the current class and replace it with
Navigate to the following classes , "ShoutEvent" "WhisperEvent" "ChatEvent"
In each class insert the following code somewhere
Go to SendMsgEvent
And insert the following code
Go to FollowFriendEvent
And insert the following code
Go to GameClient.cs and find the following
Under this put
In GameClient find
And replace with the following code
Now go to SSOTicketEvent
And replace the last line with the following code
Nearly done just a few more classes!
Go to the following classes UpdateNavigatorSettingsEvent , GetNavigatorFlatsEvent , NewNavigatorSearchEvent , InitializeNewNavigatorEvent & CanCreateRoomEvent
And insert the following code somewhere in each class
Go to CommandManager
Add the following code
Add the following in permission_commands
Finally go to
Then go to Swf/c_images/Notifications
And drag it in there
Re-build your solution and you're done!
Code:
ALTER TABLE `users` ADD `in_jail` int(11) NOT NULL
ALTER TABLE `users` ADD `jail_time` int(11) NOT NULL
Go to Habbo.cs and find private int _id; under this put
Code:
public Timer JailTimer;
At the top of Habbo.cs put
Code:
using System.Timers;
Find private int _friendCount; under this put
Code:
private int _jail_time;
private int _in_jail;
Next find
Code:
public Habbo(int Id, string Username, int Rank, string Motto, string Look, string Gender, int Credits, int ActivityPoints, int HomeRoom,
bool HasFriendRequestsDisabled, int LastOnline, bool AppearOffline, bool HideInRoom, double CreateDate, int Diamonds,
string machineID, string clientVolume, bool ChatPreference, bool FocusPreference, bool PetsMuted, bool BotsMuted, bool AdvertisingReportBlocked, double LastNameChange,
int GOTWPoints, bool IgnoreInvites, double TimeMuted, double TradingLock, bool AllowGifts, int FriendBarState, bool DisableForcedEffects, bool AllowMimic, int VIPRank)
At the end add
Code:
,int In_Jail, int Jail_Time
Under the { add
Code:
this._jail_time = Jail_Time;
this._in_jail = In_Jail;
Find
Code:
public int Id
{
get { return this._id; }
set { this._id = value; }
}
Code:
public int Jail_Time
{
get { return this._jail_time; }
set { this._jail_time = value; }
}
public int In_Jail
{
get { return this._in_jail; }
set { this._in_jail = value; }
}
Then find
Code:
public string GetQueryString
{
get
{
this._habboSaved = true;
return "UPDATE `users` SET `online` = '0', `last_online` = '" + PlusEnvironment.GetUnixTimestamp() + "', `activity_points` = '" + this.Duckets + "', `credits` = '" + this.Credits + "', `in_jail` = '" + this.In_Jail + "', `jail_time` = '" + this.Jail_Time + "', `vip_points` = '" + this.Diamonds + "', `home_room` = '" + this.HomeRoom + "', `gotw_points` = '" + this.GOTWPoints + "', `time_muted` = '" + this.TimeMuted + "',`friend_bar_state` = '" + FriendBarStateUtility.GetInt(this._friendbarState) + "' WHERE id = '" + Id + "' LIMIT 1;UPDATE `user_stats` SET `roomvisits` = '" + this._habboStats.RoomVisits + "', `onlineTime` = '" + (PlusEnvironment.GetUnixTimestamp() - SessionStart + this._habboStats.OnlineTime) + "', `respect` = '" + this._habboStats.Respect + "', `respectGiven` = '" + this._habboStats.RespectGiven + "', `giftsGiven` = '" + this._habboStats.GiftsGiven + "', `giftsReceived` = '" + this._habboStats.GiftsReceived + "', `dailyRespectPoints` = '" + this._habboStats.DailyRespectPoints + "', `dailyPetRespectPoints` = '" + this._habboStats.DailyPetRespectPoints + "', `AchievementScore` = '" + this._habboStats.AchievementPoints + "', `quest_id` = '" + this._habboStats.QuestID + "', `quest_progress` = '" + this._habboStats.QuestProgress + "', `groupid` = '" + this._habboStats.FavouriteGroupId + "',`forum_posts` = '" + this._habboStats.ForumPosts + "' WHERE `id` = '" + this.Id + "' LIMIT 1;";
}
}
Code:
public string GetQueryString
{
get
{
this._habboSaved = true;
return "UPDATE `users` SET `online` = '0', `last_online` = '" + PlusEnvironment.GetUnixTimestamp() + "', `activity_points` = '" + this.Duckets + "', `credits` = '" + this.Credits + "', `in_jail` = '" + this.In_Jail + "', `jail_time` = '" + this.Jail_Time + "', `vip_points` = '" + this.Diamonds + "', `home_room` = '" + this.HomeRoom + "', `gotw_points` = '" + this.GOTWPoints + "', `time_muted` = '" + this.TimeMuted + "',`friend_bar_state` = '" + FriendBarStateUtility.GetInt(this._friendbarState) + "' WHERE id = '" + Id + "' LIMIT 1;UPDATE `user_stats` SET `roomvisits` = '" + this._habboStats.RoomVisits + "', `onlineTime` = '" + (PlusEnvironment.GetUnixTimestamp() - SessionStart + this._habboStats.OnlineTime) + "', `respect` = '" + this._habboStats.Respect + "', `respectGiven` = '" + this._habboStats.RespectGiven + "', `giftsGiven` = '" + this._habboStats.GiftsGiven + "', `giftsReceived` = '" + this._habboStats.GiftsReceived + "', `dailyRespectPoints` = '" + this._habboStats.DailyRespectPoints + "', `dailyPetRespectPoints` = '" + this._habboStats.DailyPetRespectPoints + "', `AchievementScore` = '" + this._habboStats.AchievementPoints + "', `quest_id` = '" + this._habboStats.QuestID + "', `quest_progress` = '" + this._habboStats.QuestProgress + "', `groupid` = '" + this._habboStats.FavouriteGroupId + "',`forum_posts` = '" + this._habboStats.ForumPosts + "' WHERE `id` = '" + this.Id + "' LIMIT 1;";
}
}
Find
Code:
public void InitInformation(UserData data)
{
BadgeComponent = new BadgeComponent(this , data);
Relationships = data.Relations;
}
Code:
internal void StartJailTimer(GameClient Session, int Time)
{
Timer JailTimer = new Timer((Time * 60) * 1000);
JailTimer.Start();
Session.GetHabbo().In_Jail = 1;
JailTimer.Elapsed += (o, e) =>
{
Session.GetHabbo().PrepareRoom(0, "");
Session.SendMessage(new RoomNotificationComposer("Notification",
" You've been released from jail! \n\n" +
" Next time behave yourself!!", "small", ""));
using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
{
Session.GetHabbo().In_Jail = 0;
dbClient.SetQuery("UPDATE `users` SET `jail_time` = @jail_time, `in_jail` = @in_jail, `home_room` = @home_room WHERE id = @id");
dbClient.AddParameter("jail_time", 0);
dbClient.AddParameter("in_jail", 0);
dbClient.AddParameter("home_room", 0);
dbClient.AddParameter("id", Session.GetHabbo().Id);
dbClient.RunQuery();
}
JailTimer.Dispose();
}
;
Okay we're done with this class , now go to Authenticator.cs
Change Convert.ToInt32(Row["rank_vip"])); to Convert.ToInt32(Row["rank_vip"]), and add the following code next to it
Code:
Convert.ToInt32(Row["in_jail"]), Convert.ToInt32(Row["jail_time"]));
Go to UserDataFactory.cs & Find
Code:
dbClient.SetQuery("SELECT `id`,`username`,`rank`,`motto`,`look`,`gender`,`last_online`,`credits`,`activity_points`,`home_room`,`block_newfriends`,`hide_online`,`hide_inroom`,`vip`,`account_created`,`vip_points`,`machine_id`,`volume`,`chat_preference`,`focus_preference`, `pets_muted`,`bots_muted`,`advertising_report_blocked`,`last_change`,`gotw_points`,`ignore_invites`,`time_muted`,`allow_gifts`,`friend_bar_state`,`disable_forced_effects`,`allow_mimic`,`rank_vip` FROM `users` WHERE `auth_ticket` = @sso LIMIT 1");
dbClient.AddParameter("sso", SessionTicket);
Code:
dbClient.SetQuery("SELECT `id`,`username`,`rank`,`jail_time`,`in_jail`,`motto`,`look`,`gender`,`last_online`,`credits`,`activity_points`,`home_room`,`block_newfriends`,`hide_online`,`hide_inroom`,`vip`,`account_created`,`vip_points`,`machine_id`,`volume`,`chat_preference`,`focus_preference`, `pets_muted`,`bots_muted`,`advertising_report_blocked`,`last_change`,`gotw_points`,`ignore_invites`,`time_muted`,`allow_gifts`,`friend_bar_state`,`disable_forced_effects`,`allow_mimic`,`rank_vip` FROM `users` WHERE `auth_ticket` = @sso LIMIT 1");
dbClient.AddParameter("sso", SessionTicket);
Find
Code:
using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
{
dbClient.SetQuery("SELECT `id`,`username`,`rank`,`motto`,`look`,`gender`,`last_online`,`credits`,`activity_points`,`home_room`,`block_newfriends`,`hide_online`,`hide_inroom`,`vip`,`account_created`,`vip_points`,`machine_id`,`volume`,`chat_preference`, `focus_preference`, `pets_muted`,`bots_muted`,`advertising_report_blocked`,`last_change`,`gotw_points`,`ignore_invites`,`time_muted`,`allow_gifts`,`friend_bar_state`,`disable_forced_effects`,`allow_mimic`,`rank_vip` FROM `users` WHERE `id` = @id LIMIT 1");
dbClient.AddParameter("id", UserId);
Code:
using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
{
dbClient.SetQuery("SELECT `id`,`username`,`rank`,`motto`,`jail_time`,`in_jail`,`look`,`gender`,`last_online`,`credits`,`activity_points`,`home_room`,`block_newfriends`,`hide_online`,`hide_inroom`,`vip`,`account_created`,`vip_points`,`machine_id`,`volume`,`chat_preference`, `focus_preference`, `pets_muted`,`bots_muted`,`advertising_report_blocked`,`last_change`,`gotw_points`,`ignore_invites`,`time_muted`,`allow_gifts`,`friend_bar_state`,`disable_forced_effects`,`allow_mimic`,`rank_vip` FROM `users` WHERE `id` = @id LIMIT 1");
dbClient.AddParameter("id", UserId);
Go to HabboHotel > Rooms > Chat > Commands > Administrator
Right click then click "Add new class" and call it JailUserCommand
Delete everything in the current class and replace it with
Code:
using Plus.Communication.Packets.Outgoing.Rooms.Notifications;
using Plus.Database.Interfaces;
using Plus.HabboHotel.GameClients;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Plus.HabboHotel.Rooms.Chat.Commands.Administrator
{
class JailUserCommand : IChatCommand
{
public string PermissionRequired => "command_jail";
public string Parameters => "%username% %time%";
public string Description => "Put a user in jail!.";
public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
{
int Time = 0;
int Time_Now;
Time_Now = Time;
if (Params.Length == 1)
{
Session.SendWhisper("Please enter the username of the user you wish to jail");
return;
}
GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);
if (TargetClient == null)
{
Session.SendWhisper($"An error occoured whilst trying to find {Params[1]}!");
return;
}
RoomUser TargetUser = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Id);
if (TargetUser == null)
{
Session.SendWhisper($"An error occoured whilst trying to find {Params[1]}, maybe they're not online or in this room.");
return;
}
if (TargetClient.GetHabbo().Rank > Session.GetHabbo().Rank)
{
Session.SendWhisper("Oops , it appears you can't jail this user!");
return;
}
if (Session.GetHabbo().In_Jail == 1)
{
Session.SendWhisper($"Oops , it appears {Params[1]} is already jailed!");
return;
}
if (Session == TargetClient)
{
Session.SendWhisper("You can't put yourself in jail!");
return;
}
if (Int32.TryParse(Params[2], out Time))
{
Session.SendWhisper($"You have successfully jailed {Params[1]} for {Time} minutes!");
TargetClient.GetHabbo().PrepareRoom(// put room id of jail here // , "");
TargetClient.GetHabbo().StartJailTimer(TargetClient, Time);
TargetClient.SendMessage(new RoomNotificationComposer("Notification",
" You've been jailed by " + $"{Params[1]}\n\n" +
" You've been jailed for " + $"{Time} " + "Minute(s)", "small", ""));
using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
{
dbClient.SetQuery("UPDATE `users` SET `jail_time` = @jail_time, `in_jail` = @in_jail, `home_room` = @home_room WHERE id = @id");
dbClient.AddParameter("jail_time", Params[2]);
dbClient.AddParameter("in_jail", 1);
dbClient.AddParameter("home_room", // your room id here //);
dbClient.AddParameter("id", TargetClient.GetHabbo().Id);
dbClient.RunQuery();
}
}
}
}
}
Navigate to the following classes , "ShoutEvent" "WhisperEvent" "ChatEvent"
In each class insert the following code somewhere
Code:
if (Session.GetHabbo().In_Jail == 1)
{
Session.SendWhisper("You can't talk whilst you're in jail!");
return;
}
Go to SendMsgEvent
And insert the following code
Code:
if (Session.GetHabbo().In_Jail == 1)
{
Session.SendMessage(new RoomNotificationComposer("Notification",
" Oops , it appears you're jailed! \n\n" +
" You can't message your friends whilst jailed!", "small", ""));
return;
}
Go to FollowFriendEvent
And insert the following code
Code:
if (Session.GetHabbo().In_Jail == 1)
{
Session.SendMessage(new RoomNotificationComposer("Notification",
" Oops, it appears you're jailed ! \n\n" +
" You can't visit your friend whilst you're in jail!", "small", ""));
return;
}
Go to GameClient.cs and find the following
Code:
if (!string.IsNullOrWhiteSpace(PlusEnvironment.GetDBConfig().DBData["welcome_message"]))
SendMessage(new MOTDNotificationComposer(PlusEnvironment.GetDBConfig().DBData["welcome_message"]));
Code:
if (Session.GetHabbo().Jail_Time != 0)
{
Session.GetHabbo().StartJailTimer(Session, Session.GetHabbo().Jail_Time);
}
if (Session.GetHabbo().Jail_Time == 0 && Session.GetHabbo().Jail_Time == 0)
{
using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
{
dbClient.SetQuery("UPDATE `users` SET `jail_time` = '0', `in_jail` = '0' WHERE id = @id");
dbClient.AddParameter("jail_time", 0);
dbClient.AddParameter("in_jail", 0);
dbClient.AddParameter("id", Session.GetHabbo().Id);
dbClient.RunQuery();
}
}
In GameClient find
Code:
public bool TryAuthenticate(string AuthTicket)
Code:
public bool TryAuthenticate(string AuthTicket,GameClient Session)
Now go to SSOTicketEvent
And replace the last line with the following code
Code:
Session.TryAuthenticate(Packet.PopString(), Session);
Nearly done just a few more classes!
Go to the following classes UpdateNavigatorSettingsEvent , GetNavigatorFlatsEvent , NewNavigatorSearchEvent , InitializeNewNavigatorEvent & CanCreateRoomEvent
And insert the following code somewhere in each class
Code:
if (Session.GetHabbo().In_Jail == 1)
return;
Go to CommandManager
Add the following code
Code:
this.Register("jail", new JailUserCommand());
Add the following in permission_commands
Code:
command_jail
Finally go to
You must be registered for see links
& download the image and save it as "small"Then go to Swf/c_images/Notifications
And drag it in there
Re-build your solution and you're done!
Screenshots:
Looks easier than it is , if struggling to set up message me , failing that i'll just toss a download link for current revisions with this system on it
Last edited: