public override bool OnDragDrop(Mobile from, Item dropped) { if (dropped is HouseDeed) { HouseDeed deed = (HouseDeed)dropped; int price = ComputePriceFor(deed); if (price > 0) { if (Banker.Deposit(from, price)) { // For the deed I have placed gold in your bankbox : PublicOverheadMessage(MessageType.Regular, 0x3B2, 1008000, AffixType.Append, price.ToString(), ""); deed.Delete(); return(true); } else { PublicOverheadMessage(MessageType.Regular, 0x3B2, 500390); // Your bank box is full. return(false); } } else { PublicOverheadMessage(MessageType.Regular, 0x3B2, 500607); // I'm not interested in that. return(false); } } return(base.OnDragDrop(from, dropped)); }
public override bool OnDragDrop(Mobile from, Item dropped) { if (!TestCenter.Enabled && dropped is HouseDeed) { Faction fact = Faction.Find(from); if (FactionAllegiance != null && fact != null && FactionAllegiance != fact) { Say("I will not do business with the enemy!"); } else { HouseDeed deed = (HouseDeed)dropped; int price = ComputePriceFor(deed); if (price > 0) { if (Banker.Deposit(from, price)) { // For the deed I have placed gold in your bankbox : PublicOverheadMessage(MessageType.Regular, 0x3B2, 1008000, AffixType.Append, price.ToString(), ""); deed.Delete(); return(true); } else { PublicOverheadMessage(MessageType.Regular, 0x3B2, 500390); // Your bank box is full. return(false); } } else { PublicOverheadMessage(MessageType.Regular, 0x3B2, 500607); // I'm not interested in that. return(false); } } } return(base.OnDragDrop(from, dropped)); }
public static void ImportWorld() { ArrayList retry = new ArrayList(), houses = new ArrayList(); int count = 0; foreach (Account a in Accounts.List.Values) { for (int i = 0; i < 6; i++) { if (a[i] != null) { a[i].Player = false; } a[i] = null; } } using (StreamReader r = new StreamReader("world.txt", System.Text.Encoding.ASCII)) { string line; IEntity curObj = null; Mobile prevMob = null; Type curType = null; while ((line = r.ReadLine()) != null) { if (string.IsNullOrEmpty(line)) { continue; } string[] parts = line.Split(new char[] { '=' }, 3, StringSplitOptions.None); if (parts.Length != 3) { Console.WriteLine("Warning! Wrong number of fields: {0} -- {1}", parts.Length, line); continue; } /*if (parts[0] == "Profile") * { * long prevPos = r.BaseStream.Position; * while ((line = r.ReadLine()) != null) * { * string[] split = line.Split(new char[] { '=' }, 3, StringSplitOptions.None); * * if (split.Length != 3) * { * parts[2] += "\n" + line; * prevPos = r.BaseStream.Position; * } * else * { * r.BaseStream.Seek(prevPos, SeekOrigin.Begin); * break; * } * } * }*/ try { if (parts[0] == "Object") { PostProcess(curObj); parts[1] = TranslateType(parts[1]); curObj = null; curType = ScriptCompiler.FindTypeByFullName(parts[1], true); if (curType == null) { InsertError("{0}: Type missing", parts[1]); continue; } Serial oldSer = Utility.ToInt32(parts[2]); /*if (IsType(curType, typeof(Item))) * Serial.NewItem = Utility.ToInt32(parts[2]) - 1; * else if (IsType(curType, typeof(Mobile) )) * Serial.NewMobile = Utility.ToInt32(parts[2]) - 1; */ try { curObj = Activator.CreateInstance(curType, new object[0]) as IEntity; } catch { } if (curObj == null) { try { if (curType == typeof(BankBox) && prevMob != null) { curObj = new BankBox(prevMob); } //curObj = Activator.CreateInstance( curType, new object[1]{prevMob} ) as IEntity; } catch { } if (curObj == null) { InsertError("{0}: Unable to construct", parts[1]); continue; } } if (curObj is Mobile) { _Mobiles[oldSer] = curObj; prevMob = (Mobile)curObj; } else if (curObj is Item) { _Items[oldSer] = curObj; } count++; if ((count % 10000) == 0) { Console.WriteLine("Completed {0} objects so far", count - 1); } } else if (parts[0] == "House") { string type, loc, map, owner; type = r.ReadLine(); loc = r.ReadLine(); map = r.ReadLine(); owner = r.ReadLine(); houses.Add(new string[] { type, loc, map, owner }); } else if (parts[0] == "Skills") { Mobile m = FindMobile(Utility.ToInt32(parts[2])); while ((line = r.ReadLine()) != null) { if (line == "EndSkills" || line == "") { break; } parts = line.Split(new char[] { '=' }, 3, StringSplitOptions.None); if (parts.Length != 3) { continue; } SkillName name = (SkillName)Enum.Parse(typeof(SkillName), parts[0]); m.Skills[name].BaseFixedPoint = Utility.ToInt32(parts[2]); } } else if (parts[0] == "RuneBookEntry") { if (curObj is Runebook) { Point3D pt = Point3D.Parse(parts[1]); bool okay = true; if (Spells.SpellHelper.IsAnyT2A(Map.Felucca, pt)) { okay = false; } else if (Spells.SpellHelper.IsFeluccaDungeon(Map.Felucca, pt)) { Regions.DungeonRegion reg = Region.Find(pt, Map.Felucca) as Regions.DungeonRegion; if (reg != null) { if (reg.Name == "Fire" || reg.Name == "Ice" || reg.Name == "Orc Cave" || reg.Name == "Terathan Keep") { okay = false; } } } if (okay) { ((Runebook)curObj).Entries.Add(new RunebookEntry(pt, Map.Felucca, parts[2], null)); } } } else if (curObj != null) { DoProperty(curObj, curType, parts, retry); } } catch (Exception e) { InsertError("Exception '{0}' for line '{1}'", e.Message, line); } } PostProcess(curObj); } foreach (object[] list in retry) { DoProperty(list[0], list[1] as Type, list[2] as string[], null); } foreach (string[] list in houses) { list[0] = TranslateType(list[0]); Type deedType = ScriptCompiler.FindTypeByFullName(list[0], true); Point3D loc = Point3D.Parse(list[1]); Map map = Map.Parse(list[2]); Mobile owner = FindMobile(Utility.ToInt32(list[3])); if (deedType == null || !deedType.IsSubclassOf(typeof(HouseDeed))) { InsertError("{0}: Type missing\n", list[0]); continue; } if (owner == null || map == null || map == Map.Internal || loc == Point3D.Zero) { InsertError("House properties messed up (owner probably missing)\n"); continue; } HouseDeed deed = null; try { deed = Activator.CreateInstance(deedType, new object[0]) as HouseDeed; } catch { } if (deed == null) { InsertError("Failed to create deed {0}\n", list[0]); continue; } BaseHouse house = deed.GetHouse(owner); house.MoveToWorld(loc, map); deed.Delete(); } Console.WriteLine("Import complete, imported {0} objects.", count); Console.WriteLine("\nErrors:"); foreach (string err in _Errors.Keys) { Console.WriteLine("{0} (Count={1})", err, _Errors[err]); } Console.WriteLine("Done. Saving..."); World.Save(); Console.WriteLine("Press enter to quit. REMOVE THIS SCRIPT BEFORE RUNNING THE SERVER AGAIN"); Console.ReadLine(); System.Diagnostics.Process.GetCurrentProcess().Kill(); }
private static void OnCalculateAndWrite(Mobile cmdmob, int maxtoprint, bool bSupressNames, bool bSupressStaff, bool bIndicateBanned) { if (bInProcess == true) { System.Console.WriteLine("Got GoldTracker call when already processing."); return; } bInProcess = true; DateTime startDateTime = DateTime.Now; if (!Directory.Exists(OUTPUT_DIRECTORY)) { Directory.CreateDirectory(OUTPUT_DIRECTORY); } try { string initmsg = string.Format("Tracking Gold...outputing top {0}", maxtoprint); System.Console.WriteLine(initmsg); SM(cmdmob, initmsg); #if false using (StreamWriter op = new StreamWriter(OUTPUT_DIRECTORY + "/" + OUTPUT_FILE)) { op.WriteLine("<HTML><BODY>"); op.WriteLine("<TABLE BORDER=1 WIDTH=90%><TR>"); op.WriteLine("<TD>Account</TD><TD>Character</TD><TD>Total Worth</TD><TD>Backpack Gold</TD><TD>Bank Gold</TD><TD>House Gold</TD><TD>Number of Houses</TD><TD>Vendor Gold</TD>"); op.WriteLine("</TR>"); foreach (Account acct in Accounts.Table.Values) { string acctname = acct.Username; //System.Console.WriteLine(acctname); //iterate through characters: for (int i = 0; i < 5; ++i) { if (acct[i] != null) { PlayerMobile player = (PlayerMobile)acct[i]; op.WriteLine("<TR><TD><B>" + acctname + "</B></TD>"); op.WriteLine("<TD>" + player.Name + "</TD>"); Container backpack = player.Backpack; BankBox bank = player.BankBox; int backpackgold = 0; int bankgold = 0; //BACKPACK backpackgold = GetGoldInContainer(backpack); //BANK bankgold = GetGoldInContainer(bank); //house? int housetotal = 0; ArrayList list = Multis.BaseHouse.GetHouses(player); for (int j = 0; j < list.Count; ++j) { if (list[j] is BaseHouse) { BaseHouse house = (BaseHouse)list[j]; housetotal += GetGoldInHouse(house); } } //vendors int vendortotal = 0; ArrayList vendors = GetVendors(player); for (int j = 0; j < vendors.Count; j++) { if (vendors[j] is PlayerVendor) { PlayerVendor pv = vendors[j] as PlayerVendor; vendortotal += pv.HoldGold; } } op.WriteLine("<TD>" + (backpackgold + bankgold + housetotal + vendortotal) + "</TD>"); op.WriteLine("<TD>" + backpackgold + "</TD>"); op.WriteLine("<TD>" + bankgold + "</TD>"); op.WriteLine("<TD>" + housetotal + "</TD>"); op.WriteLine("<TD>" + list.Count + "</TD>"); op.WriteLine("<TD>" + vendortotal + " (" + vendors.Count + " vendors)" + "</TD>"); op.WriteLine("</TR>"); } } } op.WriteLine("</BODY></HTML>"); op.Flush(); op.Close(); } #else Hashtable table = new Hashtable(Accounts.Table.Values.Count); System.Console.WriteLine("GT: building hashtable"); SM(cmdmob, "GT: building hashtable"); foreach (Account acct in Accounts.Table.Values) { if (acct == null) { continue; } if ((bSupressStaff && acct.GetAccessLevel() > AccessLevel.Player) == false) { table.Add(acct, new GoldTotaller()); } } System.Console.WriteLine("GT: looping through accounts"); SM(cmdmob, "GT: looping through accounts"); foreach (Account acct in Accounts.Table.Values) { if (acct == null) { continue; } if ((bSupressStaff && acct.GetAccessLevel() > AccessLevel.Player) == false) { //iterate through characters: for (int i = 0; i < 5; ++i) { if (acct[i] != null) { PlayerMobile player = (PlayerMobile)acct[i]; Container backpack = player.Backpack; BankBox bank = player.BankBox; int backpackgold = 0; int bankgold = 0; int housedeedcount = 0; int housedeedworth = 0; int housesworth = 0; //BACKPACK backpackgold = GetGoldInContainer(backpack); housedeedworth = GetHouseDeedsInContainer(backpack, ref housedeedcount); //BANK bankgold = GetGoldInContainer(bank); housedeedworth += GetHouseDeedsInContainer(bank, ref housedeedcount); //house? int housetotal = 0; ArrayList list = Multis.BaseHouse.GetHouses(player); for (int j = 0; j < list.Count; ++j) { if (list[j] is BaseHouse) { BaseHouse house = (BaseHouse)list[j]; housesworth += (int)house.UpgradeCosts; HouseDeed hd = house.GetDeed(); if (hd != null && hd is SiegeTentBag == false && hd is TentBag == false) { housesworth += RealEstateBroker.ComputePriceFor(hd); hd.Delete(); } housetotal += GetGoldInHouse(house); housedeedworth += GetHouseDeedWorthInHouse(house, ref housedeedcount); } } ((GoldTotaller)table[acct]).BackpackGold += backpackgold; ((GoldTotaller)table[acct]).BankGold += bankgold; ((GoldTotaller)table[acct]).HouseGold += housetotal; ((GoldTotaller)table[acct]).HouseCount += list.Count; ((GoldTotaller)table[acct]).CharacterCount += 1; ((GoldTotaller)table[acct]).HouseDeedCount += housedeedcount; ((GoldTotaller)table[acct]).HouseDeedWorth += housedeedworth; ((GoldTotaller)table[acct]).HousesWorth += housesworth; } } } } System.Console.WriteLine("GT: Searching mobiles for PlayerVendors"); SM(cmdmob, "GT: Searching mobiles for PlayerVendors"); foreach (Mobile wm in World.Mobiles.Values) { if (wm == null) { continue; } if (wm is PlayerVendor) { PlayerVendor pv = wm as PlayerVendor; if (pv != null && pv.Owner != null) { Account thisacct = pv.Owner.Account as Account; if (thisacct != null) { if ((bSupressStaff && thisacct.GetAccessLevel() > AccessLevel.Player) == false) { ((GoldTotaller)table[thisacct]).VendorCount += 1; ((GoldTotaller)table[thisacct]).VendorGold += pv.HoldGold; } } } } } System.Console.WriteLine("GT: sorting"); SM(cmdmob, "GT: sorting"); ArrayList keys = new ArrayList(table.Keys); keys.Sort(new GTComparer(table)); System.Console.WriteLine("GT: Outputting html"); SM(cmdmob, "GT: Outputting html"); using (StreamWriter op = new StreamWriter(OUTPUT_DIRECTORY + "/" + OUTPUT_FILE)) { op.WriteLine("<HTML><BODY>"); op.WriteLine("<TABLE BORDER=1 WIDTH=90%><TR>"); if (bSupressNames) { op.WriteLine("<TD>=(char count)</TD>"); } else { op.WriteLine("<TD>Account (char count)</TD>"); } op.WriteLine("<TD>Total Worth</TD>"); op.WriteLine("<TD>Backpack Gold</TD>"); op.WriteLine("<TD>Bank Gold</TD>"); op.WriteLine("<TD>House Gold (house count)</TD>"); op.WriteLine("<TD>Vendor Gold (vendor count)</TD>"); op.WriteLine("<TD>Returnable Deed Worth (deed count)<br>(Included house and storage upgrade deeds</TD>"); op.WriteLine("<TD>House(s) Worth</TD>"); op.WriteLine("</TR>"); for (int i = 0; i < keys.Count && i < maxtoprint; i++) { GoldTotaller gt = table[keys[i]] as GoldTotaller; if (gt != null) { string bannedstr = ""; if (bIndicateBanned) { if (((Account)keys[i]).Banned) { bannedstr = " **banned** "; } } //System.Console.WriteLine( "Acct: {0}, total: {1}", ((Account)keys[i]).Username, gt.TotalGold ); if (bSupressNames) { op.WriteLine("<TR><TD>(" + gt.CharacterCount + ")" + bannedstr + "</TD>"); //Account } else { op.WriteLine("<TR><TD><B>" + ((Account)keys[i]).Username + "</B>(" + gt.CharacterCount + ")" + bannedstr + "</TD>"); //Account } op.WriteLine("<TD>" + gt.TotalGold + "</TD>"); //Total Worth op.WriteLine("<TD>" + gt.BackpackGold + "</TD>"); //Backpack op.WriteLine("<TD>" + gt.BankGold + "</TD>"); //bank op.WriteLine("<TD>" + gt.HouseGold + " (" + gt.HouseCount + ")</TD>"); //houses op.WriteLine("<TD>" + gt.VendorGold + " (" + gt.VendorCount + ")</TD>"); //vendors op.WriteLine("<TD>" + gt.HouseDeedWorth + " (" + gt.HouseDeedCount + ")</TD>"); //housedeeds op.WriteLine("<TD>" + gt.HousesWorth + "</TD>"); //housedeeds op.WriteLine("</TR>"); } } op.WriteLine("</TABLE></BODY></HTML>"); op.Flush(); op.Close(); } #endif } catch (Exception e) { LogHelper.LogException(e); System.Console.WriteLine("Error in GoldTracker: " + e.Message); System.Console.WriteLine(e.StackTrace); } finally { DateTime endDateTime = DateTime.Now; TimeSpan time = endDateTime - startDateTime; string endmsg = "finished in " + ((double)time.TotalMilliseconds / (double)1000) + " seconds."; System.Console.WriteLine(endmsg); SM(cmdmob, endmsg); bInProcess = false; } }