Rehashing an old Beginner.cs code to display an html page by using a keyword. Something got me interested in this and if it works great, if not, no biggie. But I need help getting past this code error.

Line 21: The type or namespace name 'CommandEventArgs' could not be found (are you missing a using directive or an assembly reference?)

Code:
// not actually a timer anymore, oh well. :>

using System;
using Server.Network;
using Server.Gumps;

using System.Collections;
using System.IO;
using Server.Mobiles;
using Server.Items;


namespace Server.Misc
{
    /// <summary>
    /// This command displays the Rules help window.
    /// </summary>
    public class RulesCommand
    {
        public static void Initialize()
        {
            Server.Commands.Register( "Rules", AccessLevel.Player, new CommandEventHandler( RulesCommand_OnCommand ) );
        }
       
        [Usage( "Rules" )]
        [Description( "Displays the shard rules to players." )]
        public static void RulesCommand_OnCommand( AccessLevel.Player )
        {
            string filename = Path.Combine( Core.BaseDirectory, "Data/HTML Files/Rules.html" );
           
            string content = "";
           
            if ( File.Exists( filename ) )
            {
                using ( StreamReader sr = new StreamReader( filename ) )
                {
                    string line;
                   
                    while ((line = sr.ReadLine()) != null)
                    {
                        content = content + line;   
                    }
                }
               
               
                if ( content != null || content != "" )
                {
                    e.Mobile.SendGump( new NoticeGump( 1060637, 0xFFFFFF, String.Format( content, Server.Commands.CommandPrefix ), 0xFFFFFF, 640, 480, null, null ) );
                }
                else
                {
                    e.Mobile.SendMessage( "Error, content was null." );
                }
            }
            else
            {
                e.Mobile.SendMessage( "Error, couldn't find {0}", filename );
            }
        }
    }
}
 
did that, got this.

CS0234: Line 23: The type or namespace name 'Register' does not exist in the namespace 'Server.Commands' (are you missing an assembly reference?)
CS0123: Line 23: No overload for 'RulesCommand_OnCommand' matches delegate ' Server.Commands.CommandEventHandler'
CS0103: Line 49: The name 'e' does not exist in the current context
CS0234: Line 49: The type or namespace name 'CommandPrefix' does not exist in the namespace 'Server.Commands' (are you missing an assembly reference?)
CS0103: Line 53: The name 'e' does not exist in the current context
CS0103: Line 58: The name 'e' does not exist in the current context
 
Yeah cause the top line
:
public static void RulesCommand_OnCommand( AccessLevel.Player)
Supposed to look like
public static void RulesCommand_OnCommand(CommandEventArgs e)
 
got it down to this now.

CS0234: Line 11: The type or namespace name 'CommandPrefix' does not exist in the namespace 'Server.Commands' (are you missing an assembly reference?)

Code:
// not actually a timer anymore, oh well. :>

using System;
using Server.Network;
using Server.Gumps;
using Server.Commands;
using System.Collections;
using System.IO;
using Server.Mobiles;
using Server.Items;
using Server.Commands.CommandPrefix;


namespace Server.Misc
{
    /// <summary>
    /// This command displays the Rules help window.
    /// </summary>
    public class RulesCommand
    {
        public static void Initialize( CommandEventArgs e )
        {
            Server.Commands.Register( "Rules", AccessLevel.Player, new CommandEventHandler( RulesCommand_OnCommand ));
        }
       
        [Usage( "Rules" )]
        [Description( "Displays the shard rules to players." )]
        public static void RulesCommand_OnCommand(CommandEventArgs e)
        {
            string filename = Path.Combine( Core.BaseDirectory, "Data/0-HTMLFiles/Rules.html" );
           
            string content = "";
           
            if ( File.Exists( filename ) )
            {
                using ( StreamReader sr = new StreamReader( filename ) )
                {
                    string line;
                   
                    while ((line = sr.ReadLine()) != null)
                    {
                        content = content + line;   
                    }
                }
               
               
                if ( content != null || content != "" )
                {
                    e.Mobile.SendGump( new NoticeGump( 1060637, 0xFFFFFF, String.Format( content, Server.Commands.CommandPrefix ), 0xFFFFFF, 640, 480, null, null ) );
                }
                else
                {
                    e.Mobile.SendMessage( "Error, content was null." );
                }
            }
            else
            {
                e.Mobile.SendMessage( "Error, couldn't find {0}", filename );
            }
        }
    }
}
 
That helped alot, but I cannot find a solution for this----
Line 48: The type or namespace name 'CommandPrefix' does not exist in the namespace 'Server.Commands' (are you missing an assembly reference?)

Code:
// not actually a timer anymore, oh well. :>

using System;
using Server.Network;
using Server.Gumps;
using Server.Commands;
using System.Collections;
using System.IO;
using Server.Mobiles;
using Server.Items;


namespace Server.Misc
{
    /// <summary>
    /// This command displays the Rules help window.
    /// </summary>
    public class RulesCommand
    {
        public static void Initialize( CommandEventArgs e )
        {
            CommandSystem.Register( "Rules", AccessLevel.Player, new CommandEventHandler( RulesCommand_OnCommand ));
        }
       
        [Usage( "Rules" )]
        [Description( "Displays the shard rules to players." )]
        public static void RulesCommand_OnCommand(CommandEventArgs e)
        {
            string filename = Path.Combine( Core.BaseDirectory, "Data/0-HTMLFiles/Rules.html" );
           
            string content = "";
           
            if ( File.Exists( filename ) )
            {
                using ( StreamReader sr = new StreamReader( filename ) )
                {
                    string line;
                   
                    while ((line = sr.ReadLine()) != null)
                    {
                        content = content + line;   
                    }
                }
               
               
                if ( content != null || content != "" )
                {
                    e.Mobile.SendGump( new NoticeGump( 1060637, 0xFFFFFF, String.Format( content, Server.Commands.CommandPrefix ), 0xFFFFFF, 640, 480, null, null ) );
                }
                else
                {
                    e.Mobile.SendMessage( "Error, content was null." );
                }
            }
            else
            {
                e.Mobile.SendMessage( "Error, couldn't find {0}", filename );
            }
        }
    }
}
 
Check the error message, Line 48:

e.Mobile.SendGump( new NoticeGump( 1060637, 0xFFFFFF, String.Format( content, Server.Commands.CommandPrefix ), 0xFFFFFF, 640, 480, null, null ) );

instead of Server.Commands.CommandPrefix you will have CommandSystem.Prefix
So
e.Mobile.SendGump( new NoticeGump( 1060637, 0xFFFFFF, String.Format( content, CommandSystem.Prefix ), 0xFFFFFF, 640, 480, null, null ) );

Like so
 
Yes because you change that to this CommandSystem.Prefix

Or Server.CommandSystem.Prefix

On my last reply check the two lines i colored red. The bottom one is how your line should look like.
 
did that. but getting this error. so I recompiled my code and restarted the server. same error.

ServUO - [http://www.servuo.com] Version 0.5, Build 5696.23999
Publish 54
Core: Optimizing for 4 64-bit processors
RandomImpl: CSPRandom (Software)
Scripts: Compiling C# scripts...done (cached)
Scripts: Skipping VB.NET Scripts...done (use -vb to enable)
Scripts: Verifying...
Finished (4057 items, 1007 mobiles, 11 customs) (1.53 seconds)
Regions: Loading...done
World: Loading...done (0 items, 0 mobiles, 0 customs) (0.04 seconds)
Error:
System.Reflection.TargetParameterCountException: Parameter count mismatch.
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Server.ScriptCompiler.Invoke(String method) in c:\ServUO-master\Server\ScriptCompiler.cs:line 660
at Server.Core.Main(String[] args) in c:\ServUO-master\Server\Main.cs:line 592
This exception is fatal, press return to exit
 
Yes because it crashes due to having public static void Initialize( CommandEventArgs e )
but it should have been just Initialize() {...

  1. public class RulesCommand
  2. {
  3. public static void Initialize( CommandEventArgs e )
  4. {
  5. CommandSystem.Register( "Rules", AccessLevel.Player, new CommandEventHandler( RulesCommand_OnCommand ));
  6. }

so to make it work

  1. public class RulesCommand
  2. {
  3. public static void Initialize()
  4. {
  5. CommandSystem.Register( "Rules", AccessLevel.Player, new CommandEventHandler( RulesCommand_OnCommand ));
  6. }

as for your first problem make sure you add
using Server.Commands;

and then
e.Mobile.SendGump( new NoticeGump( 1060637, 0xFFFFFF, String.Format( content, CommandSystem.Prefix ), 0xFFFFFF, 640, 480, null, null ) );
 
Back