|
||
|
|||||||
| Script Support Get support for modifying RunUO Scripts, or writing your own! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Forum Expert
Join Date: Sep 2007
Location: Over there
Posts: 1,575
|
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:
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;
}
}
}
}
|
|
|
|
|
|
#2 (permalink) |
|
Forum Master
|
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 ..... :) |
|
|
|
|
|
#3 (permalink) | |||
|
Forum Novice
Join Date: Jan 2003
Location: Rochester NY
Age: 27
Posts: 208
|
Quote:
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:
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:
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 •¤•¤• |
|||
|
|
|
|
|
#4 (permalink) | |
|
Forum Expert
Join Date: Sep 2007
Location: Over there
Posts: 1,575
|
Quote:
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. |
|
|
|
|
|
|
#6 (permalink) |
|
Forum Novice
Join Date: Jan 2003
Location: Rochester NY
Age: 27
Posts: 208
|
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 •¤•¤• |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|