ServUO Version
Publish 57
Ultima Expansion
Endless Journey
Is there a way to send a web browser open to the client from an action within a script? I'm working on some modifications to the help gump and need to send them to a web address rather than send a log file and page.
 
There's a command...

this is from the Commands.CS file

C#:
public class OpenBrowserCommand : BaseCommand
    {
        public OpenBrowserCommand()
        {
            AccessLevel = AccessLevel.GameMaster;
            Supports = CommandSupport.AllMobiles;
            Commands = new string[]{ "OpenBrowser", "OB" };
            ObjectTypes = ObjectTypes.Mobiles;
            Usage = "OpenBrowser <url>";
            Description = "Opens the web browser of a targeted player to a specified url.";
        }

        public static void OpenBrowser_Callback( Mobile from, bool okay, object state )
        {
            object[] states = (object[])state;
            Mobile gm = (Mobile)states[0];
            string url = (string)states[1];

            if ( okay )
            {
                gm.SendMessage( "{0} : has opened their web browser to : {1}", from.Name, url );
                from.LaunchBrowser( url );
            }
            else
            {
                from.SendMessage( "You have chosen not to open your web browser." );
                gm.SendMessage( "{0} : has chosen not to open their web browser to : {1}", from.Name, url );
            }
        }

        public override void Execute( CommandEventArgs e, object obj )
        {
            if ( e.Length == 1 )
            {
                Mobile mob = (Mobile)obj;
                Mobile from = e.Mobile;

                if ( mob.Player )
                {
                    NetState ns = mob.NetState;

                    if ( ns == null )
                    {
                        LogFailure( "That player is not online." );
                    }
                    else
                    {
                        string url = e.GetString( 0 );

                        CommandLogging.WriteLine( from, "{0} {1} requesting to open web browser of {2} to {3}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( mob ), url );
                        AddResponse( "Awaiting user confirmation..." );
                        mob.SendGump( new WarningGump( 1060637, 30720, String.Format( "A game master is requesting to open your web browser to the following URL:<br>{0}", url ), 0xFFC000, 320, 240, new WarningGumpCallback( OpenBrowser_Callback ), new object[]{ from, url } ) );
                    }
                }
                else
                {
                    LogFailure( "That is not a player." );
                }
            }
            else
            {
                LogFailure( "Format: OpenBrowser <url>" );
            }
        }
    }

Hope that helps.
 
I didn't even think of looking there, thank you haha. Also I meant open it from within another script, for example clicking a button in the help menu takes you to a webpage.
 
Last edited:
Back