public static MobRenameInfo RenameCharacter(Serial serial, int maxTries) { UOCharacter ch = new UOCharacter(serial); MobRenameInfo renameInfo = EnsureRegisterRenameInfo(serial);//Game.renamedHt[serial] != null ? (MobRenameInfo)Game.renamedHt[serial] : new MobRenameInfo(); if (renameInfo.Success || renameInfo.Tries >= maxTries) { return(renameInfo); } renameInfo.Tries++; bool check = false; check = !String.IsNullOrEmpty(ch.Name); if (!check) { if (Game.Debug) { Game.PrintMessage("Rename Check - Name EMPTY"); } check = ch.RequestStatus(250 + Core.CurrentLatency); } if (!check) { if (Game.Debug) { Game.PrintMessage("Rename Check - !RequestStatus"); } ch.Click(); Game.Wait(150); check = !String.IsNullOrEmpty(ch.Name) && ch.RequestStatus(250); } renameInfo.OriginalName = ch.Name; if (check) { string playerCode = Rename.PlayerShortCode; if ((ch.Name + String.Empty).StartsWith(playerCode)) { renameInfo.NewName = ch.Name; renameInfo.Success = true; } else if (ch.Renamable || Game.IsPossibleMob(ch) && ch.Distance <= 4)//Uvidime, ty klamaky nejak casti blbnou oproti summum { var chars = "abcdefghijklmnopqrstuvwxyz1234567890"; var random = new Random(); var result = new string( Enumerable.Repeat(chars, 5) .Select(s => s[random.Next(s.Length)]) .ToArray()); result = playerCode + result; if (result.Length > 1) { result = result.Substring(0, result.Length - 2) + result[result.Length - 2].ToString().ToUpper() + result[result.Length - 1].ToString().ToUpper(); } renameInfo.NewName = result; renameInfo.Success = ch.Rename(result); if (Game.Debug) { Game.PrintMessage("Rename : " + renameInfo.Success + " [" + result + "]/[" + renameInfo.OriginalName + "]"); } Game.Wait(Core.CurrentLatency); if (renameInfo.Success) { byte[] data = PacketBuilder.CharacterSpeechUnicode(ch.Serial, ch.Model, result, SpeechType.Regular, SpeechFont.Normal, Game.Val_PureWhite, "[ " + result + " ]"); Core.SendToClient(data, true); } } } else if (Game.Debug) { Game.PrintMessage("!Rename Check"); } if (renameInfo.Success) { new StatusBar().Show(ch.Serial); } return(renameInfo); }