public static void FindMobileByName_OnCommand(CommandEventArgs e) { if (e.Length == 1) { LogHelper Logger = new LogHelper("findMobile.log", e.Mobile, true); // The name to find string sName = e.GetString(0); foreach (Mobile m in World.Mobiles.Values) { PlayerMobile pm = m as PlayerMobile; if (pm != null) { if (pm.Name.ToLower() == sName.ToLower()) { Logger.Log(LogType.Mobile, m, String.Format("Online: {0}", ((bool)(pm.NetState != null)).ToString())); } } } Logger.Finish(); } else { // Badly formatted e.Mobile.SendMessage("Usage: FindMobileByName <name>"); } }
public static void FindMultiByType_OnCommand(CommandEventArgs e) { try { if (e.Length == 1) { LogHelper Logger = new LogHelper("FindMultiByType.log", e.Mobile, false); string name = e.GetString(0); foreach (ArrayList list in Server.Multis.BaseHouse.Multis.Values) { for (int i = 0; i < list.Count; i++) { BaseHouse house = list[i] as BaseHouse; // like Server.Multis.Tower if (house.GetType().ToString().ToLower().IndexOf(name.ToLower()) >= 0) { Logger.Log(house); } } } Logger.Finish(); } else { e.Mobile.SendMessage("Format: FindMultiByType <type>"); } } catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); } }
private static void EventSink_AddItem(AddItemEventArgs e) { LogHelper lh = new LogHelper("AddItem.log", false, true); lh.Log(LogType.Mobile, e.from, String.Format("Used [Add Item to create ItemID:{0}, Serial:{1}", e.item.ItemID.ToString(), e.item.Serial.ToString())); lh.Finish(); }
private static void LagReport_OnCommand(CommandEventArgs arg) { Mobile from = arg.Mobile; if (from is PlayerMobile) { PlayerMobile pm = (PlayerMobile)from; // Limit to 5 minutes between lag reports if ((pm.LastLagTime + TimeSpan.FromMinutes(5.0)) < DateTime.Now) { // Let them log again LogHelper lh = new LogHelper("lagreports.log", false, true); lh.Log(LogType.Mobile, from, Server.Engines.CronScheduler.Cron.GetRecentTasks()); //adam: added schduled tasks! //Requested by Adam: Console.WriteLine("Lag at: {0}", DateTime.Now.ToShortTimeString()); // Update LastLagTime on PlayerMobile pm.LastLagTime = DateTime.Now; lh.Finish(); from.SendMessage("The fact that you are experiencing lag has been logged. We will review this with other data to try and determine the cause of this lag. Thank you for your help."); } else { from.SendMessage("It has been less than five minutes since you last reported lag. Please wait five minutes between submitting lag reports."); } } }
public static void RehydrateWorld_OnCommand(CommandEventArgs e) { // make it known Server.World.Broadcast(0x35, true, "The world is rehydrating, please wait."); Console.WriteLine("World: rehydrating..."); DateTime startTime = DateTime.Now; LogHelper Logger = new LogHelper("RehydrateWorld.log", e.Mobile, true); // Extract property & value from command parameters ArrayList containers = new ArrayList(); // Loop items and check vs. types foreach (Item item in World.Items.Values) { if (item is Container) { if ((item as Container).CanFreezeDry == true) { containers.Add(item); } } } Logger.Log(LogType.Text, string.Format("{0} containers scheduled for Rehydration...", containers.Count)); int count = 0; for (int ix = 0; ix < containers.Count; ix++) { Container cont = containers[ix] as Container; if (cont != null) { // Rehydrate it if necessary if (cont.CanFreezeDry && cont.IsFreezeDried == true) { cont.Rehydrate(); } count++; } } Logger.Log(LogType.Text, string.Format("{0} containers actually Rehydrated", count)); Logger.Finish(); e.Mobile.SendMessage("{0} containers actually Rehydrated", count); DateTime endTime = DateTime.Now; Console.WriteLine("done in {0:F1} seconds.", (endTime - startTime).TotalSeconds); Server.World.Broadcast(0x35, true, "World rehydration complete. The entire process took {0:F1} seconds.", (endTime - startTime).TotalSeconds); }
private static void FindSpawner_OnCommand(CommandEventArgs arg) { Mobile from = arg.Mobile; int X = from.Location.X; int Y = from.Location.Y; string SearchText = arg.GetString(0); int TileRange = arg.GetInt32(1); // Validate parameters if (SearchText == "") { from.SendMessage("To use : [findspawner <type> (<range>)"); return; } Regex InvalidPatt = new Regex("[^-a-zA-Z0-9' ]"); if (InvalidPatt.IsMatch(SearchText)) { from.SendMessage("Invalid characters used in type or range specification."); return; } // Perform search and retrieve list of spawner matches LogHelper Logger = new LogHelper("findspawner.log", from, true); ArrayList SpawnerList = FindMobSpawners(SearchText, X, Y, TileRange); if (SpawnerList.Count > 0) { PlayerMobile pm = arg.Mobile as PlayerMobile; // Have results so sort, loop and display message for each match SpawnerList.Sort(); // reset jump table pm.JumpIndex = 0; pm.JumpList = new ArrayList(); foreach (SpawnerMatch ms in SpawnerList) { // this line prevents GMs from locating secret items unless the world is in build mode if (ms.Item == false || from.AccessLevel >= Server.AccessLevel.Administrator || Core.Building) { pm.JumpList.Add(ms.Sp); Logger.Log(LogType.Item, ms.Sp, string.Format("{0}:{1}:{2}", ms.Matched, ms.Distance, ms.Status)); } } } Logger.Finish(); }
public static void DumpRares_OnCommand(CommandEventArgs e) { LogHelper Logger = new LogHelper("RaresDump.log", false); try { foreach (DODGroup dg in RareFactory.DODGroup) { if (dg is DODGroup) { foreach (DODInstance di in dg.DODInst) { if (di is DODInstance) { if (di.RareTemplate == null) { Logger.Log(LogType.Text, String.Format("DODInstance {0} has a null RareTemplate.", di.Name)); } else { Logger.Log(LogType.Item, di.RareTemplate, String.Format("DODInstance {0}: ({1}).", di.Name, di.RareTemplate.GetType().ToString())); } } } } } Logger.Log(LogType.Text, "------------- RareFactory.DODInst -------------"); foreach (DODInstance di in RareFactory.DODInst) { if (di is DODInstance) { if (di.RareTemplate == null) { Logger.Log(LogType.Text, String.Format("DODInstance {0} has a null RareTemplate.", di.Name)); } else { Logger.Log(LogType.Item, di.RareTemplate, String.Format("DODInstance {0}: ({1}).", di.Name, di.RareTemplate.GetType().ToString())); } } } e.Mobile.SendMessage("Done."); } catch (Exception ex) { LogHelper.LogException(ex); e.Mobile.SendMessage(ex.Message); } finally { Logger.Finish(); } }
private static void MakeDeco_OnCommand(CommandEventArgs arg) { Mobile from = arg.Mobile; LogHelper Logger = new LogHelper("makedeco.log", from, true); // Loop through town regions and search out items // within foreach (Region reg in from.Map.Regions) { if (reg is GuardedRegion) { for (int pos = 0; pos < reg.Coords.Count; pos++) { if (reg.Coords[pos] is Rectangle2D) { Rectangle2D area = (Rectangle2D)reg.Coords[pos]; IPooledEnumerable eable = from.Map.GetItemsInBounds(area); foreach (object obj in eable) { if (obj is Container) { Container cont = (Container)obj; if (cont.Movable == false && cont.PlayerCrafted == false && cont.Name != "Goodwill" && !(cont.RootParent is Mobile) && !(cont is TrashBarrel) && cont.Deco == false && !(cont.IsLockedDown) && !(cont.IsSecure)) { // Exclude ransom chests if (cont.Name != null && cont.Name.ToLower().IndexOf("ransom") >= 0) { continue; } // Found one cont.Deco = true; Logger.Log(LogType.Item, cont); } } } eable.Free(); } } } } Logger.Finish(); }
private static void EventSink_Shutdown(ShutdownEventArgs e) { for (int ix = 0; ix < LogHelper.OpenLogs.Count; ix++) { LogHelper lh = LogHelper.OpenLogs[ix] as LogHelper; if (lh != null) { lh.Finish(); } } }
public static void FindItemByID_OnCommand(CommandEventArgs e) { try { if (e.Length == 1) { //erl: LogHelper class handles generic logging functionality LogHelper Logger = new LogHelper("FindItemByID.log", e.Mobile, false); int ItemId = 0; string sx = e.GetString(0).ToLower(); try { if (sx.StartsWith("0x")) { // assume hex sx = sx.Substring(2); ItemId = int.Parse(sx, System.Globalization.NumberStyles.AllowHexSpecifier); } else { // assume decimal ItemId = int.Parse(sx); } } catch { e.Mobile.SendMessage("Format: FindItemByID <ItemID>"); return; } foreach (Item ix in World.Items.Values) { if (ix is Item) { if (ix.ItemID == ItemId) { Logger.Log(LogType.Item, ix); } } } Logger.Finish(); } else { e.Mobile.SendMessage("Format: FindItemByID <ItemID>"); } } catch (Exception err) { e.Mobile.SendMessage("Exception: " + err.Message); } e.Mobile.SendMessage("Done."); }
// Does search... returns ArrayList reference for mobiles that matched public static ArrayList FindSkillMobs(SkillName skill, int elapsed) { if (elapsed == 0) { elapsed = 2; // Default } //ArrayList MobStates = NetState.Instances; List <NetState> MobStates = NetState.Instances; ArrayList MobMatches = new ArrayList(NetState.Instances.Count); // Loop through active connections' mobiles and check conditions for (int i = 0; i < MobStates.Count; ++i) { Mobile m = MobStates[i].Mobile; // If m defined & PlayerMobile, get involved (not explicit) if (m != null) { if (m is PlayerMobile) { PlayerMobile pm = (PlayerMobile)m; SkillName LastSkill = pm.LastSkillUsed; DateTime LastTime = pm.LastSkillTime; // Check time & skill, display if match if (LastSkill == skill && DateTime.Now <= (LastTime + TimeSpan.FromSeconds(elapsed * 60))) { MobMatches.Add(pm); } } } } if (MobMatches.Count > 0) { LogHelper Logger = new LogHelper("findskill.log", false, true); // Loop through matches and log before returning foreach (PlayerMobile pm in MobMatches) { Logger.Log(LogType.Mobile, pm, skill.ToString()); } Logger.Finish(); } return(MobMatches); }
public static void FindMobileByType_OnCommand(CommandEventArgs e) { try { if (e.Length == 1) { if (e == null || e.Mobile == null || e.Mobile is PlayerMobile == false) { return; } // if you are a GM the world needs to be in 'Build' mode to access this comand if (e.Mobile.AccessLevel < AccessLevel.Administrator && Core.Building == false) { e.Mobile.SendMessage("The server must be in build mode for you to access this command."); return; } PlayerMobile pm = e.Mobile as PlayerMobile; LogHelper Logger = new LogHelper("FindMobileByType.log", e.Mobile, false); string name = e.GetString(0); // reset jump table pm.JumpIndex = 0; pm.JumpList = new ArrayList(); Type tx = ScriptCompiler.FindTypeByName(name); if (tx != null) { foreach (Mobile mob in World.Mobiles.Values) { if (mob != null && !mob.Deleted && tx.IsAssignableFrom(mob.GetType())) { pm.JumpList.Add(mob); Logger.Log(LogType.Mobile, mob); } } } else { e.Mobile.SendMessage("{0} is not a recognized type.", name); } Logger.Finish(); } else { e.Mobile.SendMessage("Format: FindMobileByType <type>"); } } catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); } }
public static void LogException(Exception ex, string additionalMessage) { try { LogHelper Logger = new LogHelper("Exception.log", false); string text = String.Format("{0}\r\n{1}\r\n{2}", additionalMessage, ex.Message, ex.StackTrace); Logger.Log(LogType.Text, text); Logger.Finish(); Console.WriteLine(text); } catch { // do nothing here as we do not want to enter a "cycle of doom!" // Basically, we do not want the caller to catch an exception here, and call // LogException() again, where it throws another exception, and so forth } }
public static void TrackIt(Mobile from, string text, bool accomplice) { LogHelper Logger = new LogHelper("Cheater.log", false); Logger.Log(LogType.Mobile, from, text); if (accomplice == true) { IPooledEnumerable eable = from.GetMobilesInRange(24); foreach (Mobile m in eable) { if (m is PlayerMobile && m != from) { Logger.Log(LogType.Mobile, m, "Possible accomplice."); } } eable.Free(); } Logger.Finish(); }
public static void ComLogger_OnCommand(CommandEventArgs e) { LogHelper Logger = new LogHelper("Commoditydeed.log", true); foreach (Item m in World.Items.Values) { if (m != null) { if (m is CommodityDeed && ((CommodityDeed)m).Commodity != null) { string output = string.Format("{0}\t{1,-25}\t{2,-25}", m.Serial + ",", ((CommodityDeed)m).Commodity + ",", ((CommodityDeed)m).Commodity.Amount); Logger.Log(LogType.Text, output); } } } Logger.Finish(); }
public static void FindItemByName_OnCommand(CommandEventArgs e) { if (e.Length == 1) { LogHelper Logger = new LogHelper("FindItemByName.log", e.Mobile, false); string name = e.GetString(0).ToLower(); foreach (Item item in World.Items.Values) { if (item.Name != null && item.Name.ToLower().IndexOf(name) >= 0) { Logger.Log(LogType.Item, item); } } Logger.Finish(); } else { e.Mobile.SendMessage("Format: FindItemByName <name>"); } }
public static void On_RHFile(CommandEventArgs e) { if (e.Arguments.Length != 1) { e.Mobile.SendMessage("Usage: [LoadCont <filename>"); return; } try { int loaded = 0; int count; LogHelper log = new LogHelper(e.Arguments[0] + " LoadCont.log"); log.Log(LogType.Text, String.Format("Reload process initiated by {0}, with {1} as backup data.", e.Mobile, e.Arguments[0])); using (FileStream idxfs = new FileStream(e.Arguments[0] + ".idx", FileMode.Open, FileAccess.Read)) { using (FileStream binfs = new FileStream(e.Arguments[0] + ".bin", FileMode.Open, FileAccess.Read)) { GenericReader bin = new BinaryFileReader(new BinaryReader(binfs)); GenericReader idx = new BinaryFileReader(new BinaryReader(idxfs)); count = idx.ReadInt(); if (count == -1) { log.Log(LogType.Text, "No item data to reload."); // do nothing } else { ArrayList items = new ArrayList(count); log.Log(LogType.Text, String.Format("Attempting to reload {0} items.", count)); Type[] ctortypes = new Type[] { typeof(Serial) }; object[] ctorargs = new object[1]; for (int i = 0; i < count; i++) { string type = idx.ReadString(); Serial serial = (Serial)idx.ReadInt(); long position = idx.ReadLong(); int length = idx.ReadInt(); Type t = ScriptCompiler.FindTypeByFullName(type); if (t == null) { Console.WriteLine("Warning: Tried to load nonexistent type {0}. Ignoring item.", type); log.Log(String.Format("Warning: Tried to load nonexistent type {0}. Ignoring item.", type)); continue; } ConstructorInfo ctor = t.GetConstructor(ctortypes); if (ctor == null) { Console.WriteLine("Warning: Tried to load type {0} which has no serialization constructor. Ignoring item.", type); log.Log(String.Format("Warning: Tried to load type {0} which has no serialization constructor. Ignoring item.", type)); continue; } Item item = null; try { if (World.FindItem(serial) != null) { log.Log(LogType.Item, World.FindItem(serial), "Serial already in use!! Loading of saved item failed."); } else if (!World.IsReserved(serial)) { log.Log(String.Format("Serial {0} is not reserved!! Loading of saved item failed.", serial)); } else { ctorargs[0] = serial; item = (Item)(ctor.Invoke(ctorargs)); } } catch (Exception ex) { LogHelper.LogException(ex); Console.WriteLine("An exception occurred while trying to invoke {0}'s serialization constructor.", t.FullName); Console.WriteLine(ex.ToString()); log.Log(String.Format("An exception occurred while trying to invoke {0}'s serialization constructor.", t.FullName)); log.Log(ex.ToString()); } if (item != null) { World.FreeSerial(serial); World.AddItem(item); items.Add(new object[] { item, position, length }); log.Log(String.Format("Successfully created item {0}", item)); } } for (int i = 0; i < items.Count; i++) { object[] entry = (object[])items[i]; Item item = entry[0] as Item; long position = (long)entry[1]; int length = (int)entry[2]; if (item != null) { bin.Seek(position, SeekOrigin.Begin); try { item.Deserialize(bin); // take care of parent hierarchy object p = item.Parent; if (p is Item) { ((Item)p).RemoveItem(item); item.Parent = null; ((Item)p).AddItem(item); } else if (p is Mobile) { ((Mobile)p).RemoveItem(item); item.Parent = null; ((Mobile)p).AddItem(item); } else { item.Delta(ItemDelta.Update); } item.ClearProperties(); object rp = item.RootParent; if (rp is Item) { ((Item)rp).UpdateTotals(); } else if (rp is Mobile) { ((Mobile)rp).UpdateTotals(); } else { item.UpdateTotals(); } if (bin.Position != (position + length)) { throw new Exception(String.Format("Bad serialize on {0}", item)); } log.Log(LogType.Item, item, "Successfully loaded."); loaded++; } catch (Exception ex) { LogHelper.LogException(ex); Console.WriteLine("Caught exception while deserializing {0}:", item); Console.WriteLine(ex.ToString()); Console.WriteLine("Deleting item."); log.Log(String.Format("Caught exception while deserializing {0}:", item)); log.Log(ex.ToString()); log.Log("Deleting item."); item.Delete(); } } } } idx.Close(); bin.Close(); } } Console.WriteLine("Attempted to load {0} items: {1} loaded, {2} failed.", count, loaded, count - loaded); log.Log(String.Format("Attempted to load {0} items: {1} loaded, {2} failed.", count, loaded, count - loaded)); e.Mobile.SendMessage("Attempted to load {0} items: {1} loaded, {2} failed.", count, loaded, count - loaded); log.Finish(); } catch (Exception ex) { LogHelper.LogException(ex); Console.WriteLine(ex.ToString()); e.Mobile.SendMessage("Exception: {0}", ex.Message); } }
public void GoToJail() { if (m_Player == null || m_Player.Deleted) { return; } Account acct = m_Player.Account as Account; int sentence = 12; // 12 hour minimum sentence if (Trouble == true) { sentence = 2; // two hour sentance for troublemakets } else { foreach (AccountComment comm in acct.Comments) { if (comm.Content.IndexOf("Jailed for ") != -1 && comm.Content.IndexOf("Tag count: ") != -1) { sentence += 12; // 12 hours for each previous [jail'ing } else if (comm.Content.IndexOf(" : reported using the [macroer command") != -1) { sentence += 12; // 12 hours for every time they were caught resource botting } } } // stable the players pets StablePets(m_Player); // move to jail Point3D destPoint = Jail.GetCell(m_Cell); m_Player.MoveToWorld(destPoint, Map.Felucca); // handle jailing of logged out players if (m_Player.NetState == null) { m_Player.LogoutLocation = destPoint; m_Player.Map = Map.Internal; } JailExitGate.AddInmate(m_Player, sentence); m_Player.SendMessage("You have been jailed for {0} hours.", sentence); LogHelper Logger = new LogHelper("jail.log", false, true); Logger.Log(LogType.Mobile, m_Player, string.Format("{0}:{1}:{2}:{3}", "SYSTEM", m_Cell, m_Comment, sentence)); Logger.Finish(); if (Trouble == true) { acct.Comments.Add(new AccountComment("SYSTEM", DateTime.Now + "\nTag count: " + (acct.Comments.Count + 1) + "\nJailedTroubleMaker for " + sentence + " hours. Reason: " + m_Comment)); } else { acct.Comments.Add(new AccountComment("SYSTEM", DateTime.Now + "\nTag count: " + (acct.Comments.Count + 1) + "\nJailed for " + sentence + " hours. Reason: " + m_Comment)); } }
private static void DoCommand(CommandEventArgs e) { Dictionary <Serial, Serial> dict = new Dictionary <Serial, Serial>(); string logname = "IntMapOrphan.log"; if (e.ArgString.ToLower() == "list") { LoadDict(dict); LogHelper Logger = new LogHelper(logname, e.Mobile, true); int orphans = 0; foreach (Serial serial in dict.Keys) { Item item = World.FindItem(serial); Mobile mob = World.FindMobile(serial); if (item != null) { Logger.Log(LogType.Item, item, String.Format("Managed by Spawner {0}", dict[serial])); } if (mob != null) { Logger.Log(LogType.Mobile, mob, String.Format("Managed by Spawner {0}", dict[serial])); } if (dict[serial] == Serial.MinusOne) { orphans++; } } e.Mobile.SendMessage(String.Format("{0} template objects found with {1} orphans.", dict.Count, orphans)); e.Mobile.SendMessage(String.Format("Please see {0} for a list of template/spawner pairs. ", logname)); Logger.Finish(); } else if (e.ArgString.ToLower() == "mark") { LoadDict(dict); LogHelper Logger = new LogHelper(logname, e.Mobile, true); int orphans = 0; foreach (Serial serial in dict.Keys) { Item item = World.FindItem(serial); Mobile mob = World.FindMobile(serial); if (item != null && dict[serial] == Serial.MinusOne) { item.IsIntMapStorage = false; item.SpawnerTempItem = false; Logger.Log(LogType.Item, item, "Set to decay."); } if (mob != null && dict[serial] == Serial.MinusOne) { mob.SpawnerTempMob = false; Logger.Log(LogType.Mobile, mob, "Set to decay."); } if (dict[serial] == Serial.MinusOne) { orphans++; } } e.Mobile.SendMessage(String.Format("{0} template objects found with {1} orphans.", dict.Count, orphans)); e.Mobile.SendMessage(String.Format("Please see {0} for a list cleared templates. ", logname)); Logger.Finish(); } else { e.Mobile.SendMessage("Usage: IntMapOrphan List | Mark(for cleanup)"); } }
public static void AddressDump_OnCommand(CommandEventArgs e) { Mobile from = e.Mobile; // check arguments if (e.Length < 1) { Usage(from); return; } int iChecked = 0; int Reminders = 0; try { // loop through the accouints looking for current users ArrayList results = new ArrayList(); // assume DaysActive if (e.Length == 1 && LooksLikeInt(e.GetString(0))) { int days = 0; try { days = Convert.ToInt32(e.GetString(0)); } catch { Usage(from); return; } foreach (Account acct in Accounts.Table.Values) { iChecked++; // logged in the last n days. if (Server.Engines.CronScheduler.EmailHelpers.RecentLogin(acct, days) == true) { if (ValidEmail(acct.EmailAddress)) { Reminders++; results.Add(acct.EmailAddress); } } } } // assume activations since date else { string buff = null; for (int ix = 0; ix < e.Length; ix++) { buff += e.GetString(ix) + " "; } DateTime Since; try { Since = DateTime.Parse(buff); } catch { Usage(from); return; } foreach (Account acct in Accounts.Table.Values) { iChecked++; // account created since... if (acct.Created >= Since && acct.EmailAddress != null) { if (ValidEmail(acct.EmailAddress)) { Reminders++; results.Add(acct.EmailAddress); } } } } if (Reminders > 0) { from.SendMessage("Logging {0} email address(es).", Reminders); LogHelper Logger = new LogHelper("accountEmails.log", true); foreach (object ox in results) { string address = ox as string; if (address == null) { continue; } Logger.Log(LogType.Text, address); } Logger.Finish(); } } catch (Exception ex) { LogHelper.LogException(ex); System.Console.WriteLine("Exception Caught in generic emailer: " + ex.Message); System.Console.WriteLine(ex.StackTrace); } return; }
public static void FindMobile_OnCommand(CommandEventArgs e) { if (e.Length > 1) { LogHelper Logger = new LogHelper("findMobile.log", e.Mobile, false); // Extract property & value from command parameters string sProp = e.GetString(0); string sVal = ""; if (e.Length > 2) { sVal = e.GetString(1); // Concatenate the strings for (int argi = 2; argi < e.Length; argi++) { sVal += " " + e.GetString(argi); } } else { sVal = e.GetString(1); } Regex PattMatch = new Regex("= \"*" + sVal, RegexOptions.IgnoreCase); // Loop through assemblies and add type if has property Type[] types; Assembly[] asms = ScriptCompiler.Assemblies; ArrayList MatchTypes = new ArrayList(); for (int i = 0; i < asms.Length; ++i) { types = ScriptCompiler.GetTypeCache(asms[i]).Types; foreach (Type t in types) { if (typeof(Mobile).IsAssignableFrom(t)) { // Reflect type PropertyInfo[] allProps = t.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo prop in allProps) { if (prop.Name.ToLower() == sProp.ToLower()) { MatchTypes.Add(t); } } } } } // Loop items and check vs. types foreach (Mobile m in World.Mobiles.Values) { Type t = m.GetType(); bool match = false; foreach (Type MatchType in MatchTypes) { if (t == MatchType) { match = true; break; } } if (match == false) { continue; } // Reflect instance of type (matched) if (PattMatch.IsMatch(Properties.GetValue(e.Mobile, m, sProp))) { Logger.Log(LogType.Mobile, m); } } Logger.Finish(); } else { // Badly formatted e.Mobile.SendMessage("Format: FindMobile <property> <value>"); } }
public static void WipeMagicToTarget(Mobile from, object target) { try { Region region = null; if (target is HouseSign) { BaseHouse bh = (target as HouseSign).Structure; if (bh == null) { from.SendMessage("This house sign is not associated with any house."); return; } region = bh.Region; if (region == null) { from.SendMessage("This house is not associated with any region."); return; } } else if (target is TownshipStone) { region = (target as TownshipStone).MyRegion; if (region == null) { from.SendMessage("This township stone is not associated with any region."); return; } } from.SendMessage("Searching for runes marked for this region"); LogHelper Logger = new LogHelper("WipeMagicToTarget.log", from, false); foreach (Item item in World.Items.Values) { if (item is RecallRune) { RecallRune rune = (RecallRune)item; if (rune.Marked && rune.TargetMap != null && region.Contains(rune.Target)) { object root = item.RootParent; if (root is Mobile) { if (((Mobile)root).AccessLevel < AccessLevel.GameMaster) { Logger.Log(LogType.Item, rune, rune.Description); rune.Target = new Point3D(0, 0, 0); } } else { Logger.Log(LogType.Item, rune, rune.Description); rune.Target = new Point3D(0, 0, 0); } } } else if (item is Moonstone) { Moonstone stone = (Moonstone)item; if (stone.Marked && region.Contains(stone.Destination)) { object root = item.RootParent; if (root is Mobile) { if (((Mobile)root).AccessLevel < AccessLevel.GameMaster) { Logger.Log(LogType.Item, stone, stone.Description); stone.Destination = new Point3D(0, 0, 0); } } else { Logger.Log(LogType.Item, stone, stone.Description); stone.Destination = new Point3D(0, 0, 0); } } } else if (item is Runebook) { Runebook book = (Runebook)item; for (int i = 0; i < book.Entries.Count; ++i) { RunebookEntry entry = (RunebookEntry)book.Entries[i]; if (entry.Map != null && region.Contains(entry.Location)) { object root = item.RootParent; if (root is Mobile) { if (((Mobile)root).AccessLevel < AccessLevel.GameMaster) { Logger.Log(LogType.Item, item, string.Format("{0}:{1}:{2}", i, entry.Description, book.Description)); entry.Location = new Point3D(0, 0, 0); } } else { Logger.Log(LogType.Item, item, string.Format("{0}:{1}:{2}", i, entry.Description, book.Description)); entry.Location = new Point3D(0, 0, 0); } } } } } Logger.Finish(); from.SendMessage("Done searching for runes withing house regions"); // okay, now turn off all house security //int houseschecked = Server.Multis.BaseHouse.SetSecurity(false); //e.Mobile.SendMessage("Setting {0} houses to insecure",houseschecked); return; } catch (Exception exc) { from.SendMessage("Exception in [findrunes -- see console."); System.Console.WriteLine("Exception in [findrunes: {0}", exc.Message); System.Console.WriteLine(exc.StackTrace); return; } }
public void GoToPrison() { try { if (m_Player == null || m_Player.Deleted) { return; } Account acct = m_Player.Account as Account; // stable the players pets StablePets(m_Staff, m_Player); // drop holding Item held = m_Player.Holding; if (held != null) { held.ClearBounce(); if (m_Player.Backpack != null) { m_Player.Backpack.DropItem(held); } } m_Player.Holding = null; // move their items to the bank, overload if needed Backpack bag = new Backpack(); ArrayList equip = new ArrayList(m_Player.Items); if (m_Player.Backpack != null) { // count clothing items int WornCount = 0; foreach (Item i in equip) { if (Moongate.RestrictedItem(m_Player, i) == false) { continue; // not clothes } else { WornCount++; } } // Unequip any items being worn foreach (Item i in equip) { if (Moongate.RestrictedItem(m_Player, i) == false) { continue; } else { m_Player.Backpack.DropItem(i); } } // Get a count of all items in the player's backpack. ArrayList items = new ArrayList(m_Player.Backpack.Items); // Drop our new bag in the player's bank m_Player.BankBox.DropItem(bag); // Run through all items in player's pack, move them to the bag we just dropped in the bank foreach (Item i in items) { m_Player.Backpack.RemoveItem(i); bag.DropItem(i); } } // handle imprisoning of logged out players m_Player.MoveToWorld(m_Location, Map.Felucca); if (m_Player.NetState == null) { m_Player.LogoutLocation = m_Location; m_Player.Map = Map.Internal; } // make them an inmate m_Player.Inmate = true; // Give them a Deathrobe, Stinger dagger, and a blank spell book if (m_Player.Alive) { Item robe = new Server.Items.DeathRobe(); if (!m_Player.EquipItem(robe)) { robe.Delete(); } } Item aiStinger = new Server.Items.AIStinger(); if (!m_Player.AddToBackpack(aiStinger)) { aiStinger.Delete(); } Item spellbook = new Server.Items.Spellbook(); if (!m_Player.AddToBackpack(spellbook)) { spellbook.Delete(); } m_Player.ShortTermCriminalCounts += 3; // how long you will stay m_Player.LongTermCriminalCounts++; // how many times you've been to prison if (!m_Player.Alive && m_Player.NetState != null) { m_Player.CloseGump(typeof(Server.Gumps.ResurrectGump)); m_Player.SendGump(new Server.Gumps.ResurrectGump(m_Player, Server.Gumps.ResurrectMessage.Healer)); } int sentence = (int)m_Player.ShortTermCriminalCounts * 4; // decay time in prison is 4 hours per count m_Player.SendMessage("You have been imprisoned for {0} hours.", sentence); m_Staff.SendMessage("{0} has been imprisoned for {1} hours.", m_Player.Name, sentence); LogHelper Logger = new LogHelper("Prison.log", false, true); Logger.Log(LogType.Mobile, m_Player, string.Format("{0}:{1}:{2}:{3}", m_Staff.Name, m_Staff.Location, m_Comment, sentence)); Logger.Finish(); Commands.CommandLogging.WriteLine(m_Staff, "{0} imprisoned {1}(Username: {2}) for {4} hours with reason: {3}.", m_Staff.Name, m_Player.Name, acct.Username, m_Comment, sentence); acct.Comments.Add(new AccountComment(m_Staff.Name, DateTime.Now + "\nTag count: " + (acct.Comments.Count + 1) + "\nImprisoned for " + sentence + " hours. Reason: " + m_Comment)); } catch (Exception ex) { LogHelper.LogException(ex); } }
public static void FindItemByType_OnCommand(CommandEventArgs e) { try { if (e == null || e.Mobile == null || e.Mobile is PlayerMobile == false) { return; } string sProp = null; string sVal = null; string name = null; if (e.Length >= 1) { name = e.GetString(0); if (e.Length >= 2) { sProp = e.GetString(1); } if (e.Length >= 3) { sVal = e.GetString(2); } // if you are a GM the world needs to be in 'Build' mode to access this comand if (e.Mobile.AccessLevel < AccessLevel.Administrator && Core.Building == false) { e.Mobile.SendMessage("The server must be in build mode for you to access this command."); return; } PlayerMobile pm = e.Mobile as PlayerMobile; LogHelper Logger = new LogHelper("FindItemByType.log", e.Mobile, false); // reset jump table pm.JumpIndex = 0; pm.JumpList = new ArrayList(); Type tx = ScriptCompiler.FindTypeByName(name); if (tx != null) { foreach (Item item in World.Items.Values) { if (item != null && !item.Deleted && tx.IsAssignableFrom(item.GetType())) { // read the properties PropertyInfo[] allProps = item.GetType().GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public); if (sProp != null) { foreach (PropertyInfo prop in allProps) { if (prop.Name.ToLower() == sProp.ToLower()) { bool ok = false; string val = Properties.GetValue(e.Mobile, item, sProp); // match a null value if ((val == null || val.Length == 0 || val.EndsWith("(-null-)", StringComparison.CurrentCultureIgnoreCase)) && (sVal == null || sVal.Length == 0)) { ok = true; } // see if the property matches else if (val != null && sVal != null) { string[] toks = val.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (toks.Length >= 3 && toks[2].Equals(sVal, StringComparison.CurrentCultureIgnoreCase)) { ok = true; } else { break; } } if (ok) { pm.JumpList.Add(item); Logger.Log(LogType.Item, item); break; } } } } else { // no prop to check, everything matches pm.JumpList.Add(item); Logger.Log(LogType.Item, item); } } } } else { e.Mobile.SendMessage("{0} is not a recognized type.", name); } Logger.Finish(); } else { e.Mobile.SendMessage("Format: FindItemByType <type>"); } } catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); } }
protected override void OnTarget(Mobile from, object targ) { PlayerMobile pm = targ as PlayerMobile; if (pm == null) { from.SendMessage("Only players can be sent to jail."); return; } Account acct = pm.Account as Account; int sentence = 12; // 12 hour minimum sentence if (Trouble == true) { sentence = 2; // two hour sentance for troublemakets } else { foreach (AccountComment comm in acct.Comments) { if (comm.Content.IndexOf("Jailed for ") != -1 && comm.Content.IndexOf("Tag count: ") != -1) { sentence += 12; // 12 hours for each previous [jail'ing } else if (comm.Content.IndexOf(" : reported using the [macroer command") != -1) { sentence += 12; // 12 hours for every time they were caught resource botting } } } // stable the players pets StablePets(from, pm); // handle jailing of logged out players Point3D destPoint = Jail.GetCell(m_Cell); pm.MoveToWorld(destPoint, Map.Felucca); if (pm.NetState == null) { pm.LogoutLocation = destPoint; pm.Map = Map.Internal; } JailExitGate.AddInmate(pm, sentence); pm.SendMessage("You have been jailed for {0} hours.", sentence); from.SendMessage("{0} has been jailed for {1} hours.", pm.Name, sentence); LogHelper Logger = new LogHelper("jail.log", false, true); Logger.Log(LogType.Mobile, pm, string.Format("{0}:{1}:{2}:{3}", from.Name, m_Cell, m_Comment, sentence)); Logger.Finish(); Commands.CommandLogging.WriteLine(from, "{0} jailed {1}(Username: {2}) into cell {3} for {5} hours with reason: {4}.", from.Name, pm.Name, acct.Username, m_Cell, m_Comment, sentence); if (Trouble == true) { acct.Comments.Add(new AccountComment(from.Name, DateTime.Now + "\nTag count: " + (acct.Comments.Count + 1) + "\nJailedTroubleMaker for " + sentence + " hours. Reason: " + m_Comment)); } else { acct.Comments.Add(new AccountComment(from.Name, DateTime.Now + "\nTag count: " + (acct.Comments.Count + 1) + "\nJailed for " + sentence + " hours. Reason: " + m_Comment)); } }
public override void Execute(CommandEventArgs e, object obj) { try { Item item = obj as Item; if (!RareFactory.InUse) { if (e.Arguments.Length == 4) { int iRarity = 0; if (int.TryParse(e.Arguments[1], out iRarity) == true && iRarity >= 0 && iRarity <= 10) { DODGroup match; if ((match = FindGroup(e.Arguments[0], iRarity)) != null) { int iStartIndex = 0; if (int.TryParse(e.Arguments[2], out iStartIndex) == true && iStartIndex > 0 && iStartIndex <= 255) { int iLastIndex = 0; if (int.TryParse(e.Arguments[3], out iLastIndex) == true && iLastIndex > 0 && iLastIndex <= 255) { if (item != null) { LogHelper Logger = null; try { DODInstance di = RareFactory.AddRare(match, item); // rarity is defined by the group di.LastIndex = (short)iLastIndex; di.StartIndex = (short)iStartIndex; di.StartDate = DateTime.MinValue; // valid now di.EndDate = DateTime.MaxValue; // valid forever // default the name to the name of the item if (item.Name != null && item.Name != "") { di.Name = item.Name; } else { di.Name = item.GetType().Name; } AddResponse("Sucessfully defined new rare '" + di.Name + "'!"); } catch (Exception ex) { LogHelper.LogException(ex); e.Mobile.SendMessage(ex.Message); } finally { if (Logger != null) { Logger.Finish(); } } } else { LogFailure("Only an item may be converted into a rare."); } } else { LogFailure("The LastIndex must be a numeric value between 1 and 255 inclusive."); } } else { LogFailure("The StartIndex must be a numeric value between 1 and 255 inclusive."); } } else { LogFailure(String.Format("Could not find the group \"{0}\" with a rarity of {1}", e.Arguments[0], iRarity)); } } else { LogFailure("The rarity must be a numeric value between 0 and 10 inclusive."); } } else { LogFailure("AddRare sGroup iRarity iStartIndex iLastIndex"); } } else { LogFailure("Rare Factory is currently being configured by another administrator! Please wait. "); } } catch (Exception exe) { LogHelper.LogException(exe); e.Mobile.SendMessage(exe.Message); } }
public static void RetargetRunes_OnCommand(CommandEventArgs e) { ArrayList regionList = new ArrayList(); if (HaveRegions(e, regionList)) { try { LogHelper Logger = new LogHelper("retarget.log", e.Mobile, true); foreach (Item item in World.Items.Values) { if (item is RecallRune) { RecallRune rune = (RecallRune)item; for (int ix = 0; ix < regionList.Count; ix++) { if (rune.Marked && rune.TargetMap != null && (regionList[ix] as Region).Contains(rune.Target)) { object root = item.RootParent; if (root is Mobile) { if (((Mobile)root).AccessLevel < AccessLevel.GameMaster) { Logger.Log(LogType.Item, rune, rune.Description); rune.Target = new Point3D(0, 0, 0); } } else { Logger.Log(LogType.Item, rune, rune.Description); rune.Target = new Point3D(0, 0, 0); } } } } else if (item is Moonstone) { Moonstone stone = (Moonstone)item; for (int ix = 0; ix < regionList.Count; ix++) { if (stone.Marked && (regionList[ix] as Region).Contains(stone.Destination)) { object root = item.RootParent; if (root is Mobile) { if (((Mobile)root).AccessLevel < AccessLevel.GameMaster) { Logger.Log(LogType.Item, stone, stone.Description); stone.Destination = new Point3D(0, 0, 0); } } else { Logger.Log(LogType.Item, stone, stone.Description); stone.Destination = new Point3D(0, 0, 0); } } } } else if (item is Runebook) { Runebook book = (Runebook)item; for (int ix = 0; ix < regionList.Count; ix++) { for (int i = 0; i < book.Entries.Count; ++i) { RunebookEntry entry = (RunebookEntry)book.Entries[i]; if (entry.Map != null && (regionList[ix] as Region).Contains(entry.Location)) { object root = item.RootParent; if (root is Mobile) { if (((Mobile)root).AccessLevel < AccessLevel.GameMaster) { Logger.Log(LogType.Item, item, string.Format("{0}:{1}:{2}", i, entry.Description, book.Description)); entry.Location = new Point3D(0, 0, 0); } } else { Logger.Log(LogType.Item, item, string.Format("{0}:{1}:{2}", i, entry.Description, book.Description)); entry.Location = new Point3D(0, 0, 0); } } } } } } Logger.Finish(); e.Mobile.SendMessage("DONE search for runes."); return; } catch (Exception exc) { LogHelper.LogException(exc); e.Mobile.SendMessage("Exception in [Retarget -- see console."); System.Console.WriteLine("Exception in [Retarget: {0}", exc.Message); System.Console.WriteLine(exc.StackTrace); return; } } else { e.Mobile.SendMessage("Usage: [Retarget <-regionName|-type|-point|-RegionUID> <name|type|point|uid>"); } }
public static void FindItemByType_OnCommand(CommandEventArgs e) { try { if (e == null || e.Mobile == null || e.Mobile is PlayerMobile == false) { return; } string name = null; if (e.Length >= 1) { name = e.GetString(0); // if you are a GM the world needs to be in 'Build' mode to access this comand if (e.Mobile.AccessLevel < AccessLevel.Administrator && Core.Building == false) { e.Mobile.SendMessage("The server must be in build mode for you to access this command."); return; } PlayerMobile pm = e.Mobile as PlayerMobile; LogHelper Logger = new LogHelper("FindNPCResourceByType.log", e.Mobile, false); // reset jump table pm.JumpIndex = 0; pm.JumpList = new ArrayList(); Type tx = ScriptCompiler.FindTypeByName(name); if (tx != null) { foreach (Mobile mob in World.Mobiles.Values) { if (mob is BaseVendor == false) { continue; } BaseVendor vendor = mob as BaseVendor; if (vendor.Inventory == null || vendor.Inventory.Count == 0) { continue; } foreach (object ox in vendor.Inventory) { if (ox is SBInfo == false) { continue; } SBInfo sbi = ox as SBInfo; if (sbi.BuyInfo == null || sbi.BuyInfo.Count == 0) { continue; } ArrayList bi = sbi.BuyInfo; foreach (GenericBuyInfo gbi in bi) { if (tx.IsAssignableFrom(gbi.Type)) { pm.JumpList.Add(vendor); Logger.Log(LogType.Mobile, vendor); } } } } } else { e.Mobile.SendMessage("{0} is not a recognized type.", name); } Logger.Finish(); } else { e.Mobile.SendMessage("Format: FindNPCResourceByType <type>"); } } catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); } }
private static void InvBox_Callback(Mobile from, Map map, Point3D start, Point3D end, object state) { LogHelper Logger = new LogHelper("inventory.log", true); Logger.Log(LogType.Text, string.Format("{0}\t{1,-25}\t{7,-25}\t{2,-25}\t{3,-20}\t{4,-20}\t{5,-20}\t{6,-20}", "Qty ---", "Item ------------", "Damage / Protection --", "Durability -----", "Accuracy -----", "Exceptional", "Slayer ----", "Serial ----")); // Create rec and retrieve items within from bounding box callback // result Rectangle2D rect = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1); IPooledEnumerable eable = map.GetItemsInBounds(rect); // Loop through and add objects returned foreach (object obj in eable) { if (m_ItemType == null || obj is BaseContainer) { AddInv(obj); } else { Type ot = obj.GetType(); if (ot.IsSubclassOf(m_ItemType) || ot == m_ItemType) { AddInv(obj); } } } eable.Free(); m_Inv.Sort(); // Sort results // Loop and log foreach (InvItem ir in m_Inv) { // ir.m_description += String.Format(" ({0})", it.Serial.ToString()); string output = string.Format("{0}\t{1,-25}\t{7,-25}\t{2,-25}\t{3,-20}\t{4,-20}\t{5,-20}\t{6,-20}", ir.m_count + ",", (ir.GetDescription()) + ",", (ir.m_damage != null ? ir.m_damage : "N/A") + ",", (ir.m_durability != null ? ir.m_durability : "N/A") + ",", (ir.m_accuracy != null ? ir.m_accuracy : "N/A") + ",", (ir.m_quality != null ? ir.m_quality : "N/A") + ",", (ir.m_slayer != null ? ir.m_slayer : "N/A") + ",", ir.m_serial.ToString() ); Logger.Log(LogType.Text, output); if (m_verbose) { output = string.Format("{0}{1}{7}{2}{3}{4}{5}{6}", ir.m_count + ",", (ir.GetDescription()) + ",", (ir.m_damage != null ? ir.m_damage : "N/A") + ",", (ir.m_durability != null ? ir.m_durability : "N/A") + ",", (ir.m_accuracy != null ? ir.m_accuracy : "N/A") + ",", (ir.m_quality != null ? ir.m_quality : "N/A") + ",", (ir.m_slayer != null ? ir.m_slayer : "N/A") + ",", ir.m_serial.ToString() ); from.SendMessage(output); } } Logger.Count--; // count-1 for header Logger.Finish(); }