Trying to load gump on login?

Exale

Well-Known Member
Mar 2, 2014
230
21
38
Wisconsin
Shard Name
Mystical Nights
I am trying to get a custom gump to load on login and I am getting an error I don't understand why. The mobile is already defined in the script as it's used by default to send a message so I just used the same definition to send a gump (making sure it was closed first to prevent duplicates). I am a little puzzled. Thanks for any help.

Here is the errors.

Errors:
+ Misc/LoginStats.cs:
CS7036: Line 27: There is no argument given that corresponds to the required formal parameter 'owner' of 'WelcomeGump.WelcomeGump(Mobile)'
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

Here is the script.

C#:
using System;
using Server.Network;
using Server.Engines.Quests;
using Server.Mobiles;
using System.Collections.Generic;
using System.Linq;

namespace Server.Misc
{
    public class LoginStats
    {
        public static void Initialize()
        {
            // Register our event handler
            EventSink.Login += new LoginEventHandler(EventSink_Login);
        }

        private static void EventSink_Login(LoginEventArgs args)
        {
            int userCount = NetState.Instances.Count;
            int itemCount = World.Items.Count;
            int mobileCount = World.Mobiles.Count;

            Mobile m = args.Mobile;
            
            m.CloseGump( typeof( WelcomeGump ) );
            m.SendGump( new WelcomeGump() );

            m.SendMessage("Welcome, {0}! There {1} currently {2} user{3} online, with {4} item{5} and {6} mobile{7} in the world.",
                args.Mobile.Name,
                userCount == 1 ? "is" : "are",
                userCount, userCount == 1 ? "" : "s",
                itemCount, itemCount == 1 ? "" : "s",
                mobileCount, mobileCount == 1 ? "" : "s");

            if (m.IsStaff())
            {
                Server.Engines.Help.PageQueue.Pages_OnCalled(m);
            }
        }
    }
}
 

Vorspire

Vita-Nex: Core
Admin
ServUO Developer
Jul 29, 2013
1,136
242
32
United Kingdom
core.vita-nex.com
Shard Name
Ultima Shards: Multiverse
Donate
Donate money to this user
Get Visual Studio 2019 - Community

If you use the proper tools to develop, these errors should be more obvious.
Don't rely on the ScriptCompiler console output to tell you when you have errors, let Visual Studio do that for you.

When you've installed VS, open ServUO.sln to start editing your project. Use F6 to perform a build (create a new exe and scripts dll)
 

Exale

Well-Known Member
Mar 2, 2014
230
21
38
Wisconsin
Shard Name
Mystical Nights
Ok I will work on that. That's really the most efficient way to figure out errors is to recompile the entire server every time? I respect your abilities so I am genuinely asking. This will help me figure out errors better?
Post automatically merged:

So I did what you suggested and I have the script loaded and it's not giving me any information that Notepad++ didn't give me? It's not red, or telling me there is an error. I don't understand why this script isn't working.
 

Attachments

Last edited:

Vorspire

Vita-Nex: Core
Admin
ServUO Developer
Jul 29, 2013
1,136
242
32
United Kingdom
core.vita-nex.com
Shard Name
Ultima Shards: Multiverse
Donate
Donate money to this user
Did you not try hovering over the text that's underlined in red?
That will give you all the information you need to be able to search for similar issues.

You need a using directive to import the WelcomeGump type, and you need to add an argument between those ( braces ).
 
  • Like
Reactions: Exale

Exale

Well-Known Member
Mar 2, 2014
230
21
38
Wisconsin
Shard Name
Mystical Nights
Ahhh, I see. Thanks for pointing me in the right direction. I've never used Visual Studio before but I do see how it highlighting errors is quicker than compiling. Thanks a ton! I just started by defining m again in the brackets and then added the gump directive. thanks for taking the time to point me in the right direction instead of just posting the fixed version.
 
  • Like
Reactions: Vorspire