PigPen

Member
ServUO Version
Publish Unknown
Ultima Expansion
Mondain's Legacy
I am getting ready for Christmas on my RunUO 2.1 shard . . and . . I have no idea how to do this:

I have various items like Snowmen, Gift Boxes, Holiday Bells etc. that pop up during the Christmas Season but every year it is a real pain trying to determine which accounts are active and then go through them all to find out the various Character names on those active accounts so I can apply those active character names to the seasonal items.

If I had an in-game command I could use that would send a list of 'Character Names' (from accounts that had logged in during the past 365 days) to a .log file then I could easily copy/paste those Character Names into the various files for the Snowmen, Gift Boxes, Holiday Bells etc.

If this is possible it would be a real time saver and make the annual preparations for Holidays less of a pain and a lot more fun.

I thought perhaps something like this could be accomplished using the file Handlers.cs but everything I've tired there over the past week is beyond my skill level and just explodes.

Probably the Handlers.cs file is the wrong approach and something else needs to be created. Does anyone know how this might be possible?

If someone knows a way to achieve this . . you have all my very best and most powerful wishes for a truly Happy Christmas Season. * smiles *

Cheers
 
You could use next ingame commands for this:
[global interface name lastonline gametime where playermobile lastonline >= 10.12.2023 order by lastonline
[global addtopack LargeBagBall where playermobile lastonline >= 10.12.2023 gametime > 0.05:00:00
First command shows you all active members who logged to the game from 10 December to current date, their name, lastonline date, gametime and sorted them by lastonline filter.
Second command gives to everyone a LargeBagBall (aka GiftBox with your snowmens,etc) who logged from 10 December until the date of use with filter by players who has gametime more than 5 hours to avoid bots and unused characters.

Also RunUO like and ServUO already have automatical script for gift giving.
Example you can find there: RunUO-2.1/Scripts/Misc/Gifts/Winter2004/Winter2004.cs at master · Delphi79/RunUO-2.1
all players who will log in event date range - they will receive the rewards.
 
Thank you for that Juzzver. That is useful information for sure and I really appreciate your time and reply.

What I am really hoping to find is a way to send all the Character names to a .log file where those character names belong to an account that has logged in to the game during the past 365 days.

That would give me an easy way to cut/paste those names into a file used for Christmas Items (Snowman, Snow Globe, Christmas Bell etc).

My reason for wanting to keep the names used in those particular files 'current' is because . . . Players hunt for those items trying to find ones with their name (or a friend's name) and . . unless I keep the names to currently played accounts, well . . . we would end up with over a thousand names that are no longer used and finding one with your name on it becomes almost impossible.

I have been looking into a file that generates 'Player Wealth' on the shard to a .log file and I have been looking into the [Admin gump file to see how it searches Account character names but . . so far I can't figure out how they could be used with a command to do the search and print the results into a list in a .log file.

I would sure like to find a way to do that. It could also be useful for other things we do on the shard because searching every account manually for the names is extremely time consuming.

If any one can help on this it would be appreciated.

Cheers
 
Hey . . Thank you Juzzver!

The command . . . [global interface name lastonline gametime where playermobile lastonline >= 10.12.2023
works perfectly if I could only get it to print the results to a file on my computer like 'activeplayer.log'

Is that possible? if so what would I need to add to the command line . . or how could I put it all in a script that would run the command and direct the output to a file instead of an in game gump?

If anyone can help me with this then I am 'home free' on this problem.

Many Thanks
 
C#:
public static void LogActivePlayers()
{
    // using System.Collections.Generic;
   List<string> results = new List<string>();

   DateTime now = DateTime.Now;

   TimeSpan limit = TimeSpan.FromDays(365);

   foreach (Mobile mobile in World.Mobiles.Values)
   {
       if (mobile is PlayerMobile)
       {
           PlayerMobile player = (PlayerMobile)mobile;

           if (player.LastOnline > DateTime.MinValue && now - player.LastOnline <= limit)
           {
               results.Add(string.Format("{0}\t{1}\t{2}\t{3}", player.Account, player.RawName, player.LastOnline, player.GameTime));
           }
       }
   }

   results.Sort(StringComparer.OrdinalIgnoreCase);
   results.Insert(0, "# ACCOUNT\tPLAYER\tONLINE\tTIME");

   // using System.IO;
   File.WriteAllLines("active_players.tsv", results);
}
 
Thank you Voxpire. I really appreciate your eyes on this.

I know enough to tell me that I am missing some steps here that would be obvious to more experienced scripters but I have no idea what exactly it is.

I saved your suggestion into a file I named ActivePlayers.cs

I have no idea how this would be called upon in game but even before that . . I am getting errors trying to compile it.

Here is the content of my ActivePlayers.cs:
Code:
public static void LogActivePlayers()
{
    // using System.Collections.Generic;
   List<string> results = new List<string>();

   DateTime now = DateTime.Now;

   TimeSpan limit = TimeSpan.FromDays(365);

   foreach (Mobile mobile in World.Mobiles.Values)
   {
       if (mobile is PlayerMobile)
       {
           PlayerMobile player = (PlayerMobile)mobile;

           if (player.LastOnline > DateTime.MinValue && now - player.LastOnline <= limit)
           {
               results.Add(string.Format("{0}\t{1}\t{2}\t{3}", player.Account, player.RawName, player.LastOnline, player.GameTime));
           }
       }
   }

   results.Sort(StringComparer.OrdinalIgnoreCase);
   results.Insert(0, "# ACCOUNT\tPLAYER\tONLINE\tTIME");

   // using System.IO;
   File.WriteAllLines("active_players.tsv", results);
}

and . . here are the errors which I do not understand.
Code:
Errors:
 + Customs/Events - Special/December/ActivePlayers.cs:
    CS1518: Line 1: Expected class, delegate, enum, interface, or struct
    CS1518: Line 4: Expected class, delegate, enum, interface, or struct
    CS1022: Line 28: Type or namespace definition, or end-of-file expected

Would really love to get this working. Sorry for being so *doh* but I'm still struggling on it.
 
It's a method you can throw into a custom class, it's not a complete script.

Create a new command class, register the command using Commands.Register(...) (there are a lot of examples), and have it execute the LogActivePlayers method.

You can edit it as such if it makes more sense;
C#:
public static void LogActivePlayers(CommandEventArgs e)
{
    ...
}
 
Works like a hot *darn*

Like many times in the past . . . Thank you Voxpire for sending my down the right path.

Here is what I ended up with after your guidance.
Code:
using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Targeting;
using Server.Mobiles;
using Server.Commands;
using System.Collections.Generic;
using Server.Network;
using Server.Gumps;
using System.IO;

namespace Server.Commands
{
    public class LogActivePlayers
    {
        public static void Initialize()
        {
            CommandSystem.Register( "LogActivePlayers", AccessLevel.Administrator, new CommandEventHandler( LogActivePlayers_OnCommand ) );
        }

        [Usage( "LogActivePlayers" )]
        [Description( "Sends a list of Accounts and Characters to a file called 'active_players.tsv'" )]

        public static void LogActivePlayers_OnCommand(CommandEventArgs e )
        {
                // using System.Collections.Generic;
               List<string> results = new List<string>();

               DateTime now = DateTime.Now;

               TimeSpan limit = TimeSpan.FromDays(365);

               foreach (Mobile mobile in World.Mobiles.Values)
               {
                   if (mobile is PlayerMobile)
                   {
                       PlayerMobile player = (PlayerMobile)mobile;

                       if (player.LastOnline > DateTime.MinValue && now - player.LastOnline <= limit)
                       {
                               results.Add(string.Format("{0}\t{1}\t{2}\t{3}", player.Account, player.RawName, player.LastOnline, player.GameTime));
                       }
                   }
               }

               results.Sort(StringComparer.OrdinalIgnoreCase);
               results.Insert(0, "# ACCOUNT\tPLAYER\tONLINE\tTIME");

               // using System.IO;
               File.WriteAllLines("active_players.tsv", results);
        }
    }
}

Cheers and Merry Christmas to all who looked at this . . and special thanks to . . Juzzver and Voxpire for contributing.

Greatly appreciated.

*bows*
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back