private static void AnswerDoorbell(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null || !Instance.CheckUserRights(Session)) { return; } string Name = Message.PopString(); bool Accept = (Message.ReadBytes(1)[0] == 65); Session TargetSession = SessionManager.GetSessionByCharacterId(CharacterResolverCache.GetUidFromName(Name)); if (TargetSession == null || TargetSession.AbsoluteRoomId != Instance.RoomId || TargetSession.RoomAuthed) { return; } if (Accept) { TargetSession.RoomAuthed = true; TargetSession.SendData(RoomDoorbellAcceptedComposer.Compose()); return; } TargetSession.SendData(RoomDoorbellNoResponseComposer.Compose()); RoomManager.RemoveUserFromRoom(TargetSession, false); }
public static ServerMessage Compose(uint UserId, Dictionary <ModerationRoomVisit, ReadOnlyCollection <ModerationChatlogEntry> > Entries) { string CharacterNameString = CharacterResolverCache.GetNameFromUid(UserId); ServerMessage Message = new ServerMessage(OpcodesOut.MODERATION_CHATLOGS_USER); Message.AppendUInt32(UserId); Message.AppendStringWithBreak(CharacterNameString); Message.AppendInt32(Entries.Count); foreach (KeyValuePair <ModerationRoomVisit, ReadOnlyCollection <ModerationChatlogEntry> > EntryData in Entries) { RoomInfo Info = RoomInfoLoader.GetRoomInfo(EntryData.Key.RoomId); Message.AppendBoolean(Info != null && Info.Type == RoomType.Public); Message.AppendUInt32(Info != null ? Info.Id : 0); Message.AppendStringWithBreak(Info != null ? Info.Name : "(Unknown room)"); Message.AppendInt32(EntryData.Value.Count); foreach (ModerationChatlogEntry Entry in EntryData.Value) { DateTime Time = UnixTimestamp.GetDateTimeFromUnixTimestamp(Entry.Timestamp); Message.AppendInt32(Time.Hour); Message.AppendInt32(Time.Minute); Message.AppendUInt32(Entry.UserId); Message.AppendStringWithBreak(Entry.UserId == UserId ? CharacterNameString : CharacterResolverCache.GetNameFromUid(Entry.UserId)); Message.AppendStringWithBreak(Entry.Message); } } return(Message); }
private static void AddToStaffPicked(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null || !Session.HasRight("hotel_admin")) { return; } if (!Navigator.StaffPickedContainsRoom(Instance.RoomId)) { Navigator.AddRoomToStaffPicked(Instance.RoomId); Session.SendData(NotificationMessageComposer.Compose("This room has been added to the staff picked rooms successfully.")); // todo: unlock achievement for room owner using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Session TargetSession = SessionManager.GetSessionByCharacterId(CharacterResolverCache.GetUidFromName(Instance.Info.OwnerName)); AchievementManager.ProgressUserAchievement(MySqlClient, TargetSession, "ACH_Spr", 1); } } else { Navigator.RemoveRoomFromStaffPicked(Instance.RoomId); Session.SendData(NotificationMessageComposer.Compose("This room has been removed from the staff picked rooms successfully.")); } }
public static ServerMessage Compose(RoomEvent Event) { ServerMessage Message = new ServerMessage(OpcodesOut.ROOM_EVENT_INFO); if (Event == null) { Message.AppendStringWithBreak("-1"); } else { Message.AppendStringWithBreak(Event.OwnerId.ToString()); Message.AppendStringWithBreak(CharacterResolverCache.GetNameFromUid(Event.OwnerId)); Message.AppendStringWithBreak(Event.RoomId.ToString()); Message.AppendInt32(Event.CategoryId); Message.AppendStringWithBreak(Event.Name); Message.AppendStringWithBreak(Event.Description); Message.AppendStringWithBreak(UnixTimestamp.GetDateTimeFromUnixTimestamp(Event.TimestampStarted).ToShortTimeString()); List <string> Tags = Event.Tags; Message.AppendInt32(Tags.Count); foreach (string Tag in Tags) { Message.AppendStringWithBreak(Tag); } } return(Message); }
private static void IgnoreUser(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } uint UserId = CharacterResolverCache.GetUidFromName(Message.PopString()); if (UserId == 0) { return; } Session TargetSession = SessionManager.GetSessionByCharacterId(UserId); if (TargetSession != null) { if (TargetSession.HasRight("cannot_ignore")) { Session.SendData(NotificationMessageComposer.Compose("You can not ignore this user.")); return; } Session.IgnoreCache.MarkUserIgnored(TargetSession.CharacterId); Session.SendData(RoomIgnoreResultComposer.Compose(1)); } }
public static ServerMessage Compose(ModerationTicket Ticket) { string DisplayRoomName = string.Empty; if (Ticket.RoomId > 0) { RoomInfo Info = RoomInfoLoader.GetRoomInfo(Ticket.RoomId); DisplayRoomName = Info == null ? "(Unknown room " + Ticket.RoomId + ")" : Info.Name; } ServerMessage Message = new ServerMessage(OpcodesOut.MODERATION_TICKET); Message.AppendUInt32(Ticket.Id); Message.AppendUInt32(Ticket.TabId); Message.AppendUInt32(11); // ?? unknown Message.AppendUInt32(Ticket.CategoryId); Message.AppendUInt32(11); // ?? unknown Message.AppendUInt32(Ticket.Score); Message.AppendUInt32(Ticket.ReporteeUserId); Message.AppendStringWithBreak(CharacterResolverCache.GetNameFromUid(Ticket.ReporteeUserId)); Message.AppendUInt32(Ticket.ReportedUserId); Message.AppendStringWithBreak(CharacterResolverCache.GetNameFromUid(Ticket.ReportedUserId)); Message.AppendUInt32(Ticket.ModeratorUserId); Message.AppendStringWithBreak(CharacterResolverCache.GetNameFromUid(Ticket.ModeratorUserId)); Message.AppendStringWithBreak(Ticket.Message); Message.AppendUInt32(Ticket.RoomId); Message.AppendStringWithBreak(DisplayRoomName); return(Message); }
private static void smethod_21(Session session_0, ClientMessage clientMessage_0) { clientMessage_0.ReadInteger(); uint actorId = clientMessage_0.ReadUnsignedInteger(); clientMessage_0.ReadInteger(); clientMessage_0.ReadInteger(); uint num2 = clientMessage_0.ReadUnsignedInteger(); clientMessage_0.ReadInteger(); clientMessage_0.ReadInteger(); SpaceInstance instanceBySpaceId = SpaceManager.GetInstanceBySpaceId(session_0.CurrentSpaceId); if (instanceBySpaceId != null) { SpaceActor actor = instanceBySpaceId.GetActor(actorId); SpaceActor actor2 = instanceBySpaceId.GetActor(num2); uint ID1 = CharacterResolverCache.GetUidFromName(actor.Name); uint ID2 = CharacterResolverCache.GetUidFromName(actor2.Name); if ((actor != null) && (actor2 != null)) { CharacterInfo referenceObject = (CharacterInfo)actor.ReferenceObject; CharacterInfo info2 = (CharacterInfo)actor2.ReferenceObject; if (!actor.IsLocked && !actor2.IsLocked && ChatCommands.block_upper == false && !ChatCommands.UpperBlock.Contains(actor2.Name) && !ChatCommands.UpperBlockUser.Contains(ID1) && !ChatCommands.UpperBlockUser.Contains(ID2)) { actor.StopMoving(); using (SqlDatabaseClient client = SqlDatabaseManager.GetClient()) { if (referenceObject.Staff == 1) { referenceObject.UpdateGoldCreditsBalance(client, -250);//Punch cost 500 referenceObject.UpdateUppercuts(client, true); info2.UpdateUppercuts(client, false); session_0.SendData(CharacterCoinsComposer.RemoveGoldCompose(250), false);//Punch cost 500 instanceBySpaceId.BroadcastMessage(SpaceUpdateUserStatistics.Compose(actor, 4), 0, false); instanceBySpaceId.BroadcastMessage(SpaceUpdateUserStatistics.Compose(actor2, 4), 0, false); actor.Lock(13, false, false); actor2.Lock(10, true, false); instanceBySpaceId.BroadcastMessage(SpaceUserSendUppercut.Compose(actor, actor2), 0, false); } else { referenceObject.UpdateGoldCreditsBalance(client, -250);//Punch cost 200 referenceObject.UpdateUppercuts(client, true); info2.UpdateUppercuts(client, false); session_0.SendData(CharacterCoinsComposer.RemoveGoldCompose(250), false);//Punch cost 200 instanceBySpaceId.BroadcastMessage(SpaceUpdateUserStatistics.Compose(actor, 4), 0, false); instanceBySpaceId.BroadcastMessage(SpaceUpdateUserStatistics.Compose(actor2, 4), 0, false); actor.Lock(13, false, false); actor2.Lock(10, true, false); instanceBySpaceId.BroadcastMessage(SpaceUserSendUppercut.Compose(actor, actor2), 0, false); } } } } } }
public static void Takeaway(SqlDatabaseClient MySqlClient, int Amount, string name) { uint ID = CharacterResolverCache.GetUidFromName(name); CharacterInfo info = CharacterInfoLoader.GetCharacterInfo(MySqlClient, ID); int int_0 = info.int_0; int_0 -= Amount; MySqlClient.SetParameter("id", ID); MySqlClient.SetParameter("credits", int_0); MySqlClient.ExecuteNonQuery("UPDATE usuarios SET creditos_oro = @credits WHERE id = @id"); }
public static string checkcredits(string username) { uint ID = CharacterResolverCache.GetUidFromName(username); Session session_1; session_1 = SessionManager.GetSessionByCharacterId(ID); int gold = session_1.CharacterInfo.GoldCoins; string str = string.Format("The User {0} Has {1} Credits", username, gold); return(str); }
public static void givemod(SqlDatabaseClient MySqlClient, string username, uint mod) { uint ID = CharacterResolverCache.GetUidFromName(username); Session session_1992; session_1992 = SessionManager.GetSessionByCharacterId(ID); MySqlClient.SetParameter("id", ID); MySqlClient.SetParameter("modlevel", mod); MySqlClient.ExecuteNonQuery("UPDATE usuarios SET moderador = @modlevel WHERE id = @id"); }
private static void UserWhisper(Session Session, ClientMessage Message) { if (Session.CharacterInfo.IsMuted) { return; } RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } RoomActor Actor = Instance.GetActorByReferenceId(Session.CharacterId); if (Actor == null) { return; } string MessageText = UserInputFilter.FilterString(Message.PopString().Trim()); if (MessageText.Length == 0) { return; } if (MessageText.Length > 100) { MessageText = MessageText.Substring(0, 100); } string[] Bits = MessageText.Split(' '); if (Bits.Length < 2) { return; } string UserBit = Bits[0]; MessageText = MessageText.Substring(UserBit.Length + 1); uint UserId = CharacterResolverCache.GetUidFromName(UserBit); if (UserId > 0) { Actor.Whisper(MessageText, UserId); } }
public static ServerMessage Compose(List <uint> Requests) { ServerMessage Message = new ServerMessage(OpcodesOut.MESSENGER_REQUESTS_LIST); Message.AppendInt32(Requests.Count); Message.AppendInt32(Requests.Count); foreach (uint RequestId in Requests) { Message.AppendUInt32(RequestId); Message.AppendStringWithBreak(CharacterResolverCache.GetNameFromUid(RequestId)); Message.AppendStringWithBreak(RequestId.ToString()); } return(Message); }
private static void UnignoreUser(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } uint UserId = CharacterResolverCache.GetUidFromName(Message.PopString()); if (UserId > 0) { Session.IgnoreCache.MarkUserUnignored(UserId); Session.SendData(RoomIgnoreResultComposer.Compose(3)); } }
private static void GetIgnoredUsers(Session Session, ClientMessage Message) { ReadOnlyCollection <uint> IgnoredUsers = Session.IgnoreCache.List; List <string> Names = new List <string>(); foreach (uint IgnoredUser in IgnoredUsers) { string Name = CharacterResolverCache.GetNameFromUid(IgnoredUser); if (Name != "Unknown User" && !Names.Contains(Name)) { Names.Add(Name); } } Session.SendData(IgnoredUserListComposer.Compose(Names)); }
public void TryAuthenticate(string Username, string Password, string RemoteAddress, bool Register = false) { using (SqlDatabaseClient client = SqlDatabaseManager.GetClient()) { uint characterId = UserCredentialsAuthenticator.TryAuthenticate(client, Username, Password, RemoteAddress); if (characterId == 0) { this.SendData(AuthenticationKoComposer.Compose(false), false); } else { BoomBang.Game.Characters.CharacterInfo info = CharacterInfoLoader.GetCharacterInfo(client, characterId, this.uint_0, true); if (ModerationBanManager.IsUserIdBlacklisted(info.UInt32_0)) { this.SendData(ModerationBanComposer.Compose(ModerationBanManager.GetBanDetails(info.UInt32_0)), false); SessionManager.StopSession(this.uint_0); } else if ((info != null) && info.HasLinkedSession) { this.characterInfo_0 = info; this.characterInfo_0.TimestampLastOnline = UnixTimestamp.GetCurrent(); CharacterResolverCache.AddToCache(this.characterInfo_0.UInt32_0, this.characterInfo_0.Username, true); this.sessionLaptopFriendCache_0 = new SessionLaptopFriendCache(client, this.CharacterId); this.userIgnoreCache_0 = new UserIgnoreCache(client, this.CharacterId); this.bool_1 = true; if (Register) { this.SendData(RegisterComposer.Compose(this.characterInfo_0), false); } else { this.SendData(AuthenticationOkComposer.Compose(this.characterInfo_0), false); } LaptopHandler.MarkUpdateNeeded(this, 0, true); } else { SessionManager.StopSession(this.uint_0); } } } }
private static void OnFriendRequest(Session Session, ClientMessage Message) { string RequestName = UserInputFilter.FilterString(Message.PopString()); uint TargetId = CharacterResolverCache.GetUidFromName(RequestName); if (TargetId < 1 || TargetId == Session.CharacterId) { return; } CharacterInfo TargetUserInfo = null; using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { TargetUserInfo = CharacterInfoLoader.GetCharacterInfo(MySqlClient, TargetId); if (!TargetUserInfo.PrivacyAcceptFriends) { Session.SendData(MessengerErrorEvent.Compose(39, 3)); return; } if (FriendshipExists(MySqlClient, Session.CharacterId, TargetUserInfo.Id, false)) { return; } CreateFriendship(MySqlClient, Session.CharacterId, TargetUserInfo.Id, false); } Session NotifySession = SessionManager.GetSessionByCharacterId(TargetUserInfo.Id); if (NotifySession != null) { NotifySession.SendData(MessengerRequestNoficiationComposer.Compose(Session.CharacterId, Session.CharacterInfo.Username)); } QuestManager.ProgressUserQuest(Session, QuestType.SOCIAL_FRIEND); }
public static ServerMessage Compose(uint UserId, ReadOnlyCollection <ModerationRoomVisit> Visits) { ServerMessage Message = new ServerMessage(OpcodesOut.MODERATION_ROOM_VISITS); Message.AppendUInt32(UserId); Message.AppendStringWithBreak(CharacterResolverCache.GetNameFromUid(UserId)); Message.AppendInt32(Visits.Count); foreach (ModerationRoomVisit Visit in Visits) { RoomInfo Info = RoomInfoLoader.GetRoomInfo(Visit.RoomId); DateTime Time = UnixTimestamp.GetDateTimeFromUnixTimestamp(Visit.TimestampEntered); Message.AppendBoolean(Info != null && Info.Type == RoomType.Public); Message.AppendUInt32(Info != null ? Info.Id : 0); Message.AppendStringWithBreak(Info != null ? Info.Name : "Unknown Room"); Message.AppendInt32(Time.Hour); Message.AppendInt32(Time.Minute); } return(Message); }
public static ServerMessage Compose(RoomInfo Info, ReadOnlyCollection <ModerationChatlogEntry> Entries) { ServerMessage Message = new ServerMessage(OpcodesOut.MODERATION_CHATLOGS_ROOM); Message.AppendBoolean(Info.Type == RoomType.Public); Message.AppendUInt32(Info.Id); Message.AppendStringWithBreak(Info.Name); Message.AppendInt32(Entries.Count); foreach (ModerationChatlogEntry Entry in Entries) { DateTime Time = UnixTimestamp.GetDateTimeFromUnixTimestamp(Entry.Timestamp); Message.AppendInt32(Time.Hour); Message.AppendInt32(Time.Minute); Message.AppendUInt32(Entry.UserId); Message.AppendStringWithBreak(CharacterResolverCache.GetNameFromUid(Entry.UserId)); Message.AppendStringWithBreak(Entry.Message); } return(Message); }
public static ServerMessage Compose(RoomInstance Instance) { ServerMessage Message = new ServerMessage(OpcodesOut.ROOM_EDIT_INFO); Message.AppendUInt32(Instance.Info.Id); Message.AppendStringWithBreak(Instance.Info.Name); Message.AppendStringWithBreak(Instance.Info.Description); Message.AppendInt32((int)Instance.Info.AccessType); Message.AppendInt32(Instance.Info.CategoryId); Message.AppendInt32(Instance.Info.MaxUsers); Message.AppendInt32(Instance.Model.MaxUsers); Message.AppendInt32(Instance.Info.Tags.Count); foreach (string Tag in Instance.Info.Tags) { Message.AppendStringWithBreak(Tag); } Message.AppendInt32(Instance.UsersWithRights.Count); foreach (uint User in Instance.UsersWithRights) { Message.AppendUInt32(User); Message.AppendStringWithBreak(CharacterResolverCache.GetNameFromUid(User)); } // GQjl~rkfasfs!qwHHQFQFHHHIHIHHH Message.AppendInt32(Instance.UsersWithRights.Count); Message.AppendBoolean(Instance.Info.AllowPets); Message.AppendBoolean(Instance.Info.AllowPetEating); Message.AppendBoolean(Instance.Info.DisableRoomBlocking); Message.AppendBoolean(Instance.Info.HideWalls); Message.AppendInt32(Instance.Info.WallThickness); Message.AppendInt32(Instance.Info.FloorThickness); return(Message); }
public static bool HandleCommand(Session Session, string Input) { Input = Input.Substring(1, Input.Length - 1); string[] Bits = Input.Split(' '); RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); RoomActor Actor = (Instance == null ? null : Instance.GetActorByReferenceId(Session.CharacterId)); switch (Bits[0].ToLower()) { case "commands": { Session.SendData(NotificationMessageComposer.Compose((string)LangManager.GetValue("command.commands.info") + ":\n\n:commands\n:online\n:about\n:pickall")); return(true); } case "update_catalog": { if (!Session.HasRight("hotel_admin")) { return(false); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Snowlight.Game.Catalog.CatalogManager.RefreshCatalogData(MySqlClient); } Session.SendData(NotificationMessageComposer.Compose((string)LangManager.GetValue("command.updatecatalog.success"))); return(true); } case "online": { List <string> OnlineUsers = SessionManager.ConnectedUserData.Values.ToList(); StringBuilder MessageText = new StringBuilder((string)LangManager.GetValue("command.online.part1") + " " + OnlineUsers.Count + " " + (string)LangManager.GetValue("command.online.part2") + "\n"); foreach (string OnlineUser in OnlineUsers) { MessageText.Append('\n'); MessageText.Append("- " + OnlineUser); } Session.SendData(NotificationMessageComposer.Compose(MessageText.ToString())); return(true); } case "superkick": { if (!Session.HasRight("hotel_admin")) { return(false); } if (Bits.Length < 2) { Session.SendData(RoomChatComposer.Compose(Actor.Id, (string)LangManager.GetValue("command.invalidsyntax") + " - :kick <username>", 0, ChatType.Whisper)); return(true); } string Username = UserInputFilter.FilterString(Bits[1].Trim()); Session TargetSession = SessionManager.GetSessionByCharacterId(CharacterResolverCache.GetUidFromName(Username)); if (TargetSession == null || TargetSession.HasRight("moderation_tool") || !TargetSession.InRoom) { Session.SendData(RoomChatComposer.Compose(Actor.Id, (string)LangManager.GetValue("command.targetuser") + " '" + Username + "' is offline or cannot be kicked.", 0, ChatType.Whisper)); return(true); } SessionManager.StopSession(TargetSession.Id); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Superkicked user from server (chat command)", "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ")."); } return(true); } case "kick": { if (!Session.HasRight("moderation_tool")) { return(false); } if (Bits.Length < 2) { Session.SendData(RoomChatComposer.Compose(Actor.Id, (string)LangManager.GetValue("command.invalidsyntax") + " - :kick <username>", 0, ChatType.Whisper)); return(true); } string Username = UserInputFilter.FilterString(Bits[1].Trim()); Session TargetSession = SessionManager.GetSessionByCharacterId(CharacterResolverCache.GetUidFromName(Username)); if (TargetSession == null || TargetSession.HasRight("moderation_tool") || !TargetSession.InRoom) { Session.SendData(RoomChatComposer.Compose(Actor.Id, (string)LangManager.GetValue("command.targetuser") + " '" + Username + "' is offline, not in a room, or cannot be kicked.", 0, ChatType.Whisper)); return(true); } RoomManager.RemoveUserFromRoom(TargetSession, true); TargetSession.SendData(NotificationMessageComposer.Compose((string)LangManager.GetValue("command.kick.success"))); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Kicked user from room (chat command)", "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ")."); } return(true); } case "roomunmute": { if (!Session.HasRight("mute")) { return(false); } if (Instance.RoomMuted) { Instance.RoomMuted = false; Session.SendData(RoomChatComposer.Compose(Actor.Id, (string)LangManager.GetValue("command.roomunmute.success"), 0, ChatType.Whisper)); } else { Session.SendData(RoomChatComposer.Compose(Actor.Id, (string)LangManager.GetValue("command.roomunmute.error"), 0, ChatType.Whisper)); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Unmuted room", "Room '" + Instance.Info.Name + "' (ID " + Instance.RoomId + ")"); } return(true); } case "roommute": { if (!Session.HasRight("mute")) { return(false); } if (!Instance.RoomMuted) { Instance.RoomMuted = true; Session.SendData(RoomChatComposer.Compose(Actor.Id, (string)LangManager.GetValue("command.roommute.success"), 0, ChatType.Whisper)); } else { Session.SendData(RoomChatComposer.Compose(Actor.Id, (string)LangManager.GetValue("command.roommute.error"), 0, ChatType.Whisper)); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Muted room", "Room '" + Instance.Info.Name + "' (ID " + Instance.RoomId + ")"); } return(true); } case "unmute": { if (!Session.HasRight("mute")) { return(false); } if (Bits.Length < 2) { Session.SendData(RoomChatComposer.Compose(Actor.Id, (string)LangManager.GetValue("command.invalidsyntax") + " - :unmute <username>", 0, ChatType.Whisper)); return(true); } string Username = UserInputFilter.FilterString(Bits[1].Trim()); Session TargetSession = SessionManager.GetSessionByCharacterId(CharacterResolverCache.GetUidFromName(Username)); if (TargetSession == null) { Session.SendData(RoomChatComposer.Compose(Actor.Id, (string)LangManager.GetValue("command.targetuser") + " '" + Username + "' " + (string)LangManager.GetValue("command.cannotproceedcmd3"), 0, ChatType.Whisper)); return(true); } if (!TargetSession.CharacterInfo.IsMuted) { Session.SendData(RoomChatComposer.Compose(Actor.Id, (string)LangManager.GetValue("command.targetuser") + " '" + Username + "' " + (string)LangManager.GetValue("command.unmute.error"), 0, ChatType.Whisper)); return(true); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { TargetSession.CharacterInfo.Unmute(MySqlClient); } TargetSession.SendData(NotificationMessageComposer.Compose((string)LangManager.GetValue("command.unmute.sucess"))); Session.SendData(RoomChatComposer.Compose(Actor.Id, (string)LangManager.GetValue("command.targetuser") + " '" + Username + "' " + (string)LangManager.GetValue("command.unmute.sucess2"), 0, ChatType.Whisper)); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Unmuted user", "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ")."); } return(true); } case "mute": { if (!Session.HasRight("mute")) { return(false); } if (Bits.Length < 2) { Session.SendData(RoomChatComposer.Compose(Actor.Id, (string)LangManager.GetValue("command.invalidsyntax") + " - :mute <username> [length in seconds]", 0, ChatType.Whisper)); return(true); } string Username = UserInputFilter.FilterString(Bits[1].Trim()); int TimeToMute = 0; if (Bits.Length >= 3) { int.TryParse(Bits[2], out TimeToMute); } if (TimeToMute <= 0) { TimeToMute = 300; } if (TimeToMute > 3600) { Session.SendData(RoomChatComposer.Compose(Actor.Id, (string)LangManager.GetValue("command.mute.error"), 0, ChatType.Whisper)); return(true); } Session TargetSession = SessionManager.GetSessionByCharacterId(CharacterResolverCache.GetUidFromName(Username)); if (TargetSession == null || TargetSession.HasRight("mute")) { Session.SendData(RoomChatComposer.Compose(Actor.Id, (string)LangManager.GetValue("command.targetuser") + " '" + Username + "' " + (string)LangManager.GetValue("command.cannotproceedcmd4"), 0, ChatType.Whisper)); return(true); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { TargetSession.CharacterInfo.Mute(MySqlClient, TimeToMute); ModerationLogs.LogModerationAction(MySqlClient, Session, "Muted user", "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ") for " + TimeToMute + " seconds."); } TargetSession.SendData(RoomMutedComposer.Compose(TimeToMute)); Session.SendData(RoomChatComposer.Compose(Actor.Id, (string)LangManager.GetValue("command.mute.sucess.part1") + " '" + Username + "' " + (string)LangManager.GetValue("command.mute.sucess.part2") + " " + TimeToMute + " seconds.", 0, ChatType.Whisper)); return(true); } case "clipping": if (!Session.HasRight("hotel_admin")) { return(false); } Actor.OverrideClipping = !Actor.OverrideClipping; Actor.ApplyEffect(Actor.ClippingEnabled ? 0 : 23); Session.CurrentEffect = 0; return(true); case "about": Session.SendData(UserAlertModernComposer.Compose("Powered by Snowlight", "This hotel is proudly powered by Snowlight, the premium open-source Habbo Hotel emulator.\n\nhttp://www.meth0d.org/snowlight")); return(true); case "t": if (!Session.HasRight("hotel_admin")) { return(false); } Session.SendData(NotificationMessageComposer.Compose("Position: " + Actor.Position.ToString() + ", Rotation: " + Actor.BodyRotation)); return(true); case "emptyinv": if (!Session.HasRight("hotel_admin")) { return(false); } Session.InventoryCache.ClearAndDeleteAll(); Session.SendData(InventoryRefreshComposer.Compose()); Session.SendData(NotificationMessageComposer.Compose((string)LangManager.GetValue("command.emptyinv.sucess"))); return(true); case "pickall": if (!Instance.CheckUserRights(Session, true)) { Session.SendData(NotificationMessageComposer.Compose((string)LangManager.GetValue("command.pickall.error"))); return(true); } Instance.PickAllToUserInventory(Session); return(true); } return(false); }
public static bool HandleCommand(Session Session, string Input) { Input = Input.Substring(1, Input.Length - 1); string[] Bits = Input.Split(' '); RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); RoomActor Actor = (Instance == null ? null : Instance.GetActorByReferenceId(Session.CharacterId)); Session TargetSession = null; RoomActor TargetActor = null; String TargetName = ""; switch (Bits[0].ToLower()) { #region users #region misc case "commands": { Session.SendData(NotificationMessageComposer.Compose(Localization.GetValue("command.commands.info") + ":\n\n:commands\n:online\n:about\n:pickall")); return(true); } case "online": { List <string> OnlineUsers = SessionManager.ConnectedUserData.Values.ToList(); StringBuilder MessageText = new StringBuilder(Localization.GetValue("command.online", OnlineUsers.Count.ToString()) + "\n"); foreach (string OnlineUser in OnlineUsers) { MessageText.Append('\n'); MessageText.Append("- " + OnlineUser); } Session.SendData(NotificationMessageComposer.Compose(MessageText.ToString())); return(true); } case "about": Session.SendData(UserAlertModernComposer.Compose("Powered by Snowlight", "This hotel is proudly powered by Snowlight,\nedited by flx5. \nCredits to Meth0d.")); return(true); #endregion #region furni case "empty": case "emptyinv": if (Bits.Length > 2) { return(false); } if (!Session.HasRight("hotel_admin") && Bits.Length == 2) { return(false); } Session Targetuser = Session; if (Bits.Length == 2) { uint userid = CharacterResolverCache.GetUidFromName(Bits[1]); Targetuser = SessionManager.GetSessionByCharacterId(userid); } Targetuser.PetInventoryCache.ClearAndDeleteAll(); Targetuser.InventoryCache.ClearAndDeleteAll(); Targetuser.SendData(InventoryRefreshComposer.Compose()); Targetuser.SendData(NotificationMessageComposer.Compose(Localization.GetValue("command.emptyinv.sucess"))); return(true); case "pickall": if (!Instance.CheckUserRights(Session, true)) { Session.SendData(NotificationMessageComposer.Compose(Localization.GetValue("command.pickall.error"))); return(true); } Instance.PickAllToUserInventory(Session); return(true); #endregion #region extra case "moonwalk": if (!Session.CharacterInfo.IsPremium) { return(false); } Actor.WalkingBackwards = !Actor.WalkingBackwards; Actor.Dance(Actor.WalkingBackwards ? 4 : 0); Session.SendData(RoomChatComposer.Compose(Actor.Id, "TEST " + Actor.WalkingBackwards, 0, ChatType.Whisper)); return(true); #region push case "push": if (!Session.CharacterInfo.IsPremium || Bits.Length != 2) { return(false); } TargetName = UserInputFilter.FilterString(Bits[1].Trim()); TargetActor = Instance.GetActorByReferenceId(CharacterResolverCache.GetUidFromName(TargetName)); if (TargetActor == null || TargetActor.IsMoving) { return(false); } if ((TargetActor.Position.X == Actor.Position.X - 1) || (TargetActor.Position.X == Actor.Position.X + 1) || (TargetActor.Position.Y == Actor.Position.Y - 1) || (TargetActor.Position.Y == Actor.Position.Y + 1)) { Vector2 Newposition = null; if (TargetActor.Position.X == Actor.Position.X - 1 && TargetActor.Position.Y == Actor.Position.Y) { Newposition = new Vector2(TargetActor.Position.X - 1, TargetActor.Position.Y); } if (TargetActor.Position.X == Actor.Position.X + 1 && TargetActor.Position.Y == Actor.Position.Y) { Newposition = new Vector2(TargetActor.Position.X + 1, TargetActor.Position.Y); } if (TargetActor.Position.X == Actor.Position.X && TargetActor.Position.Y == Actor.Position.Y + 1) { Newposition = new Vector2(TargetActor.Position.X, TargetActor.Position.Y + 1); } if (TargetActor.Position.X == Actor.Position.X && TargetActor.Position.Y == Actor.Position.Y - 1) { Newposition = new Vector2(TargetActor.Position.X, TargetActor.Position.Y - 1); } if (TargetActor.Position.X == Actor.Position.X + 1 && TargetActor.Position.Y == Actor.Position.Y + 1) { Newposition = new Vector2(TargetActor.Position.X + 1, TargetActor.Position.Y + 1); } if (TargetActor.Position.X == Actor.Position.X - 1 && TargetActor.Position.Y == Actor.Position.Y - 1) { Newposition = new Vector2(TargetActor.Position.X - 1, TargetActor.Position.Y - 1); } if (TargetActor.Position.X == Actor.Position.X - 1 && TargetActor.Position.Y == Actor.Position.Y + 1) { Newposition = new Vector2(TargetActor.Position.X - 1, TargetActor.Position.Y + 1); } if (TargetActor.Position.X == Actor.Position.X + 1 && TargetActor.Position.Y == Actor.Position.Y - 1) { Newposition = new Vector2(TargetActor.Position.X + 1, TargetActor.Position.Y - 1); } if (Newposition == null || !Instance.IsValidPosition(Newposition) || (Instance.Model.DoorPosition.GetVector2().X == Newposition.X && Instance.Model.DoorPosition.GetVector2().Y == Newposition.Y)) { return(false); } TargetActor.MoveTo(Newposition); Actor.Chat("*" + Session.CharacterInfo.Username + " pushes " + Bits[1] + "*"); return(true); } else { Session.SendData(RoomChatComposer.Compose(Actor.Id, Bits[1] + " is not in your area.", 0, ChatType.Whisper)); return(false); } #endregion case "pull": if (!Session.CharacterInfo.IsPremium || Bits.Length != 2) { return(false); } TargetName = UserInputFilter.FilterString(Bits[1].Trim()); TargetActor = Instance.GetActorByReferenceId(CharacterResolverCache.GetUidFromName(TargetName)); if (TargetActor == null || TargetActor.IsMoving) { return(false); } if ((TargetActor.Position.X > Actor.Position.X - 10) && (TargetActor.Position.X < Actor.Position.X + 10) && (TargetActor.Position.Y > Actor.Position.Y - 10) && (TargetActor.Position.Y < Actor.Position.Y + 10) && (Instance.Model.DoorPosition.GetVector2().X == Actor.SquareInFront.X && Instance.Model.DoorPosition.GetVector2().Y == Actor.SquareInFront.Y)) { TargetActor.MoveTo(Actor.SquareInFront); Actor.Chat("*" + Session.CharacterInfo.Username + " pulls " + Bits[1] + "*"); return(true); } Session.SendData(RoomChatComposer.Compose(Actor.Id, Bits[1] + " is not in your area.", 0, ChatType.Whisper)); return(false); #endregion #endregion #region debugging #region items case "update_catalog": { if (!Session.HasRight("hotel_admin")) { return(false); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Snowlight.Game.Catalog.CatalogManager.RefreshCatalogData(MySqlClient); } Session.SendData(NotificationMessageComposer.Compose(Localization.GetValue("command.updatecatalog.success"))); return(true); } case "update_items": { if (!Session.HasRight("hotel_admin")) { return(false); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Snowlight.Game.Items.ItemDefinitionManager.Initialize(MySqlClient); } Session.SendData(NotificationMessageComposer.Compose("Items reloaded")); return(true); } #endregion #region rooms case "unload": if (!Session.HasRight("hotel_admin")) { return(false); } Instance.BroadcastMessage(NotificationMessageComposer.Compose("This room was unloaded!")); Instance.Unload(); return(true); case "t": if (!Session.HasRight("hotel_admin")) { return(false); } Session.SendData(NotificationMessageComposer.Compose("Position: " + Actor.Position.ToString() + ", Rotation: " + Actor.BodyRotation)); return(true); #endregion case "update_rights": if (!Session.HasRight("hotel_admin")) { return(false); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { RightsManager.RebuildCache(MySqlClient); } return(true); case "effect": if (!Session.HasRight("hotel_admin")) { return(false); } if (Bits.Length < 1) { Session.SendData(RoomChatComposer.Compose(Actor.Id, "Invalid syntax - :effect <id>", 0, ChatType.Whisper)); return(true); } int effectID; if (int.TryParse(Bits[1], out effectID)) { Actor.ApplyEffect(effectID); Session.CurrentEffect = 0; } else { Session.SendData(RoomChatComposer.Compose(Actor.Id, "Invalid syntax - :effect <id>", 0, ChatType.Whisper)); } return(true); case "clipping": if (!Session.HasRight("hotel_admin")) { return(false); } Actor.OverrideClipping = !Actor.OverrideClipping; Actor.ApplyEffect(Actor.ClippingEnabled ? 0 : 23); Session.CurrentEffect = 0; return(true); #endregion #region moderation #region kick case "superkick": // Kick User out of the Hotel { if (!Session.HasRight("hotel_admin")) { return(false); } if (Bits.Length < 2) { Session.SendData(RoomChatComposer.Compose(Actor.Id, Localization.GetValue("command.invalidsyntax") + " - :kick <username>", 0, ChatType.Whisper)); return(true); } TargetName = UserInputFilter.FilterString(Bits[1].Trim()); TargetSession = SessionManager.GetSessionByCharacterId(CharacterResolverCache.GetUidFromName(TargetName)); if (TargetSession == null || TargetSession.HasRight("moderation_tool") || !TargetSession.InRoom) { Session.SendData(RoomChatComposer.Compose(Actor.Id, Localization.GetValue("command.targetuser") + " '" + TargetName + "' is offline or cannot be kicked.", 0, ChatType.Whisper)); return(true); } SessionManager.StopSession(TargetSession.Id); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Superkicked user from server (chat command)", "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ")."); } return(true); } case "kick": //kick User out of Room { if (!Session.HasRight("moderation_tool")) { return(false); } if (Bits.Length < 2) { Session.SendData(RoomChatComposer.Compose(Actor.Id, Localization.GetValue("command.invalidsyntax") + " - :kick <username>", 0, ChatType.Whisper)); return(true); } TargetName = UserInputFilter.FilterString(Bits[1].Trim()); TargetSession = SessionManager.GetSessionByCharacterId(CharacterResolverCache.GetUidFromName(TargetName)); if (TargetSession == null || TargetSession.HasRight("moderation_tool") || !TargetSession.InRoom) { Session.SendData(RoomChatComposer.Compose(Actor.Id, Localization.GetValue("command.targetuser") + " '" + TargetName + "' is offline, not in a room, or cannot be kicked.", 0, ChatType.Whisper)); return(true); } RoomManager.RemoveUserFromRoom(TargetSession, true); TargetSession.SendData(NotificationMessageComposer.Compose(Localization.GetValue("command.kick.success"))); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Kicked user from room (chat command)", "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ")."); } return(true); } #endregion #region mute case "roomunmute": { if (!Session.HasRight("mute")) { return(false); } if (Instance.RoomMuted) { Instance.RoomMuted = false; Session.SendData(RoomChatComposer.Compose(Actor.Id, Localization.GetValue("command.roomunmute.success"), 0, ChatType.Whisper)); } else { Session.SendData(RoomChatComposer.Compose(Actor.Id, Localization.GetValue("command.roomunmute.error"), 0, ChatType.Whisper)); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Unmuted room", "Room '" + Instance.Info.Name + "' (ID " + Instance.RoomId + ")"); } return(true); } case "roommute": { if (!Session.HasRight("mute")) { return(false); } if (!Instance.RoomMuted) { Instance.RoomMuted = true; Session.SendData(RoomChatComposer.Compose(Actor.Id, Localization.GetValue("command.roommute.success"), 0, ChatType.Whisper)); } else { Session.SendData(RoomChatComposer.Compose(Actor.Id, Localization.GetValue("command.roommute.error"), 0, ChatType.Whisper)); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Muted room", "Room '" + Instance.Info.Name + "' (ID " + Instance.RoomId + ")"); } return(true); } case "unmute": { if (!Session.HasRight("mute")) { return(false); } if (Bits.Length < 2) { Session.SendData(RoomChatComposer.Compose(Actor.Id, Localization.GetValue("command.invalidsyntax") + " - :unmute <username>", 0, ChatType.Whisper)); return(true); } TargetName = UserInputFilter.FilterString(Bits[1].Trim()); TargetSession = SessionManager.GetSessionByCharacterId(CharacterResolverCache.GetUidFromName(TargetName)); if (TargetSession == null) { Session.SendData(RoomChatComposer.Compose(Actor.Id, Localization.GetValue("command.targetuser") + " '" + TargetName + "' " + Localization.GetValue("command.cannotproceedcmd3"), 0, ChatType.Whisper)); return(true); } if (!TargetSession.CharacterInfo.IsMuted) { Session.SendData(RoomChatComposer.Compose(Actor.Id, Localization.GetValue("command.targetuser") + " '" + TargetName + "' " + Localization.GetValue("command.unmute.error"), 0, ChatType.Whisper)); return(true); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { TargetSession.CharacterInfo.Unmute(MySqlClient); } TargetSession.SendData(NotificationMessageComposer.Compose(Localization.GetValue("command.unmute.sucess"))); Session.SendData(RoomChatComposer.Compose(Actor.Id, Localization.GetValue("command.targetuser") + " '" + TargetName + "' " + Localization.GetValue("command.unmute.sucess2"), 0, ChatType.Whisper)); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Unmuted user", "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ")."); } return(true); } case "mute": { if (!Session.HasRight("mute")) { return(false); } if (Bits.Length < 2) { Session.SendData(RoomChatComposer.Compose(Actor.Id, Localization.GetValue("command.invalidsyntax") + " - :mute <username> [length in seconds]", 0, ChatType.Whisper)); return(true); } TargetName = UserInputFilter.FilterString(Bits[1].Trim()); int TimeToMute = 0; if (Bits.Length >= 3) { int.TryParse(Bits[2], out TimeToMute); } if (TimeToMute <= 0) { TimeToMute = 300; } if (TimeToMute > 3600) { Session.SendData(RoomChatComposer.Compose(Actor.Id, Localization.GetValue("command.mute.error"), 0, ChatType.Whisper)); return(true); } TargetSession = SessionManager.GetSessionByCharacterId(CharacterResolverCache.GetUidFromName(TargetName)); if (TargetSession == null || TargetSession.HasRight("mute")) { Session.SendData(RoomChatComposer.Compose(Actor.Id, Localization.GetValue("command.targetuser") + " '" + TargetName + "' " + Localization.GetValue("command.cannotproceedcmd4"), 0, ChatType.Whisper)); return(true); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { TargetSession.CharacterInfo.Mute(MySqlClient, TimeToMute); ModerationLogs.LogModerationAction(MySqlClient, Session, "Muted user", "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ") for " + TimeToMute + " seconds."); } TargetSession.SendData(RoomMutedComposer.Compose(TimeToMute)); Session.SendData(RoomChatComposer.Compose(Actor.Id, Localization.GetValue("command.mute.sucess.part1") + " '" + TargetName + "' " + Localization.GetValue("command.mute.sucess.part2") + " " + TimeToMute + " seconds.", 0, ChatType.Whisper)); return(true); } #endregion #region credits case "coins": case "credits": using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { if (!Session.HasRight("hotel_admin")) { return(false); } if (Bits.Length < 2) { Session.SendData(RoomChatComposer.Compose(Actor.Id, "Invalid syntax - :" + Bits[0].ToLower() + " <user> <amount>", 0, ChatType.Whisper)); return(false); } int Valor; if (!Int32.TryParse(Bits[2], out Valor)) { Session.SendData(RoomChatComposer.Compose(Actor.Id, "Amount must be numeric!", 0, ChatType.Whisper)); return(false); } TargetName = UserInputFilter.FilterString(Bits[1].Trim()); uint UserID = CharacterResolverCache.GetUidFromName(TargetName); if (UserID == 0) { Session.SendData(RoomChatComposer.Compose(Actor.Id, "User not found!", 0, ChatType.Whisper)); return(false); } Session TargetUser = SessionManager.GetSessionByCharacterId(UserID); if (TargetUser == null) { Session.SendData(RoomChatComposer.Compose(Actor.Id, "User not online!", 0, ChatType.Whisper)); return(false); } TargetUser.CharacterInfo.UpdateCreditsBalance(MySqlClient, (int)Valor); TargetUser.SendData(RoomChatComposer.Compose(TargetUser.Id, "You received " + Valor + " coins!", 0, ChatType.Whisper)); Session.SendData(RoomChatComposer.Compose(Actor.Id, TargetName + " received " + Valor + " coins!", 0, ChatType.Whisper)); TargetUser.SendData(CreditsBalanceComposer.Compose(TargetUser.CharacterInfo.CreditsBalance)); return(true); } #endregion #region messages case "ha": { if (!Session.HasRight("hotel_admin")) { return(false); } string Alert = UserInputFilter.FilterString(MergeInputs(Bits, 1)); SessionManager.BroadcastPacket(UserAlertModernComposer.Compose("Important notice from Hotel Management", Alert)); return(true); } #endregion #endregion } return(false); }
public static bool HandleCommand(Session Session, string Input) { Input = Input.Substring(1, Input.Length - 1); string[] Bits = Input.Split(' '); RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); RoomActor Actor = (Instance == null ? null : Instance.GetActorByReferenceId(Session.CharacterId)); switch (Bits[0].ToLower()) { case "commands": { Session.SendData(NotificationMessageComposer.Compose("The following commands are available to regular users:\n\n:commands\n:online\n:about\n:pickall")); return(true); } case "online": { List <string> OnlineUsers = SessionManager.ConnectedUserData.Values.ToList(); StringBuilder MessageText = new StringBuilder("There are currently " + OnlineUsers.Count + " user(s) online:\n"); foreach (string OnlineUser in OnlineUsers) { MessageText.Append('\n'); MessageText.Append("- " + OnlineUser); } Session.SendData(NotificationMessageComposer.Compose(MessageText.ToString())); return(true); } case "superkick": { if (!Session.HasRight("hotel_admin")) { return(false); } if (Bits.Length < 2) { Session.SendData(RoomChatComposer.Compose(Actor.Id, "Invalid syntax - :kick <username>", 0, ChatType.Whisper)); return(true); } string Username = UserInputFilter.FilterString(Bits[1].Trim()); Session TargetSession = SessionManager.GetSessionByCharacterId(CharacterResolverCache.GetUidFromName(Username)); if (TargetSession == null || TargetSession.HasRight("moderation_tool") || !TargetSession.InRoom) { Session.SendData(RoomChatComposer.Compose(Actor.Id, "Target user '" + Username + "' is offline or cannot be kicked.", 0, ChatType.Whisper)); return(true); } SessionManager.StopSession(TargetSession.Id); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Superkicked user from server (chat command)", "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ")."); } return(true); } case "kick": { if (!Session.HasRight("moderation_tool")) { return(false); } if (Bits.Length < 2) { Session.SendData(RoomChatComposer.Compose(Actor.Id, "Invalid syntax - :kick <username>", 0, ChatType.Whisper)); return(true); } string Username = UserInputFilter.FilterString(Bits[1].Trim()); Session TargetSession = SessionManager.GetSessionByCharacterId(CharacterResolverCache.GetUidFromName(Username)); if (TargetSession == null || TargetSession.HasRight("moderation_tool") || !TargetSession.InRoom) { Session.SendData(RoomChatComposer.Compose(Actor.Id, "Target user '" + Username + "' is offline, not in a room, or cannot be kicked.", 0, ChatType.Whisper)); return(true); } RoomManager.RemoveUserFromRoom(TargetSession, true); TargetSession.SendData(NotificationMessageComposer.Compose("You have been kicked from the room by a community staff member.")); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Kicked user from room (chat command)", "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ")."); } return(true); } case "roomunmute": { if (!Session.HasRight("mute")) { return(false); } if (Instance.RoomMuted) { Instance.RoomMuted = false; Session.SendData(RoomChatComposer.Compose(Actor.Id, "The current room has been unmuted successfully.", 0, ChatType.Whisper)); } else { Session.SendData(RoomChatComposer.Compose(Actor.Id, "This room is not muted.", 0, ChatType.Whisper)); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Unmuted room", "Room '" + Instance.Info.Name + "' (ID " + Instance.RoomId + ")"); } return(true); } case "roommute": { if (!Session.HasRight("mute")) { return(false); } if (!Instance.RoomMuted) { Instance.RoomMuted = true; Session.SendData(RoomChatComposer.Compose(Actor.Id, "The current room has been muted successfully.", 0, ChatType.Whisper)); } else { Session.SendData(RoomChatComposer.Compose(Actor.Id, "This room is already muted.", 0, ChatType.Whisper)); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Muted room", "Room '" + Instance.Info.Name + "' (ID " + Instance.RoomId + ")"); } return(true); } case "unmute": { if (!Session.HasRight("mute")) { return(false); } if (Bits.Length < 2) { Session.SendData(RoomChatComposer.Compose(Actor.Id, "Invalid syntax - :unmute <username>", 0, ChatType.Whisper)); return(true); } string Username = UserInputFilter.FilterString(Bits[1].Trim()); Session TargetSession = SessionManager.GetSessionByCharacterId(CharacterResolverCache.GetUidFromName(Username)); if (TargetSession == null) { Session.SendData(RoomChatComposer.Compose(Actor.Id, "Target user '" + Username + "' does not exist or is not online.", 0, ChatType.Whisper)); return(true); } if (!TargetSession.CharacterInfo.IsMuted) { Session.SendData(RoomChatComposer.Compose(Actor.Id, "Target user '" + Username + "' is not muted.", 0, ChatType.Whisper)); return(true); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { TargetSession.CharacterInfo.Unmute(MySqlClient); } TargetSession.SendData(NotificationMessageComposer.Compose("You have been unmuted. Please reload the room.")); Session.SendData(RoomChatComposer.Compose(Actor.Id, "Target user '" + Username + "' was successfully unmuted.", 0, ChatType.Whisper)); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Unmuted user", "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ")."); } return(true); } case "mute": { if (!Session.HasRight("mute")) { return(false); } if (Bits.Length < 2) { Session.SendData(RoomChatComposer.Compose(Actor.Id, "Invalid syntax - :mute <username> [length in seconds]", 0, ChatType.Whisper)); return(true); } string Username = UserInputFilter.FilterString(Bits[1].Trim()); int TimeToMute = 0; if (Bits.Length >= 3) { int.TryParse(Bits[2], out TimeToMute); } if (TimeToMute <= 0) { TimeToMute = 300; } if (TimeToMute > 3600) { Session.SendData(RoomChatComposer.Compose(Actor.Id, "The maximum mute time is one hour.", 0, ChatType.Whisper)); return(true); } Session TargetSession = SessionManager.GetSessionByCharacterId(CharacterResolverCache.GetUidFromName(Username)); if (TargetSession == null || TargetSession.HasRight("mute")) { Session.SendData(RoomChatComposer.Compose(Actor.Id, "Target user '" + Username + "' does not exist, is not online, or cannot be muted.", 0, ChatType.Whisper)); return(true); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { TargetSession.CharacterInfo.Mute(MySqlClient, TimeToMute); ModerationLogs.LogModerationAction(MySqlClient, Session, "Muted user", "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ") for " + TimeToMute + " seconds."); } TargetSession.SendData(RoomMutedComposer.Compose(TimeToMute)); Session.SendData(RoomChatComposer.Compose(Actor.Id, "User '" + Username + "' has been muted successfully for " + TimeToMute + " seconds.", 0, ChatType.Whisper)); return(true); } case "clipping": if (!Session.HasRight("hotel_admin")) { return(false); } Actor.OverrideClipping = !Actor.OverrideClipping; Actor.ApplyEffect(Actor.ClippingEnabled ? 0 : 23); Session.CurrentEffect = 0; return(true); case "about": Session.SendData(UserAlertModernComposer.Compose("Powered by Snowlight", "This hotel is proudly powered by Snowlight, the premium open-source Habbo Hotel emulator.\n\nhttp://www.meth0d.org/snowlight")); return(true); case "t": if (!Session.HasRight("hotel_admin")) { return(false); } Session.SendData(NotificationMessageComposer.Compose("Position: " + Actor.Position.ToString() + ", Rotation: " + Actor.BodyRotation)); return(true); case "emptyinv": if (!Session.HasRight("hotel_admin")) { return(false); } Session.InventoryCache.ClearAndDeleteAll(); Session.SendData(InventoryRefreshComposer.Compose()); Session.SendData(NotificationMessageComposer.Compose("Your inventory has been emptied.")); return(true); case "pickall": if (!Instance.CheckUserRights(Session, true)) { Session.SendData(NotificationMessageComposer.Compose("You do not have rights to pickall in this room.")); return(true); } Instance.PickAllToUserInventory(Session); return(true); } return(false); }
public void TryAuthenticate(string Ticket, string RemoteAddress) { using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { uint AuthedUid = SingleSignOnAuthenticator.TryAuthenticate(MySqlClient, Ticket, RemoteAddress); if (AuthedUid <= 0) { SessionManager.StopSession(mId); return; } CharacterInfo Info = CharacterInfoLoader.GetCharacterInfo(MySqlClient, AuthedUid, mId, true); if (Info == null || !Info.HasLinkedSession) // not marked online = CharacterInfoLoader failed somehow { SessionManager.StopSession(mId); return; } mCharacterInfo = Info; mAchieventCache = new AchievementCache(MySqlClient, CharacterId); mBadgeCache = new BadgeCache(MySqlClient, CharacterId, mAchieventCache); if (!HasRight("login")) { SessionManager.StopSession(mId); return; } mCharacterInfo.TimestampLastOnline = UnixTimestamp.GetCurrent(); CharacterResolverCache.AddToCache(mCharacterInfo.Id, mCharacterInfo.Username, true); mMessengerFriendCache = new SessionMessengerFriendCache(MySqlClient, CharacterId); mFavoriteRoomsCache = new FavoriteRoomsCache(MySqlClient, CharacterId); mRatedRoomsCache = new RatedRoomsCache(); mInventoryCache = new InventoryCache(MySqlClient, CharacterId); mIgnoreCache = new UserIgnoreCache(MySqlClient, CharacterId); mNewItemsCache = new NewItemsCache(MySqlClient, CharacterId); mAvatarEffectCache = new AvatarEffectCache(MySqlClient, CharacterId); mQuestCache = new QuestCache(MySqlClient, CharacterId); mPetCache = new PetInventoryCache(MySqlClient, CharacterId); // Subscription manager MySqlClient.SetParameter("userid", CharacterId); DataRow Row = MySqlClient.ExecuteQueryRow("SELECT * FROM user_subscriptions WHERE user_id = @userid"); mSubscriptionManager = (Row != null ? new ClubSubscription(CharacterId, (ClubSubscriptionLevel)int.Parse((Row["subscription_level"].ToString())), (double)Row["timestamp_created"], (double)Row["timestamp_expire"], (double)Row["past_time_hc"], (double)Row["past_time_vip"]) : new ClubSubscription(CharacterId, ClubSubscriptionLevel.None, 0, 0, 0, 0)); if (mSubscriptionManager.SubscriptionLevel < ClubSubscriptionLevel.VipClub) { mBadgeCache.DisableSubscriptionBadge("ACH_VipClub"); } if (mSubscriptionManager.SubscriptionLevel < ClubSubscriptionLevel.BasicClub) { mBadgeCache.DisableSubscriptionBadge("ACH_BasicClub"); } mAvatarEffectCache.CheckEffectExpiry(this); mAuthProcessed = true; SendData(AuthenticationOkComposer.Compose()); SendData(FuseRightsListComposer.Compose(this)); SendData(UserHomeRoomComposer.Compose(mCharacterInfo.HomeRoom)); SendData(UserEffectListComposer.Compose(AvatarEffectCache.Effects)); SendData(NavigatorFavoriteRoomsComposer.Compose(FavoriteRoomsCache.FavoriteRooms)); SendData(InventoryNewItemsComposer.Compose(NewItemsCache.NewItems)); SendData(AchievementDataListComposer.Compose(AchievementManager.Achievements.Values.ToList())); SendData(AvailabilityStatusMessageComposer.Compose()); SendData(InfoFeedEnableMessageComposer.Compose(1)); SendData(ActivityPointsMessageComposer.Compose()); if (HasRight("moderation_tool")) { SendData(ModerationToolComposer.Compose(this, ModerationPresets.UserMessagePresets, ModerationPresets.UserActionPresets, ModerationPresets.RoomMessagePresets)); foreach (ModerationTicket ModTicket in ModerationTicketManager.ActiveTickets) { SendData(ModerationTicketComposer.Compose(ModTicket)); } } MessengerHandler.MarkUpdateNeeded(this, 0, true); } }
public static bool HandleCommand(Session Session, string Input) { Input = Input.Substring(1, Input.Length - 1); string[] input = Input.Split(new char[] { ' ' }); SpaceInstance instanceBySpaceId = SpaceManager.GetInstanceBySpaceId(Session.CurrentSpaceId); SpaceActor actor = (instanceBySpaceId == null) ? null : instanceBySpaceId.GetActorByReferenceId(Session.CharacterId, SpaceActorType.UserCharacter); CharacterInfo referenceObject = (CharacterInfo)actor.ReferenceObject; switch (input[0]) { case "position": { Session.SendData(SpaceChatComposer.Compose(0, string.Concat(new object[] { "Tu posici\x00f3n actual es - X: ", actor.Position.Int32_0, ", Y: ", actor.Position.Int32_1, ", Z: ", actor.Position.Int32_2 }), 3, ChatType.Say), false); return(true); } case "block": if (referenceObject.Staff != 0) { instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, actor.Name + " ha bloqueado el punch.", 3, ChatType.Say), 0, false); block = true; return(true); } return(false); case "unblock": if (referenceObject.Staff != 0) { instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, actor.Name + " ha desbloqueado el punch.", 3, ChatType.Say), 0, false); block = false; return(true); } return(false); case "ban": if (referenceObject.Staff == 2) { SqlDatabaseClient mySqlClient = SqlDatabaseManager.GetClient(); string Input2 = Input; string reason2 = Input2.Substring(Input2.IndexOf(',') + 1); Input = Input.Replace(",", ""); string[] split = Input.Split(' '); string username = (split[1]); string reason = string.Join(" ", Input, 2, Input.Length - 2); uint UserID = CharacterResolverCache.GetUidFromName(username); Moderation.ModerationBanManager.BanHammer(mySqlClient, UserID, reason2, actor.Name); string ban = string.Format("{0} ha baneado a {1} por {2}", actor.Name, username, reason2); Input = Input.Replace(" ", ""); uint ID = CharacterResolverCache.GetUidFromName(username); if (SessionManager.ContainsCharacterId(ID)) { Session Session_ID = SessionManager.GetSessionByCharacterId(ID); uint session_id2 = Session_ID.CharacterInfo.SessionId; SessionManager.StopSession(session_id2); } else { } instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, ban, 3, ChatType.Say), 0, false); return(true); } return(false); case "alert": if (referenceObject.Staff != 0) { string messageText = InputFilter.FilterString(InputFilter.MergeString(input, 1), false); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(0, messageText, 3, ChatType.Say), 0, false); return(true); } return(false); case "la": if (referenceObject.Staff != 0) { foreach (KeyValuePair <uint, Session> pair in SessionManager.Sessions) { pair.Value.SendData(LaptopMessageComposer.Compose(pair.Value.CharacterId, Input.Replace("la", ""), 2)); } return(true); } return(false); case "give": if (referenceObject.Staff == 2) { Session session_0; string userthatadded = actor.Name; SqlDatabaseClient mySqlClient = SqlDatabaseManager.GetClient(); int credits = 0; string Input2 = Input; string reason2 = Input2.Substring(Input2.IndexOf(',') + 1); credits = int.Parse(reason2); Input = Input.Replace(",", ""); string[] split = Input.Split(' '); string username = (split[1]); string reason = string.Join(" ", Input, 2, Input.Length - 2); uint ID = CharacterResolverCache.GetUidFromName(username); session_0 = SessionManager.GetSessionByCharacterId(ID); //givecredits2(mySqlClient, credits, username); referenceObject.UpdateGoldCreditsBalance(mySqlClient, +credits); session_0.SendData(CharacterCoinsComposer.AddGoldCompose(Convert.ToUInt32(credits)), false); //Punch cost 200 string str = string.Format("{0} le ha dado a {1} {2} Creditos!", userthatadded, username, credits); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(0, str, 3, ChatType.Say), 0, false); return(true); } return(false); case "take": if (referenceObject.Staff == 2) { Session session_0; string userthatadded = actor.Name; SqlDatabaseClient mySqlClient = SqlDatabaseManager.GetClient(); int credits = 0; string Input2 = Input; string reason2 = Input2.Substring(Input2.IndexOf(',') + 1); credits = int.Parse(reason2); Input = Input.Replace(",", ""); string[] split = Input.Split(' '); string username = (split[1]); string reason = string.Join(" ", Input, 2, Input.Length - 2); uint ID = CharacterResolverCache.GetUidFromName(username); session_0 = SessionManager.GetSessionByCharacterId(ID); referenceObject.UpdateGoldCreditsBalance(mySqlClient, -credits); session_0.SendData(CharacterCoinsComposer.RemoveGoldCompose(Convert.ToUInt32(credits)), false); //Punch cost 200 string str = string.Format("{0} le ha quitado {1} Creditos a {2}!", userthatadded, credits, username); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(0, str, 3, ChatType.Say), 0, false); return(true); } return(false); case "kick": if (referenceObject.Staff != 0) { Session session_0; Input = Input.Replace("kick", ""); Input = Input.Replace(" ", ""); uint ID = CharacterResolverCache.GetUidFromName(Input); if (SessionManager.ContainsCharacterId(ID)) { session_0 = SessionManager.GetSessionByCharacterId(ID); SpaceManager.RemoveUserFromSpace(session_0); string str = string.Format("{0} echa a {1} de la isla", actor.Name, Input); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(0, str, 3, ChatType.Say), 0, false); } return(true); } return(false); case "kickoffline": if (referenceObject.Staff == 2) { Session session_0; Input = Input.Replace("kickoffline", ""); Input = Input.Replace(" ", ""); uint ID = CharacterResolverCache.GetUidFromName(Input); if (SessionManager.ContainsCharacterId(ID)) { session_0 = SessionManager.GetSessionByCharacterId(ID); uint session_id2 = session_0.CharacterInfo.SessionId; SessionManager.StopSession(session_id2); string str = string.Format("{0} desconectó a {1}", actor.Name, Input); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(0, str, 3, ChatType.Say), 0, false); } //SpaceManager.GetInstanceBySpaceId //SpaceUserRemovedComposer.BroadcastCompose( return(true); } return(false); case "chest1": if (referenceObject.Staff == 2) { return(true); } return(false); } return(false); }
private static void PerformSearch(Session Session, ClientMessage Message) { ServerMessage Response = TryGetResponseFromCache(0, Message); if (Response != null) { Session.SendData(Response); return; } Dictionary <uint, RoomInfo> Rooms = new Dictionary <uint, RoomInfo>(); string Query = UserInputFilter.FilterString(Message.PopString()).ToLower().Trim(); int SearchEventCatId = 0; if (mEventSearchQueries.ContainsKey(Query.ToLower())) { SearchEventCatId = mEventSearchQueries[Query.ToLower()]; } // Limit query length. just a precaution. if (Query.Length > 64) { Query = Query.Substring(0, 64); } if (Query.Length > 0) { IEnumerable <RoomInstance> InstanceMatches = (from RoomInstance in RoomManager.RoomInstances where RoomInstance.Value.HumanActorCount > 0 && RoomInstance.Value.Info.Type == RoomType.Flat && (RoomInstance.Value.Info.OwnerName.StartsWith(Query) || RoomInstance.Value.SearchableTags.Contains(Query) || RoomInstance.Value.Info.Name.Contains(Query) || (RoomInstance.Value.HasOngoingEvent && (RoomInstance.Value.Event.Name.StartsWith(Query) || (SearchEventCatId > 0 && RoomInstance.Value.Event.CategoryId == SearchEventCatId)))) orderby RoomInstance.Value.HumanActorCount descending select RoomInstance.Value).Take(50); foreach (RoomInstance Instance in InstanceMatches) { Rooms.Add(Instance.RoomId, Instance.Info); } if (Rooms.Count < 50) // need db results? { using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { MySqlClient.SetParameter("query", Query + "%"); MySqlClient.SetParameter("fquery", "%" + Query + "%"); uint ToUid = CharacterResolverCache.GetUidFromName(Query); if (ToUid > 0) { MySqlClient.SetParameter("owneruid", ToUid); } DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM rooms WHERE name LIKE @query AND type = 'flat' OR tags LIKE @fquery AND type = 'flat'" + (ToUid > 0 ? " OR owner_id = @owneruid AND type = 'flat'" : string.Empty) + " LIMIT 50"); foreach (DataRow Row in Table.Rows) { uint RoomId = (uint)Row["id"]; if (!Rooms.ContainsKey(RoomId)) { Rooms.Add(RoomId, RoomInfoLoader.GenerateRoomInfoFromRow(Row)); } } } } } Response = NavigatorRoomListComposer.Compose(1, 9, Query, Rooms.Values.Take(50).ToList()); AddToCacheIfNeeded(0, Message, Response); Session.SendData(Response); }
private static void GiveRights(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null || !Instance.CheckUserRights(Session, true)) { return; } uint UserId = Message.PopWiredUInt32(); if (Instance.GiveUserRights(UserId)) { Session.SendData(RoomRightsGivenConfirmationComposer.Compose(Instance.RoomId, UserId, CharacterResolverCache.GetNameFromUid(UserId))); } }
public static bool HandleCommand(Session Session, string Input) { Input = Input.Substring(1, Input.Length - 1); string[] input = Input.Split(new char[] { ' ' }); SpaceInstance instanceBySpaceId = SpaceManager.GetInstanceBySpaceId(Session.CurrentSpaceId); SpaceActor actor = (instanceBySpaceId == null) ? null : instanceBySpaceId.GetActorByReferenceId(Session.CharacterId, SpaceActorType.UserCharacter); CharacterInfo referenceObject = (CharacterInfo)actor.ReferenceObject; switch (input[0]) { case "position": if (referenceObject.Staff == 1 || referenceObject.Staff == 2 || referenceObject.Staff == 6) { Session.SendData(SpaceChatComposer.Compose(0, string.Concat(new object[] { "Tu posici\x00f3n actual es - X: ", actor.Position.Int32_0, ", Y: ", actor.Position.Int32_1, ", Z: ", actor.Position.Int32_2 }), 3, ChatType.Say), false); return(true); } return(false); case "bm": if (referenceObject.Staff == 2 || referenceObject.Staff == 6) { if (!UpperBlock.Contains(actor.Name)) { string str = string.Format("{0}: Has activated Block User Upper.", actor.Name); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, str, 3, ChatType.Say), 0, false); UpperBlock.Add(actor.Name); } return(true); } return(false); case "uub": if (referenceObject.Staff == 2 || referenceObject.Staff == 6) { Input = Input.Replace("uub", ""); Input = Input.Replace(" ", ""); uint IDtoblock = CharacterResolverCache.GetUidFromName(Input); if (!UpperBlockUser.Contains(IDtoblock)) { string str = string.Format("{0}: Has activated Block User Upper For {1}", actor.Name, Input); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, str, 3, ChatType.Say), 0, false); UpperBlockUser.Add(IDtoblock); } return(true); } return(false); case "ub": if (referenceObject.Staff == 2 || referenceObject.Staff == 6) { Input = Input.Replace("ub", ""); Input = Input.Replace(" ", ""); uint IDtoblock = CharacterResolverCache.GetUidFromName(Input); if (UpperBlockUser.Contains(IDtoblock)) { string str = string.Format("{0}: Has deactivated Block User Upper For {1}", actor.Name, Input); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, str, 3, ChatType.Say), 0, false); UpperBlockUser.Remove(IDtoblock); } return(true); } return(false); case "ubm": if (referenceObject.Staff == 2 || referenceObject.Staff == 6) { if (UpperBlock.Contains(actor.Name)) { string str = string.Format("{0}: Has deactivated Block User Upper.", actor.Name); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, str, 3, ChatType.Say), 0, false); UpperBlock.Remove(actor.Name); } return(true); } return(false); case "block_upper": if (referenceObject.Staff == 1 || referenceObject.Staff == 2 || referenceObject.Staff == 6) { instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, actor.Name + " ha bloqueado el punch.", 3, ChatType.Say), 0, false); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, actor.Name + ": Has turned Block Punch On.", 3, ChatType.Say), 0, false); block_upper = true; return(true); } return(false); case "unblock_upper": if (referenceObject.Staff == 1 || referenceObject.Staff == 2 || referenceObject.Staff == 6) { instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, actor.Name + " ha desbloqueado el punch.", 3, ChatType.Say), 0, false); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, actor.Name + ": Has turned Block Punch Off.", 3, ChatType.Say), 0, false); block_upper = false; return(true); } return(false); case "checkcredits": if (referenceObject.Staff == 1 || referenceObject.Staff == 2 || referenceObject.Staff == 6) { Input = Input.Replace("checkcredits", ""); Input = Input.Replace(" ", ""); uint ID = CharacterResolverCache.GetUidFromName(actor.Name); actor.Whisper(checkcredits(Input), ID, false); return(true); } return(false); case "block_coco": if (referenceObject.Staff == 1 || referenceObject.Staff == 2 || referenceObject.Staff == 6) { instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, actor.Name + ": Ha bloqueado el coco.", 3, ChatType.Say), 0, false); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, actor.Name + ": Has turned Block Coco On.", 3, ChatType.Say), 0, false); block_coco = true; return(true); } return(false); case "unblock_coco": if (referenceObject.Staff == 1 || referenceObject.Staff == 2 || referenceObject.Staff == 6) { instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, actor.Name + ": ha desbloqueado el coco.", 3, ChatType.Say), 0, false); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, actor.Name + ": Has turned Block Coco Off.", 3, ChatType.Say), 0, false); block_coco = false; return(true); } return(false); case "ban": if (referenceObject.Staff == 1 || referenceObject.Staff == 2 && actor.Name != "DaLoe" || referenceObject.Staff == 6) { SqlDatabaseClient mySqlClient = SqlDatabaseManager.GetClient(); string Input2 = Input; string reason2 = Input2.Substring(Input2.IndexOf(',') + 1); Input = Input.Replace(",", ""); string[] split = Input.Split(' '); string username = (split[1]); string reason = string.Join(" ", Input, 2, Input.Length - 2); uint UserID = CharacterResolverCache.GetUidFromName(username); Moderation.ModerationBanManager.BanHammer(mySqlClient, UserID, reason2, actor.Name); string ban = string.Format("{0}: Banned: {1}, For: {2}", actor.Name, username, reason2); Input = Input.Replace(" ", ""); uint ID = CharacterResolverCache.GetUidFromName(username); if (SessionManager.ContainsCharacterId(ID)) { Session Session_ID = SessionManager.GetSessionByCharacterId(ID); uint session_id2 = Session_ID.CharacterInfo.SessionId; SessionManager.StopSession(session_id2); } else { } instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, ban, 3, ChatType.Say), 0, false); return(true); } return(false); case "unban": if (referenceObject.Staff == 1 || referenceObject.Staff == 2 && actor.Name != "DaLoe" && actor.Name != "Fran" || referenceObject.Staff == 6) { SqlDatabaseClient mySqlClient = SqlDatabaseManager.GetClient(); Input = Input.Replace("unban", ""); Input = Input.Replace(" ", ""); uint ID = CharacterResolverCache.GetUidFromName(Input); Moderation.ModerationBanManager.Unban(mySqlClient, ID); string unban = string.Format("{0}: Unbanned User {1}", actor.Name, Input); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, unban, 3, ChatType.Say), 0, false); return(true); } return(false); case "ipban": if (referenceObject.Staff == 2 && actor.Name != "DaLoE" && actor.Name != "Fran" || referenceObject.Staff == 6) { SqlDatabaseClient mySqlClient = SqlDatabaseManager.GetClient(); string Input2 = Input; string reason2 = Input2.Substring(Input2.IndexOf(',') + 1); Input = Input.Replace(",", ""); string[] split = Input.Split(' '); string username = (split[1]); string reason = string.Join(" ", Input, 2, Input.Length - 2); uint UserID = CharacterResolverCache.GetUidFromName(username); Sessions.Session session_0; session_0 = SessionManager.GetSessionByCharacterId(UserID); string str = session_0.RemoteAddress.ToString(); Moderation.ModerationBanManager.BanHammer3(mySqlClient, UserID, reason2, actor.Name, str); string ban = string.Format("{0}: IP Banned: {1}, For: {2}", actor.Name, username, reason2); Input = Input.Replace(" ", ""); uint ID = CharacterResolverCache.GetUidFromName(username); if (SessionManager.ContainsCharacterId(ID)) { Session Session_ID = SessionManager.GetSessionByCharacterId(ID); uint session_id2 = Session_ID.CharacterInfo.SessionId; SessionManager.StopSession(session_id2); } else { } instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(1, ban, 3, ChatType.Say), 0, false); return(true); } return(false); case "alert": if (referenceObject.Staff == 1 || referenceObject.Staff == 2 || referenceObject.Staff == 6) { string messageText = InputFilter.FilterString(InputFilter.MergeString(input, 1), false); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(0, messageText, 3, ChatType.Say), 0, false); return(true); } return(false); case "la": if (referenceObject.Staff == 1 || referenceObject.Staff == 2 || referenceObject.Staff == 6) { if (actor.Name == "Brandon" || actor.Name == "Mike") { foreach (KeyValuePair <uint, Session> pair in SessionManager.Sessions) { Input = Input.Replace("la", ""); string send = string.Format("{0} - From Burbian Creator {1}", Input, actor.Name); pair.Value.SendData(LaptopMessageComposer.Compose(pair.Value.CharacterId, send, 2)); } } else if (actor.Name == "Kyle") { foreach (KeyValuePair <uint, Session> pair in SessionManager.Sessions) { Input = Input.Replace("la", ""); string send = string.Format("{0} - From Burbian Main Programmer {1}", Input, actor.Name); pair.Value.SendData(LaptopMessageComposer.Compose(pair.Value.CharacterId, send, 2)); } } else if (referenceObject.Staff == 1) { foreach (KeyValuePair <uint, Session> pair in SessionManager.Sessions) { Input = Input.Replace("la", ""); string send = string.Format("{0} - From Burbian Moderator {1}", Input, actor.Name); pair.Value.SendData(LaptopMessageComposer.Compose(pair.Value.CharacterId, send, 2)); } } else if (referenceObject.Staff == 2 && actor.Name != "Brandon" && actor.Name != "Mike") { foreach (KeyValuePair <uint, Session> pair in SessionManager.Sessions) { Input = Input.Replace("la", ""); string send = string.Format("{0} - From Burbian Administrator {1}", Input, actor.Name); pair.Value.SendData(LaptopMessageComposer.Compose(pair.Value.CharacterId, send, 2)); } } else if (referenceObject.Staff == 6 && actor.Name != "Kyle") { foreach (KeyValuePair <uint, Session> pair in SessionManager.Sessions) { Input = Input.Replace("la", ""); string send = string.Format("{0} - From Burbian Programmer {1}", Input, actor.Name); pair.Value.SendData(LaptopMessageComposer.Compose(pair.Value.CharacterId, send, 2)); } } else { foreach (KeyValuePair <uint, Session> pair in SessionManager.Sessions) { Input = Input.Replace("la", ""); string send = string.Format("{0} - From Burbian Moderator {1}", Input, actor.Name); pair.Value.SendData(LaptopMessageComposer.Compose(pair.Value.CharacterId, send, 2)); } } return(true); } return(false); case "effect": if (referenceObject.Vip == 1 || referenceObject.Staff == 2 || referenceObject.Staff == 6) { Input = Input.Replace("effect", ""); Input = Input.Replace(" ", ""); switch (int.Parse(Input)) { case 1: actor.ApplyEffect(1, true); actor.UpdateNeeded = true; break; case 2: actor.ApplyEffect(2, true); actor.UpdateNeeded = true; break; case 3: actor.ApplyEffect(3, true); actor.UpdateNeeded = true; break; case 4: actor.ApplyEffect(4, true); actor.UpdateNeeded = true; break; } return(true); } return(false); case "give": if (referenceObject.Staff == 2 || referenceObject.Staff == 6) { Session session_0; string userthatadded = actor.Name; SqlDatabaseClient mySqlClient = SqlDatabaseManager.GetClient(); int credits = 0; string Input2 = Input; string reason2 = Input2.Substring(Input2.IndexOf(',') + 1); credits = int.Parse(reason2); Input = Input.Replace(",", ""); string[] split = Input.Split(' '); string username = (split[1]); string reason = string.Join(" ", Input, 2, Input.Length - 2); uint ID = CharacterResolverCache.GetUidFromName(username); session_0 = SessionManager.GetSessionByCharacterId(ID); //givecredits2(mySqlClient, credits, username); referenceObject.UpdateGoldCreditsBalance(mySqlClient, +credits); session_0.SendData(CharacterCoinsComposer.AddGoldCompose(Convert.ToUInt32(credits)), false); //Punch cost 200 string str = string.Format("{0}: Gave {1}, {2} Credits!", userthatadded, username, credits); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(0, str, 3, ChatType.Say), 0, false); return(true); } return(false); case "share": if (referenceObject.Staff == 0 || referenceObject.Staff == 1 || referenceObject.Staff == 2 || referenceObject.Staff == 3 || referenceObject.Staff == 4 || referenceObject.Staff == 5 || referenceObject.Staff == 6) { string BeforeComma = string.Empty; string AfterComma = string.Empty; SqlDatabaseClient client = SqlDatabaseManager.GetClient(); Session session_0; Session session_1; Input = Input.Replace("share", ""); Input = Input.Replace(" ", ""); BeforeComma = Input.Remove(Input.LastIndexOf(',')); AfterComma = Input.Substring(Input.IndexOf(',') + 1); string username = BeforeComma.Replace(" ", ""); string amountofcredits_0 = AfterComma.Replace(" ", ""); int amount = int.Parse(amountofcredits_0); uint actorID = CharacterResolverCache.GetUidFromName(actor.Name); uint actorID2 = CharacterResolverCache.GetUidFromName(username); session_0 = SessionManager.GetSessionByCharacterId(actorID); session_1 = SessionManager.GetSessionByCharacterId(actorID2); SpaceInstance instanceBySpaceId2 = SpaceManager.GetInstanceBySpaceId(session_1.CurrentSpaceId); SpaceActor actor2 = (instanceBySpaceId2 == null) ? null : instanceBySpaceId2.GetActorByReferenceId(session_1.CharacterId, SpaceActorType.UserCharacter); CharacterInfo referenceObject2 = (CharacterInfo)actor2.ReferenceObject; if (enoughcredits(session_0, amount)) { referenceObject.UpdateGoldCreditsBalance(client, -amount); session_0.SendData(CharacterCoinsComposer.RemoveGoldCompose(Convert.ToUInt32(amount)), false); referenceObject2.UpdateGoldCreditsBalance(client, +amount); session_1.SendData(CharacterCoinsComposer.AddGoldCompose(Convert.ToUInt32(amount)), false); string str = string.Format("{0}: Shared {1} Credits To {2}!", actor.Name, amount, username); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(0, str, 3, ChatType.Say), 0, false); } else { string str = string.Format("Could not send {0} the credits, did you have enough?", username); actor.Whisper(str, actorID, false); } return(true); } return(false); case "take": if (referenceObject.Staff == 2 || referenceObject.Staff == 6) { Session session_0; Session session_1; uint actoeid = CharacterResolverCache.GetUidFromName(actor.Name); string userthatadded = actor.Name; SqlDatabaseClient mySqlClient = SqlDatabaseManager.GetClient(); int credits = 0; string Input2 = Input; string reason2 = Input2.Substring(Input2.IndexOf(',') + 1); credits = int.Parse(reason2); Input = Input.Replace(",", ""); string[] split = Input.Split(' '); string username = (split[1]); string reason = string.Join(" ", Input, 2, Input.Length - 2); uint ID = CharacterResolverCache.GetUidFromName(username); session_0 = SessionManager.GetSessionByCharacterId(ID); //givecredits2(mySqlClient, credits, username); session_1 = SessionManager.GetSessionByCharacterId(ID); int gold = session_1.CharacterInfo.GoldCoins; int minusgold = gold - credits; if (minusgold < 0) { actor.Whisper("Error, the amount you tried to give was below 0", actoeid, false); } else { referenceObject.UpdateGoldCreditsBalance(mySqlClient, -credits); session_0.SendData(CharacterCoinsComposer.RemoveGoldCompose(Convert.ToUInt32(credits)), false); string str = string.Format("{0}: Took Away {1} Credits From {2}!", userthatadded, credits, username); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(0, str, 3, ChatType.Say), 0, false); } return(true); } return(false); case "kick": if (referenceObject.Staff == 1 || referenceObject.Staff == 2 || referenceObject.Staff == 6) { Session session_0; Input = Input.Replace("kick", ""); Input = Input.Replace(" ", ""); uint ID = CharacterResolverCache.GetUidFromName(Input); if (SessionManager.ContainsCharacterId(ID)) { session_0 = SessionManager.GetSessionByCharacterId(ID); SpaceManager.RemoveUserFromSpace(session_0); string str = string.Format("{0}: Has Kicked {1} From Island.", actor.Name, Input); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(0, str, 3, ChatType.Say), 0, false); } else { } //SpaceManager.GetInstanceBySpaceId //SpaceUserRemovedComposer.BroadcastCompose( return(true); } return(false); case "kickoffline": if (referenceObject.Staff == 2 || referenceObject.Staff == 6) { Session session_0; Input = Input.Replace("kickoffline", ""); Input = Input.Replace(" ", ""); uint ID = CharacterResolverCache.GetUidFromName(Input); if (SessionManager.ContainsCharacterId(ID)) { session_0 = SessionManager.GetSessionByCharacterId(ID); uint session_id2 = session_0.CharacterInfo.SessionId; SessionManager.StopSession(session_id2); string str = string.Format("{0}: Has kicked {1} Offline!", actor.Name, Input); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(0, str, 3, ChatType.Say), 0, false); } else { } //SpaceManager.GetInstanceBySpaceId //SpaceUserRemovedComposer.BroadcastCompose( return(true); } return(false); case "mod": if (actor.Name == "Kyle" || actor.Name == "Brandon" || actor.Name == "Mike") { Session session_0; SqlDatabaseClient client; client = SqlDatabaseManager.GetClient(); Input = Input.Replace("mod", ""); Input = Input.Replace(" ", ""); string Input2 = Input; string level = Input2.Substring(Input2.IndexOf(",") + 1); uint mod = Convert.ToUInt32(level); if (Input.Contains(",")) { Input = Input.Substring(0, Input.LastIndexOf(",")); } givemod(client, Input, mod); string str = string.Format("{0}: Gave {1} Level {2} Mod Ability.", actor.Name, Input, mod); instanceBySpaceId.BroadcastMessage(SpaceChatComposer.Compose(0, str, 3, ChatType.Say), 0, false); uint ID = CharacterResolverCache.GetUidFromName(Input); session_0 = SessionManager.GetSessionByCharacterId(ID); uint session_id2 = session_0.CharacterInfo.SessionId; SessionManager.StopSession(session_id2); return(true); } return(false); case "getmod": if (actor.Name == "Kyle" || actor.Name == "Brandon" || actor.Name == "Mike") { SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient(); Input = Input.Replace("getmod", ""); Input = Input.Replace(" ", ""); uint ID2 = CharacterResolverCache.GetUidFromName(actor.Name); uint ID = CharacterResolverCache.GetUidFromName(Input); Session session_1; session_1 = SessionManager.GetSessionByCharacterId(ID); uint modlevel = session_1.CharacterInfo.Staff; string str = string.Format("User {0} is mod level {1}", Input, modlevel); actor.Whisper(str, ID2, false); SessionManager.StopSession(session_1.AbsoluteSpaceId); return(true); } return(false); } return(false); }
public void TryAuthenticate(string Ticket, string RemoteAddress) { using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { uint AuthedUid = SingleSignOnAuthenticator.TryAuthenticate(MySqlClient, Ticket, RemoteAddress); if (AuthedUid <= 0) { SessionManager.StopSession(mId); return; } CharacterInfo Info = CharacterInfoLoader.GetCharacterInfo(MySqlClient, AuthedUid, mId, true); if (Info == null || !Info.HasLinkedSession) // not marked online = CharacterInfoLoader failed somehow { SessionManager.StopSession(mId); return; } mCharacterInfo = Info; mAchieventCache = new AchievementCache(MySqlClient, CharacterId); mBadgeCache = new BadgeCache(MySqlClient, CharacterId, mAchieventCache); if (!HasRight("login")) { SessionManager.StopSession(mId); return; } mCharacterInfo.TimestampLastOnline = UnixTimestamp.GetCurrent(); CharacterResolverCache.AddToCache(mCharacterInfo.Id, mCharacterInfo.Username, true); mMessengerFriendCache = new SessionMessengerFriendCache(MySqlClient, CharacterId); mFavoriteRoomsCache = new FavoriteRoomsCache(MySqlClient, CharacterId); mRatedRoomsCache = new RatedRoomsCache(); mInventoryCache = new InventoryCache(MySqlClient, CharacterId); mIgnoreCache = new UserIgnoreCache(MySqlClient, CharacterId); mNewItemsCache = new NewItemsCache(MySqlClient, CharacterId); mAvatarEffectCache = new AvatarEffectCache(MySqlClient, CharacterId); mQuestCache = new QuestCache(MySqlClient, CharacterId); mPetCache = new PetInventoryCache(MySqlClient, CharacterId); // Subscription manager MySqlClient.SetParameter("userid", CharacterId); DataRow Row = MySqlClient.ExecuteQueryRow("SELECT * FROM user_subscriptions WHERE user_id = @userid"); mSubscriptionManager = (Row != null ? new ClubSubscription(CharacterId, (ClubSubscriptionLevel)int.Parse((Row["subscription_level"].ToString())), (double)Row["timestamp_created"], (double)Row["timestamp_expire"], (double)Row["past_time_hc"], (double)Row["past_time_vip"]) : new ClubSubscription(CharacterId, ClubSubscriptionLevel.None, 0, 0, 0, 0)); if (mSubscriptionManager.SubscriptionLevel < ClubSubscriptionLevel.VipClub) { mBadgeCache.DisableSubscriptionBadge("ACH_VipClub"); } if (mSubscriptionManager.SubscriptionLevel < ClubSubscriptionLevel.BasicClub) { mBadgeCache.DisableSubscriptionBadge("ACH_BasicClub"); } mAvatarEffectCache.CheckEffectExpiry(this); mAuthProcessed = true; SendData(AuthenticationOkComposer.Compose()); SendData(FuseRightsListComposer.Compose(this)); SendData(UserHomeRoomComposer.Compose(mCharacterInfo.HomeRoom)); SendData(UserEffectListComposer.Compose(AvatarEffectCache.Effects)); SendData(NavigatorFavoriteRoomsComposer.Compose(FavoriteRoomsCache.FavoriteRooms)); SendData(InventoryNewItemsComposer.Compose(NewItemsCache.NewItems)); SendData(MessageOfTheDayComposer.Compose("Welcome to uberHotel.org BETA.\n\n\nThank you for participating in the uberHotel.org BETA test. We hope to gather relevant feedback and ideas to help make this hotel into a success.\n\nPlease submit any bugs, feedback, or ideas via:\nhttp://snowlight.uservoice.com\n\n\nHave fun, and thank you for joining us!")); SendData(AchievementDataListComposer.Compose(AchievementManager.Achievements.Values.ToList())); // This is available status packet (AvailabilityStatusMessageComposer) ServerMessage UnkMessage2 = new ServerMessage(290); UnkMessage2.AppendInt32(1); UnkMessage2.AppendInt32(0); SendData(UnkMessage2); // This is info feed packet (InfoFeedEnableMessageComposer) ServerMessage UnkMessage3 = new ServerMessage(517); UnkMessage3.AppendInt32(1); // 1 = enabled 0 = disabled (true/false) SendData(UnkMessage3); // This is activity points message (ActivityPointsMessageComposer) not sure how this is handled... ServerMessage UnkMessage4 = new ServerMessage(628); UnkMessage4.AppendInt32(1); UnkMessage4.AppendInt32(0); UnkMessage4.AppendInt32(2971); SendData(UnkMessage4); SendData(ClientConfigComposer.Compose(CharacterInfo.ConfigVolume, false)); if (HasRight("moderation_tool")) { SendData(ModerationToolComposer.Compose(this, ModerationPresets.UserMessagePresets, ModerationPresets.UserActionPresets, ModerationPresets.RoomMessagePresets)); foreach (ModerationTicket ModTicket in ModerationTicketManager.ActiveTickets) { SendData(ModerationTicketComposer.Compose(ModTicket)); } } MessengerHandler.MarkUpdateNeeded(this, 0, true); } }