public static void WealthTracker_OnCommand(CommandEventArgs e) { try { if (e.ArgString.Contains("-h")) { e.Mobile.SendMessage("Usage: WealthTracker -h|-l=NN|-m=NN|-o"); e.Mobile.SendMessage("Where: -h ... help - this screen"); e.Mobile.SendMessage("Where: -l=NN ... list - top NN gold farming domains"); e.Mobile.SendMessage("Where: -m=NN ... mins - within last NN minutes"); e.Mobile.SendMessage("Where: -o ... online clients only"); //e.Mobile.SendMessage("Where: -hi ... clients that have hardware info"); return; } // default to top 10 int limit = 10; if (e.ArgString.Contains("-t")) { limit = GetArgInt(e.Mobile, "-t", e.ArgString, AccessLevel.Owner, limit); } // default to last hour int minutes = 60; if (e.ArgString.Contains("-m")) { minutes = GetArgInt(e.Mobile, "-m", e.ArgString, AccessLevel.Counselor, minutes); } bool mustBeOnline = false; if (e.ArgString.Contains("-o")) { mustBeOnline = true; } // compile the constrained list IPDomain[] list = ReportCompiler(limit, minutes); // show a super minimal report for (int ix = 0; ix < list.Length; ix++) { IPDomain node = list[ix] as IPDomain; AccountDomain ad = GetFirst(node.accountList, mustBeOnline) as AccountDomain; // just first (online) account if (ad != null) { Mobile m = GetFirst(ad.mobileList, mustBeOnline) as Mobile; // just first (online) mobile if (m != null) { e.Mobile.SendMessage(String.Format("mob:{2}, gold:{0}, loc:{1}", node.gold, node.location, m)); } } } } catch (Exception ex) { LogHelper.LogException(ex); } e.Mobile.SendMessage("done."); }
public static IPDomain[] ReportCompiler(int limit, int timeout) { // allocate an array to hold the output IPDomain[] list = new IPDomain[WealthTracker.m_IPList.Count]; // remove expired nodes int jx = 0; foreach (IPDomain node in WealthTracker.m_IPList.Values) { // filter out old farming activity if (node == null) { continue; } if (((TimeSpan)(DateTime.Now - node.lastTick)).Minutes <= timeout) { list[jx++] = node; } } // now sort on gold held Array.Sort(list, new WealthDomainComparer()); // now trim the array if (list.Length > limit) { Array.Resize(ref list, limit); } return(list); }
private static void GoldLifted(WealthTrackerEventArgs e) { // sanity if (e == null || e.item == null || e.from == null || e.from.NetState == null) { return; } // eliminate tracking of all but approved scenarios if (ScenarioFilter(e) == false) { return; } NetState state = e.from.NetState; int iphc = state.ToString().GetHashCode(); // hash code of IP address IPDomain ipd = null; AccountDomain ad = null; if (m_IPList.Contains(iphc)) // if we have it already { ipd = m_IPList[iphc] as IPDomain; // get the IPDomain at this IP address if (ipd.accountList.Contains(e.from.Account) == false) // if we don't have an account domain, create it { ipd.accountList.Add(e.from.Account, new AccountDomain()); } ad = ipd.accountList[e.from.Account] as AccountDomain; // get the account domain } else { m_IPList[iphc] = new IPDomain(); // start a new list of clients at this IP address ipd = m_IPList[iphc] as IPDomain; // get the IPDomain at this IP address ipd.accountList.Add(e.from.Account, new AccountDomain()); // add another client at this IP + location ad = ipd.accountList[e.from.Account] as AccountDomain; // get the account domain } // update domain information if (ad != null && ipd != null) { ad.mobileList[e.from.Serial] = e.from; // record mobile (not sure what the key should be) ad.gold += e.item.Amount; // update gold for this IPDomain ad.lastTick = DateTime.Now; // last gold pickup ad.location = e.from.Location; // last gold pickup location ipd.gold += e.item.Amount; // update gold for this IPDomain ipd.lastTick = DateTime.Now; // last gold pickup ipd.location = e.from.Location; // last gold pickup location } }
int IComparer.Compare(Object x, Object y) { // reverse x and y to get a descending sort (largest to smallest) IPDomain mx = y as IPDomain; IPDomain my = x as IPDomain; if (mx == null || my == null) { return(0); } if (mx.gold == my.gold) { return(0); } if (mx.gold > my.gold) { return(1); } else { return(-1); } }
private static void GoldLifted(WealthTrackerEventArgs e) { // sanity if (e == null || e.item == null || e.from == null || e.from.NetState == null) return; // eliminate tracking of all but approved scenarios if (ScenarioFilter(e) == false) return; NetState state = e.from.NetState; int iphc = state.ToString().GetHashCode(); // hash code of IP address IPDomain ipd = null; AccountDomain ad = null; if (m_IPList.Contains(iphc)) // if we have it already { ipd = m_IPList[iphc] as IPDomain; // get the IPDomain at this IP address if (ipd.accountList.Contains(e.from.Account) == false) // if we don't have an account domain, create it ipd.accountList.Add(e.from.Account, new AccountDomain()); ad = ipd.accountList[e.from.Account] as AccountDomain; // get the account domain } else { m_IPList[iphc] = new IPDomain(); // start a new list of clients at this IP address ipd = m_IPList[iphc] as IPDomain; // get the IPDomain at this IP address ipd.accountList.Add(e.from.Account, new AccountDomain()); // add another client at this IP + location ad = ipd.accountList[e.from.Account] as AccountDomain; // get the account domain } // update domain information if (ad != null && ipd != null) { ad.mobileList[e.from.Serial] = e.from; // record mobile (not sure what the key should be) ad.gold += e.item.Amount; // update gold for this IPDomain ad.lastTick = DateTime.Now; // last gold pickup ad.location = e.from.Location; // last gold pickup location ipd.gold += e.item.Amount; // update gold for this IPDomain ipd.lastTick = DateTime.Now; // last gold pickup ipd.location = e.from.Location; // last gold pickup location } }
public static IPDomain[] ReportCompiler(int limit, int timeout) { // allocate an array to hold the output IPDomain[] list = new IPDomain[WealthTracker.m_IPList.Count]; // remove expired nodes int jx = 0; foreach (IPDomain node in WealthTracker.m_IPList.Values) { // filter out old farming activity if (node == null) continue; if (((TimeSpan)(DateTime.Now - node.lastTick)).Minutes <= timeout) list[jx++] = node; } // now sort on gold held Array.Sort(list, new WealthDomainComparer()); // now trim the array if (list.Length > limit) Array.Resize(ref list, limit); return list; }