Go Back   RunUO - Ultima Online Emulation > RunUO > Script Support

Script Support Get support for modifying RunUO Scripts, or writing your own!

Reply
 
Thread Tools Display Modes
Old 08-22-2008, 10:30 PM   #1 (permalink)
Forum Expert
 
TheRockstar2253's Avatar
 
Join Date: Sep 2007
Location: Over there
Posts: 1,575
Default need help fixing my custom [event command for my shard

Hello,

I am currently having issues trying to compile a script I created for my new shard. It's a script that when a gamemaster types in [event, it's suppose to send a gump to all players asking them if they want to join or decline.

Also I have a good feeling that the code I use to bring the players to the gm isn't right. So if anyone can post the proper code to help me get it right, that would be great.

Now I'm getting some nasty errors out of this, and having a hard time fixing them. If anyone can help, I'll really appreciate it. Here's the error followed by the scripts:

Code:
Errors:
 + Custom Scripts/Event Command/EventCommand.cs:
    CS0103: Line 15: The name 'Event_OnCommand' does not exist in the current
context
    CS0103: Line 20: The name 'from' does not exist in the current context
    CS0026: Line 20: Keyword 'this' is not valid in a static property, static me
thod, or static field initializer
    CS0103: Line 20: The name 'from' does not exist in the current context
    CS0103: Line 22: The name 'from' does not exist in the current context
    CS0139: Line 23: No enclosing loop out of which to break or continue
 + Custom Scripts/Event Command/EventGump.cs:
    CS0117: Line 46: 'Server.Mobile' does not contain a definition for 'Mobile'
    CS0103: Line 46: The name 'm_From' does not exist in the current context
    CS0103: Line 46: The name 'm_From' does not exist in the current context
 + Custom Scripts/PaintballTeleporter.cs:
    CS0161: Line 45: 'Server.Items.PaintballTeleporter.OnMoveOver(Server.Mobile)
': not all code paths return a value
Code for Event Gump:

Code:
namespace Server.Gumps
{
    public class EventSendGump : Gump
    {

        public EventSendGump(string Name)
            : base(500, 350)
        {
            this.Closable = false;
            this.Disposable = true;
            this.Dragable = true;
            this.Resizable = false;
            AddPage(0);
            AddBackground(35, 29, 366, 91, 9270);
            this.AddAlphaRegion(66, 43, 311, 26);
            AddLabel(103, 47, 5, @"A Game Master is starting an event.");
            AddLabel(30, 16, 1153, @"Join");
            AddLabel(269, 82, 1153, @"No Thanks");
            AddButton(227, 80, 4005, 4007, 0, GumpButtonType.Reply, 0);
            AddButton(106, 80, 4005, 4007, 1, GumpButtonType.Reply, 0);

        }
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            switch (info.ButtonID)
            {
                   case 0: // 0 is reserved for gump close.
                    {
                        from.CloseGump(typeof(EventSendGump));
                        break;
                    }
                case 1:
                    {
                        from.Mobile.MoveToWorld(m_From.Location, m_From.Map);
                        break;
                    }
            }
        }
    }
}

Code:
namespace Server.Commands
{
    public class Eventcommand
    {
        public static void Initialize()
        {
            CommandSystem.Register("Event", AccessLevel.GameMaster, new CommandEventHandler(Event_OnCommand));
        }

        private static void Event_OnCommand(CommandEventArgs e)
        {
            if (from.InRange(this, 3) && from is PlayerMobile)
            {
                if (!from.HasGump(typeof(EventSendGump)))
                    break;
          
                }
        }
    }
}
TheRockstar2253 is offline   Reply With Quote
Old 08-23-2008, 12:52 AM   #2 (permalink)
Forum Master
 
Lord_Greywolf's Avatar
 
Join Date: Dec 2005
Posts: 6,777
Send a message via Yahoo to Lord_Greywolf
Default

need to see the whole scripts, hard to tell line numbers, when some are missing, also could be or should be stuff set up in the other areas, that might be wrong giving some errors also (like using Server.Commands.Generic, etc)

but just an FYI - there is something simular to this in the script release section (or the archives)\

the gm just types [createevent -- it then sends out a message to everyone, telling them if they want to join to type [event
it then sends them to the spot where the gm used the command
when done gm types [closeevent

real easy to use
__________________
http://www.AoAUO.com

:) ..... Come for the Customs, Play for the Fun. Return to see your new Friends ..... :)
Lord_Greywolf is online now   Reply With Quote
Old 08-23-2008, 03:53 AM   #3 (permalink)
Forum Novice
 
Arkryal's Avatar
 
Join Date: Jan 2003
Location: Rochester NY
Age: 27
Posts: 208
Default

Quote:
if (from.InRange(this, 3) && from is PlayerMobile)
within the context of that file, from would be the PlayerMobile GM who used the command and this refers to the command which can not have a range relative to the GM.

Instead, build an array of all mobiles in the world.
for each mobile in the array, check that they are a player.
if the entry is a player, send a Gump.

Quote:
from.Mobile.MoveToWorld(m_From.Location, m_From.Map);
Here it looks like you're trying to move a player to a location. Try this:

Mobile mPlayer = Whatever Mobile you Pass;
mPlayer.MoveToWorld(m_From.Location, m_From.Map);

Also check that m_From actually has a location, if they are internalized your server will crash.

Quote:
CS0161: Line 45: 'Server.Items.PaintballTeleporter.OnMoveOver(Serve r.Mobile)
': not all code paths return a value
This error usually means there's an If without an Else, so if the criteria of that statement is not met, no value is returned. Look through there and make sure you're not missing a return or break line.

Also check your includes. That's the using System.Whatever... at the top.

Post the full code, those errors are all easy to diagnose, so you're in good shape.
__________________
•¤•¤•Arkryal •¤•¤•
Arkryal is offline   Reply With Quote
Old 08-23-2008, 04:16 AM   #4 (permalink)
Forum Expert
 
TheRockstar2253's Avatar
 
Join Date: Sep 2007
Location: Over there
Posts: 1,575
Default

Quote:
Originally Posted by Arkryal View Post
This error usually means there's an If without an Else, so if the criteria of that statement is not met, no value is returned. Look through there and make sure you're not missing a return or break line.

Also check your includes. That's the using System.Whatever... at the top.

Post the full code, those errors are all easy to diagnose, so you're in good shape.
Oh wait the paintball teleporter is something I created for the paintball game on my shard, which I happened to fix on another test server behsides this one. I forgot to move it out of there lol so that error has been taken care of already.

As for the rest I will post the full code, but really it is the full code behsides the beginning code "using system;" and so on.
TheRockstar2253 is offline   Reply With Quote
Old 08-25-2008, 08:18 AM   #5 (permalink)
Forum Expert
 
Join Date: Nov 2004
Posts: 1,656
Send a message via ICQ to Murzin Send a message via AIM to Murzin Send a message via MSN to Murzin
Default

ark, thats totally false.

not all codepaths return a value means he has a bool/int method without a return in it.

people do If statements all the time without elses.
Murzin is offline   Reply With Quote
Old 08-25-2008, 09:53 AM   #6 (permalink)
Forum Novice
 
Arkryal's Avatar
 
Join Date: Jan 2003
Location: Rochester NY
Age: 27
Posts: 208
Default

I said he should look for a return. I find that most of those errors come from the return being on the wrong side of a close bracket in an If Statement, missing a "break;" in a switch or other conditional criteria not being met, so the return never executes. By stepping through your conditionals, it's easy to find where the return is missing or misplaced. I never meant to imply that all "If" statements needed an "Else", only that if the return was declared solely within an IF, and never declared outside of it, any unmet conditions would not return anything. Though reading my previous post again, I got a little ahead of myself and didn't explain why he should look at those things, So I can see how it may be misleading, thanks for pointing that out.
__________________
•¤•¤•Arkryal •¤•¤•
Arkryal is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5