public static void Execute(User UserThatCalled, params string[] Params) { if (Params.Length > 1) { if (!Permissions.IsStaff(UserThatCalled)) return; User TargetUser = UserManager.GetUserByName(Params[1]); if (TargetUser == null) { UserThatCalled.ClientConnection.SendData("CHAT;Couldn't find that user!"); return; } if (UserThatCalled == TargetUser) return; using(DatabaseConnection DB = new DatabaseConnection()) { DB.SetQuery("UPDATE users SET banned = '1' WHERE id = @id"); DB.AddParam("id", TargetUser.UserID); DB.ExecuteQuery(); } TargetUser.ClientConnection.SendData("CHAT;You were banned by " + UserThatCalled.Username + "!"); TargetUser.ClientConnection.Disconnect(); UserManager.SendMassData("CHAT;" + TargetUser.Username + " was banned by " + UserThatCalled.Username + "!"); } else { UserThatCalled.ClientConnection.SendData("CHAT;Invalid syntax, correct: /ban USERNAME"); } }
public static void SendUserList(User UserToSendTo) { UserToSendTo.ClientConnection.SendData("NEWUSR;" + UserToSendTo.Username); lock (Users.Values) { foreach (User User in Users.Values) { if (User == null || User == UserToSendTo) continue; UserToSendTo.ClientConnection.SendData("NEWUSR;" + User.Username); } } }
public void Disconnect() { if (ClientSocket != null && ClientSocket.Connected) { ClientSocket.Shutdown(SocketShutdown.Both); ClientSocket.Close(); ClientSocket = null; } if (ClientUser != null) { ClientUser.OnDisconnect(); ClientUser = null; } }
public static void Execute(User UserThatCalled, string[] Params) { if (Params.Length < 3) return; if (!Permissions.IsStaff(UserThatCalled)) return; User TargetUser = UserManager.GetUserByName(Params[1]); string Message = "MESSAGE FROM A STAFF MEMBER:\n" + ConstructMessage(Params, 2); if (TargetUser == null) return; TargetUser.ClientConnection.SendData("SHWALERT;" + Message); }
public static void Parse(User User, string Text) { string TextNoSlash = Text.Substring(1); string[] Params = TextNoSlash.Split(' '); string Command = Params[0]; if (Commands.ContainsKey(Command.ToLower())) { Action<User, string[]> MethodToInvoke = Commands[Command.ToLower()]; MethodToInvoke.BeginInvoke(User, Params, null, null); } else { User.ClientConnection.SendData("CHAT;Invalid command!"); } }
public static void Execute(User UserThatCalled, string[] Params) { if (Permissions.IsStaff(UserThatCalled)) SQLQueue.ExecutePendingQueries(); }
public static bool IsStaff(User User) { if (User.Rank > 1) return true; return false; }