public static void CreateNewCharacter(MartialClient c, InPacket p) { if (c.getAccount().activeCharacter != null) { Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character while being ingame."); c.Close(); return; } if (c.getAccount().characters.Count() == 5) { Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character while characters count is 5."); c.Close(); return; } string charName = MiscFunctions.obscureString(p.ReadString(18)); if (charName == null) { c.WriteRawPacket(Constants.createNCharNameTaken); return; } if (charName.Length < 3 || Regex.Replace(charName, "[^A-Za-z0-9]+", "") != charName || MySQLTool.NameTaken(charName)) { c.WriteRawPacket(Constants.createNCharNameTaken); return; } byte face = (byte)p.ReadShort(); if (face < 1 || face > 7) { Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character with face no {0}", face); c.WriteRawPacket(Constants.createNCharNameTaken); return; } short unknownShit = p.ReadShort(); // but let's check it if (unknownShit > 0) { Logger.WriteLog(Logger.LogTypes.Debug, "Create character's shit: {0}", unknownShit); } short unknownShit2 = p.ReadShort(); if (unknownShit2 > 0) { Logger.WriteLog(Logger.LogTypes.Debug, "Create character's shit: {0}", unknownShit2); } byte cClass = (byte)p.ReadShort(); if (cClass < 1 || cClass > 4) { Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character with class no {0}", cClass); c.WriteRawPacket(Constants.createNCharNameTaken); return; } byte[] stats = { (byte)p.ReadShort(), (byte)p.ReadShort(), (byte)p.ReadShort(), (byte)p.ReadShort(), (byte)p.ReadShort() }; byte statPoints = (byte)p.ReadShort(); if (stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + statPoints > 55) { Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character with weird amount of attributes."); c.WriteRawPacket(Constants.createNCharNameTaken); return; } Character newChr = new Character(); newChr.setName(charName); newChr.setFace(face); newChr.setcClass(cClass); newChr.setStr(stats[0]); newChr.setDex(stats[1]); newChr.setVit(stats[2]); newChr.setAgi(stats[3]); newChr.setInt(stats[4]); newChr.setStatPoints(statPoints); newChr.setAccount(c.getAccount()); if (newChr.Create() == true) { CharacterFunctions.createEquipments(newChr); CharacterFunctions.createInventories(newChr); CharacterFunctions.calculateCharacterStatistics(newChr); newChr.setCurHP(newChr.getMaxHP()); newChr.setCurMP(newChr.getMaxMP()); newChr.setCurSP(newChr.getMaxSP()); c.getAccount().appendToCharacters(newChr); c.WriteRawPacket(Constants.createNewCharacter); return; } c.WriteRawPacket(Constants.createNCharNameTaken); return; }