public static Hashtable[] Query(string qry) { Stopwatch sw = new Stopwatch(); sw.Start(); SqliteDataReader reader = null; cmd = conn.CreateCommand(); cmd.CommandText = qry; try { reader = cmd.ExecuteReader(); } catch (Exception ex) { MainClass.AddLog("Query error: '" + ex.Message + "'", true); MainClass.AddLog("Query was: '" + qry + "'", true); return(null); } List <Hashtable> ret = new List <Hashtable>(); while (reader.Read()) { Hashtable row = new Hashtable(); for (int i = 0; i < reader.FieldCount; i++) { if (reader[i].GetType() == typeof(Int64)) { if ((long)reader[i] > int.MaxValue) { row[reader.GetName(i)] = (long)reader[i]; } else { row[reader.GetName(i)] = (int)(long)reader[i]; } } else { row[reader.GetName(i)] = reader[i]; } } ret.Add(row); } sw.Stop(); if (sw.ElapsedMilliseconds >= 1000) { MainClass.AddLog("SQL Query took very long: " + sw.ElapsedMilliseconds + "ms", true); } return(ret.ToArray()); }
public void Kick() { MainClass.AddLog("Client '" + this.User_Name + "' kicked."); if (this.CurrentRoom != null) { this.CurrentRoom = null; } this.Disconnect(); }
public void Disconnect() { MainClass.AddLog("Client '" + this.User_Name + "' disconnected."); if (this.CurrentRoom != null) { this.CurrentRoom.Users.Remove(this); } this.tcpClient.Close(); this.Connected = false; }
void couldntReadData() { MainClass.AddLog("Couldn't read data from " + this.User_Name + ", user disconnecting"); if (CurrentRoom != null) { CurrentRoom = null; } mainClass.Users.Remove(this); this.tcpClient.Close(); }
} // end addslashes public static Hashtable[] Query(string query) { Stopwatch sw = new Stopwatch(); sw.Start(); MySql obj = new MySql(); List <Hashtable> ret = new List <Hashtable>(); if (obj.Open() == true) { MySqlCommand cmd = new MySqlCommand(query, obj.conn); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Hashtable row = new Hashtable(); for (int i = 0; i < reader.FieldCount; i++) { if (reader[i].GetType() == typeof(Int64)) { if ((long)reader[i] > int.MaxValue) { row[reader.GetName(i)] = (long)reader[i]; } else { row[reader.GetName(i)] = (int)(long)reader[i]; } } else { row[reader.GetName(i)] = reader[i]; } } //end for ret.Add(row); } //end while reader.Close(); obj.Close(); } //end openconnection sw.Stop(); if (sw.ElapsedMilliseconds >= 1000) { MainClass.AddLog("SQL Query took very long: " + sw.ElapsedMilliseconds + "ms", true); } return(ret.ToArray()); } //end QueryMethod
// public void WriteNTu(string data) // { //// int length; // byte[] writeBytes = UTF8Encoding.UTF8.GetBytes(data); //// length = writeBytes.Length; //// writeBytes[length] = 0; // WriteArr(writeBytes); //// byte[] utf8data = UTF8Encoding.UTF8.GetBytes(data); //// byte[] writeBytes = new byte[utf8data.Length + 1]; //// writeBytes = UTF8Encoding.UTF8.GetBytes(data); //// writeBytes[utf8data.Length] = 0; //// WriteArr(writeBytes); // ///// byte[] utf8writeBytes = UTF8Encoding.UTF8.GetBytes(data); //// byte[] writeBytes = new byte[utf8writeBytes.Length + 1]; //// utf8writeBytes.CopyTo(writeBytes, 0); //// return writeBytes; // } public byte[] ReadArr(int count) { try { return(user.tcpReader.ReadBytes(count)); } catch { MainClass.AddLog("Reading while socket closed!", true); return(new byte[0]); } }
} // end open private bool Close() { try { conn.Close(); return(true); } catch (MySqlException ex) { MainClass.AddLog(ex.ToString()); return(false); } } // end close
// Client handshakes with the server public void NSCHello() { User_Protocol = ez.Read1(); User_Game = ez.ReadNT().Replace("\n", "|"); MainClass.AddLog(User_IP + " is using SMOP v" + User_Protocol.ToString() + " in " + User_Game); PlayTime.Start(); ez.Write1((byte)(mainClass.ServerOffset + NSCommand.NSCHello)); ez.Write1(mainClass.ServerVersion); ez.WriteNT(mainClass.ServerConfig.Get("Server_Name")); ez.SendPack(); }
public byte Read1() { LastPacketSize--; try { return(user.tcpReader.ReadByte()); } catch { MainClass.AddLog("Reading while socket closed!", true); return(0); } }
public static void Connect() { UseCommit = bool.Parse(MainClass.Instance.ServerConfig.Get("Database_UseCommit")); conn = new SqliteConnection("Data Source=" + Filename + ";Version=" + Version.ToString() + ";New=False;Compress=" + Compress.ToString() + ";Journal Mode=Off;UTF8Encoding=True;"); try { conn.Open(); } catch (Exception ex) { MainClass.AddLog("Couldn't open SQLite database: " + ex.Message, true); } if (UseCommit) { Query("BEGIN TRANSACTION"); } }
public void SendToRoom() { SyncNeeded = false; CanPlay = true; if (CurrentRoom != null) { SendRoomList(); ez.Write1((byte)(mainClass.ServerOffset + NSCommand.NSCSMOnline)); ez.Write1(1); ez.Write1(0); ez.WriteNT(CurrentRoom.Name); ez.WriteNT(CurrentRoom.Description); ez.Write1(1); // If this is 0, it won't change the players' screen ez.SendPack(); foreach (User user in mainClass.Users) { user.SendRoomPlayers(); } CurrentRoomRights = RoomRights.Player; mainClass.SendChatAll(NameFormat() + Func.ChatColor("ffffff") + " joined the room.", CurrentRoom); if (CurrentRoom.Fixed) { if (CurrentRoom.FixedMotd != "") { SendChatMessage(Func.ChatColor("00aa00") + CurrentRoom.FixedMotd); } if (CurrentRoom.FixedOperators.Contains(User_ID)) { SendChatMessage(Func.ChatColor("0000aa") + "You are an operator in this fixed room."); CurrentRoomRights = RoomRights.Operator; } } } else { MainClass.AddLog("Not supported: Kicking from room. Fixme! User::SendToRoom", true); } }
public static int CreateRoomDB(User user) { if (user.CurrentRoom == null || user.CurrentRoom.CurrentSong == null) { return(-1); } else { string owner = MySql.AddSlashes(user.CurrentRoom.Owner.User_Name); string name = MySql.AddSlashes(user.CurrentRoom.Name); string desc = MySql.AddSlashes(user.CurrentRoom.Description); MySql.Query("INSERT INTO rooms (Name,Description,Owner) VALUES('" + name + "','" + desc + "','" + owner + "')"); MainClass.AddLog("Owner: " + owner + " Name: " + name + "Description: " + desc); Hashtable[] getroomid = MySql.Query("SELECT ID from rooms where Name = '" + name + "' and Description = '" + desc + "' and Owner = '" + owner + "' ORDER BY created DESC LIMIT 1"); Hashtable roomidhash = getroomid[0]; int roomid = (int)roomidhash["ID"]; return(roomid); } }
public static Hashtable GetSong(string Name, string Artist, string SubTitle) { Hashtable[] resCheck = MySql.Query("SELECT * FROM songs WHERE BINARY Name='" + Name + "' " + "AND BINARY Artist='" + Artist + "' " + "AND BINARY SubTitle='" + SubTitle + "' LIMIT 1"); MainClass.AddLog("A DB select was made on (Name,Artist,Subtitle) VALUES('" + Name + "','" + Artist + "','" + SubTitle + "')"); if (resCheck == null) { return(null); } if (resCheck.Length == 1) { return(resCheck[0]); } else { return(null); } }
public void Update() { if (++SendStatsTimer == mainClass.FPS / 2) { foreach (User user in Users) { if (user.Playing) { user.SendGameStatus(); } } SendStatsTimer = 0; } if (UserCount == 0 && !Fixed) { MainClass.AddLog("Room '" + Name + "' removed."); mainClass.Rooms.Remove(this); } }
private bool Open() { try { conn.Open(); return(true); } catch (MySqlException ex) { switch (ex.Number) { case 0: MainClass.AddLog("MySQL: Cannot connect to server."); break; case 1045: MainClass.AddLog("MySQL: Invalid username/password."); break; } return(false); } } // end open
public void HandleError(Exception ex) { MainClass.AddLog("Scripting error: " + Engine.GetService <ExceptionOperations>().FormatException(ex), true); }
public static void AddStats(User user) { if (user.CurrentRoom == null) { return; } if (user.CurrentRoom.CurrentSong == null) { return; } string Name = MySql.AddSlashes(OpenSMO.User.Utf8Decode(user.CurrentRoom.CurrentSong.Name)); string Artist = MySql.AddSlashes(OpenSMO.User.Utf8Decode(user.CurrentRoom.CurrentSong.Artist)); string SubTitle = MySql.AddSlashes(OpenSMO.User.Utf8Decode(user.CurrentRoom.CurrentSong.SubTitle)); int songID = 0; Hashtable song = Data.GetSong(Name, Artist, SubTitle); if (song == null) { MySql.Query("INSERT INTO songs (Name,Artist,SubTitle) VALUES(" + "'" + Name + "'," + "'" + Artist + "'," + "'" + SubTitle + "')"); } Hashtable newsong = Data.GetSong(Name, Artist, SubTitle); if (newsong != null) { if (!user.ShadowBanned) { double songTime = user.SongTime.Elapsed.TotalSeconds; if (songTime != 0) { if ((user.SongOptions.Contains("Fail")) && (user.User_Protocol == 2)) { // if (songTime > (int)newsong["Time"]) // { MySql.Query("UPDATE songs SET Time=" + songTime.ToString().Replace(',', '.') + " WHERE ID=" + newsong["ID"]); } // } } } } // MainClass.AddLog("User ID " +user.User_Table["ID"].ToString() + "'s Final Timing: " + user.timing); MainClass.AddLog("User ID " + user.User_Table["ID"].ToString() + "'s Toasty Count: " + user.toasty); MainClass.AddLog("User ID " + user.User_Table["ID"].ToString() + "'s Room ID: " + user.CurrentRoom.roomid); // Give player XP int XP = 0; for (int i = 3; i <= 8; i++) { XP += (i - 3) * user.Notes[i]; } // MainClass.AddLog("Regular XP: " + XP + "Jump XP: " + user.jumpxp); XP += user.jumpxp; user.jumpxp = 0; XP /= 6; if (user.timing > 2) { user.toasty = 0; XP = 0; } // user.SendChatMessage("You gained " + Func.ChatColor("aaaa00") + XP.ToString() + Func.ChatColor("ffffff") + " XP!"); int toastyxp = (user.toasty * 50); XP += toastyxp; // user.SendChatMessage("You gained an additional " + Func.ChatColor("aaaa00") + toastyxp.ToString() + Func.ChatColor("ffffff") + " Bonus XP for " + user.toasty + " Toasty(s) for a total of " + Func.ChatColor("aaaa00") + XP.ToString() + Func.ChatColor("ffffff") + " XP!"); int fullcomboxp = 0; int marv = user.Notes[8]; int perf = user.Notes[7]; int grea = user.Notes[6]; int good = user.Notes[5]; int boo = user.Notes[4]; int miss = user.Notes[3]; int ok = user.Notes[10]; int ng = user.Notes[9]; float Tpnt = (3 * marv) + (2 * perf) + grea - (4 * boo) - (8 * miss) + (6 * ok); float Tmaxpnt = 3 * (marv + perf + grea + good + boo + miss) + 6 * (ok + ng); float percentf = (Tpnt / Tmaxpnt) * 100F; string mpercent = percentf.ToString("n3"); string percent = percentf.ToString("n2"); if ((miss == 0) && (boo == 0) && (good == 0) && ((marv + perf + grea) > 8)) { if ((marv + perf + grea) > 150) { fullcomboxp = 100; } } XP += fullcomboxp; int pretoastyxp = XP; string percentageq = "round(100.00/(3 * (Note_Flawless + Note_Perfect + Note_Great + Note_Good + Note_Barely + Note_Miss) + 6 * (Note_Held + Note_NG))*((3 * Note_Flawless) + (2 * Note_Perfect) + Note_Great - (4 * Note_Barely) - (8 * Note_Miss) + (6 * Note_Held)),3)"; if (newsong != null) { songID = (int)newsong["ID"]; Hashtable[] smoPBestQuery = MySql.Query("select count(*) as 'count' from stats where song = " + songID.ToString() + " and user = "******"ID"].ToString() + " and Difficulty = '" + ((int)user.GameDifficulty).ToString() + "' and Feet = '" + user.GameFeet.ToString() + "' and " + percentageq + " > '" + mpercent + "'"); Hashtable PBStats = smoPBestQuery[0]; int count = (int)PBStats["count"]; count += 1; Hashtable[] smoPBestTotalQuery = MySql.Query("select count(*) as 'count' from stats where song = " + songID.ToString() + " and user = "******"ID"].ToString() + " and Difficulty = '" + ((int)user.GameDifficulty).ToString() + "' and Feet = '" + user.GameFeet.ToString() + "'"); Hashtable oPBStats = smoPBestTotalQuery[0]; int ocount = (int)oPBStats["count"]; ocount += 1; Hashtable[] smoTBestQuery = MySql.Query("select count(*) as 'count' from stats where song = " + songID.ToString() + " and Difficulty = '" + ((int)user.GameDifficulty).ToString() + "' and Feet = '" + user.GameFeet.ToString() + "' and " + percentageq + " > '" + mpercent + "'"); Hashtable TBStats = smoTBestQuery[0]; int tcount = (int)TBStats["count"]; tcount += 1; Hashtable[] smoTBestTotalQuery = MySql.Query("select count(*) as 'count' from stats where song = " + songID.ToString() + " and Difficulty = '" + ((int)user.GameDifficulty).ToString() + "' and Feet = '" + user.GameFeet.ToString() + "'"); Hashtable oTBStats = smoTBestTotalQuery[0]; int tocount = (int)oTBStats["count"]; tocount += 1; string bestmessage = Func.ChatColor("aaaa00") + percent + "%" + Func.ChatColor("ffffff") + " PB: #" + Func.ChatColor("aaaa00") + count + "/" + ocount + Func.ChatColor("ffffff") + " TB: #" + Func.ChatColor("aaaa00") + tcount + "/" + tocount + Func.ChatColor("ffffff"); if (user.toasty > 0) { bestmessage = bestmessage + " " + Func.ChatColor("aaaa00") + pretoastyxp + "+" + toastyxp + Func.ChatColor("ffffff") + " XP Gained - " + Func.ChatColor("aaaa00") + user.toasty + Func.ChatColor("ffffff") + " Toasty(s)"; } else { bestmessage = bestmessage + " " + Func.ChatColor("aaaa00") + pretoastyxp + Func.ChatColor("ffffff") + " XP Gained "; } if (fullcomboxp > 0) { bestmessage = bestmessage + " -FC"; } fullcomboxp = 0; if (user.timing > 2) { bestmessage = bestmessage + " -TIMING"; } if (user.ShowOffset) { double clientoffsetavg = user.clientoffset / (double)user.clientoffsetcount; double clientoffsetms = clientoffsetavg * (double)1000; bestmessage = bestmessage + " " + Func.ChatColor("aa0000") + "+" + user.offsetpos.ToString() + Func.ChatColor("ffffff") + "/" + Func.ChatColor("aa0000") + "-" + user.offsetneg.ToString() + " " + clientoffsetms.ToString("n3") + Func.ChatColor("ffffff") + "ms"; } string playerSettings = Sql.AddSlashes(user.GamePlayerSettings); if (!user.ShadowBanned) { // Big-ass query right there... if (!user.ShadowBanned) { MySql.Query("INSERT INTO stats (User,PlayerSettings,Song,Room,Feet,Difficulty,Grade,Score,MaxCombo," + "Note_0,Note_1,Note_Mine,Note_Miss,Note_Barely,Note_Good,Note_Great,Note_Perfect,Note_Flawless,Note_NG,Note_Held,Toasty,timing, rate) VALUES(" + user.User_Table["ID"].ToString() + ",'" + playerSettings + "'," + songID.ToString() + "," + user.CurrentRoom.roomid.ToString() + "," + user.GameFeet.ToString() + "," + ((int)user.GameDifficulty).ToString() + "," + ((int)user.Grade).ToString() + "," + user.Score.ToString() + "," + user.MaxCombo.ToString() + "," + user.Notes[0].ToString() + "," + user.Notes[1].ToString() + "," + user.Notes[2].ToString() + "," + user.Notes[3].ToString() + "," + user.Notes[4].ToString() + "," + user.Notes[5].ToString() + "," + user.Notes[6].ToString() + "," + user.Notes[7].ToString() + "," + user.Notes[8].ToString() + "," + user.Notes[9].ToString() + "," + user.Notes[10].ToString() + "," + user.toasty + "," + user.timing + "," + user.PlayerRate + ")"); } } user.SendRoomChatMessage(bestmessage); user.toasty = 0; user.timing = 0; user.offsetneg = 0; user.offsetpos = 0; user.clientoffsetcount = 0; user.clientoffset = 0; user.servcombo = 0; user.perfmarv = 0; } if (!user.ShadowBanned) { MySql.Query("UPDATE users SET XP=XP+" + XP.ToString() + " WHERE ID=" + user.User_ID.ToString()); } //Update Current rank in users name Hashtable[] checkxp = MySql.Query("select XP from users where ID = '" + user.User_Table["ID"].ToString() + "'"); Hashtable XP_Table = checkxp[0]; int currentxp = (int)XP_Table["XP"] + 1; Hashtable[] checkrank = MySql.Query("select count(*) as 'levelrank' from users where xp > '" + currentxp.ToString() + "'"); Hashtable New_Rank_Table = checkrank[0]; int oldrank = user.User_Level_Rank; user.User_Level_Rank = (int)New_Rank_Table["levelrank"] + 1; if (oldrank != user.User_Level_Rank) { user.SendChatMessage("Your Rank changed from " + Func.ChatColor("aaaa00") + oldrank.ToString() + Func.ChatColor("ffffff") + " to " + Func.ChatColor("aaaa00") + user.User_Level_Rank.ToString() + Func.ChatColor("ffffff") + " -- Congratz!"); } }
private static void CloseHandler() { MainClass.AddLog("Connection closed during StreamHelper byte reading", true); }
private static void ErrorHandler() { MainClass.AddLog("Error in StreamHelper", true); }
// Client sent SMO packet (note subpacket comments) public void NSCSMOnline() { packetCommandSub = ez.Read1(); byte packetCommandSubSub = ez.Read1(); if (packetCommandSub == 0) // Login { ez.Read1(); // Reserved byte string smoUsername = ez.ReadNT(); string smoPassword = ez.ReadNT(); if (!new Regex("^([A-F0-9]{32})$").Match(smoPassword).Success) { ez.Write1((byte)(mainClass.ServerOffset + NSCommand.NSCSMOnline)); ez.Write2(1); ez.WriteNT("Login failed! Invalid password."); ez.SendPack(); MainClass.AddLog("Invalid password hash given!", true); return; } Hashtable[] smoLoginCheck = MySql.Query("SELECT * FROM users WHERE Username='******'"); if (smoLoginCheck.Length == 1 && smoLoginCheck[0]["Password"].ToString() == smoPassword) { MainClass.AddLog(smoUsername + " logged in."); User_Table = smoLoginCheck[0]; User_ID = (int)User_Table["ID"]; User_Name = (string)User_Table["Username"]; User_Rank = (UserRank)User_Table["Rank"]; ez.Write1((byte)(mainClass.ServerOffset + NSCommand.NSCSMOnline)); ez.Write2(0); ez.WriteNT("Login success!"); ez.SendPack(); SendChatMessage(mainClass.ServerConfig.Get("Server_MOTD")); SendRoomList(); User[] users = GetUsersInRoom(); foreach (User user in users) { user.SendRoomPlayers(); } return; } else if (smoLoginCheck.Length == 0) { if (bool.Parse(mainClass.ServerConfig.Get("Allow_Registration"))) { smoUsername = smoUsername.Trim(); if (smoUsername.Trim() == "") { ez.Write1((byte)(mainClass.ServerOffset + NSCommand.NSCSMOnline)); ez.Write2(1); ez.WriteNT("Registration failed! Invalid username."); ez.SendPack(); return; } MySql.Query("INSERT INTO users (Username,Password,Email,Rank,XP) VALUES(\"" + MySql.AddSlashes(smoUsername) + "\",\"" + MySql.AddSlashes(smoPassword) + "\",\"\",0,0)"); MainClass.AddLog(smoUsername + " is now registered"); User_Table = MySql.Query("SELECT * FROM users WHERE Username='******' AND Password='******'")[0]; User_ID = (int)User_Table["ID"]; User_Name = (string)User_Table["Username"]; User_Rank = (UserRank)User_Table["Rank"]; ez.Write1((byte)(mainClass.ServerOffset + NSCommand.NSCSMOnline)); ez.Write2(0); ez.WriteNT("Login success!"); ez.SendPack(); SendChatMessage(mainClass.ServerConfig.Get("Server_MOTD")); SendRoomList(); User[] users = GetUsersInRoom(); foreach (User user in users) { user.SendRoomPlayers(); } return; } } MainClass.AddLog(smoUsername + " tried logging in but failed"); ez.Write1((byte)(mainClass.ServerOffset + NSCommand.NSCSMOnline)); ez.Write2(1); ez.WriteNT("Login failed! Invalid password."); ez.SendPack(); } else if (packetCommandSub == 01) // Join room { if (!RequiresAuthentication()) { return; } if (ez.LastPacketSize == 0) { return; } string joinRoomName = ez.ReadNT(); string joinRoomPass = ""; if (ez.LastPacketSize > 0) { joinRoomPass = ez.ReadNT(); } foreach (Room room in mainClass.Rooms) { if (room.Name == joinRoomName && (room.Password == joinRoomPass || IsModerator())) { CurrentRoomRights = RoomRights.Player; CurrentRoom = room; SendToRoom(); break; } } } else if (packetCommandSub == 02) // New room { if (!RequiresAuthentication()) { return; } string newRoomName = ez.ReadNT(); string newRoomDesc = ez.ReadNT(); string newRoomPass = ""; if (ez.LastPacketSize > 0) { newRoomPass = ez.ReadNT(); } MainClass.AddLog(User_Name + " made a new room '" + newRoomName + "'"); Room newRoom = new Room(mainClass, this); newRoom.Name = newRoomName; newRoom.Description = newRoomDesc; newRoom.Password = newRoomPass; mainClass.Rooms.Add(newRoom); User[] users = GetUsersInRoom(); foreach (User user in users) { user.SendRoomList(); } CurrentRoom = newRoom; CurrentRoomRights = RoomRights.Owner; SendToRoom(); SendChatMessage("Welcome to your room! Type /help for a list of commands."); } else { // This is probably only for command sub 3, which is information you get when you hover over a room in the lobby. // TODO: Make NSCSMOnline sub packet 3 (room info on hover) //MainClass.AddLog( "Discarded unknown sub-packet " + packetCommandSub.ToString() + " for NSCSMOnline" ); ez.Discard(); } }
public void Update() { if (++pingTimer == mainClass.FPS) { if (pingTimeout > 0) { pingTimer = 0; pingTimeout = 5; ez.Write1((byte)(mainClass.ServerOffset + NSCommand.NSCPing)); ez.SendPack(); } else { if (pingTimeout == 0) { MainClass.AddLog("Ping timeout for " + this.User_Name + ", user disconnecting"); if (CurrentRoom != null) { CurrentRoom = null; } mainClass.Users.Remove(this); this.tcpClient.Close(); return; } else { MainClass.AddLog("Timeout " + pingTimeout + " for user " + this.User_Name); pingTimeout--; } } } try { int a = tcpClient.Available; } catch { MainClass.AddLog("Socket closed."); if (CurrentRoom != null) { CurrentRoom = null; } mainClass.Users.Remove(this); return; } if (tcpClient.Available > 0) { try { if (ez.ReadPack() == -1) { return; } } catch { this.couldntReadData(); return; } NSCommand packetCommand; try { packetCommand = (NSCommand)ez.Read1(); } catch { this.couldntReadData(); return; } switch (packetCommand) { case NSCommand.NSCPing: this.NSCPing(); break; case NSCommand.NSCPingR: this.NSCPingR(); break; case NSCommand.NSCHello: this.NSCHello(); break; case NSCommand.NSCSMS: this.NSCSMS(); break; case NSCommand.NSCGSR: this.NSCGSR(); break; case NSCommand.NSCGSU: this.NSCGSU(); break; case NSCommand.NSCGON: this.NSCGON(); break; case NSCommand.NSCRSG: this.NSCRSG(); break; case NSCommand.NSCUPOpts: this.NSCUPOpts(); break; case NSCommand.NSCSMOnline: this.NSCSMOnline(); break; case NSCommand.NSCSU: this.NSCSU(); break; case NSCommand.NSCCM: this.NSCCM(); break; default: MainClass.AddLog("Packet " + packetCommand.ToString() + " discarded!"); ez.Discard(); break; } if (mainClass.Scripting.PacketHooks.ContainsKey(packetCommand)) { for (int i = 0; i < mainClass.Scripting.PacketHooks[packetCommand].Count; i++) { try { mainClass.Scripting.PacketHooks[packetCommand][i](new HookInfo() { User = this, SubCommand = packetCommandSub }); } catch (Exception ex) { mainClass.Scripting.HandleError(ex); } } } } }