} expected?

Candy Apple

Well-Known Member
Nov 14, 2016
269
25
45
I am not sure why I keep getting this and Sometimes if I // out the else it works and sometimes it don't. :(

--------------------------------------------------------------------------------
ServUO - [http://www.servuo.com] Version 0.5, Build 6437.20990
Publish 54
Core: Optimizing for 4 64-bit processors
RandomImpl: CSPRandom (Software)
Core: Loading config...
Scripts: Compiling C# scripts...Failed with: 1 errors, 0 warnings
Errors:
+ Quests/Ancient White Tiger Quest/VirtuesBox.cs:
CS1513: Line 76: } expected
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
Post automatically merged:

Ok this is really dumb but I used a working one and just set it up for the quest I am working on. the ShardBox.cs works fine for the working quest but the VitruesBox.cs gives me this error. p.s is diff than the above.

--------------------------------------------------------------------------------
ServUO - [http://www.servuo.com] Version 0.5, Build 6437.20990
Publish 54
Core: Optimizing for 4 64-bit processors
RandomImpl: CSPRandom (Software)
Core: Loading config...
Scripts: Compiling C# scripts...Failed with: 1 errors, 0 warnings
Errors:
+ Quests/Ancient White Tiger Quest/VirtuesBox.cs:
CS1022: Line 94: Type or namespace definition, or end-of-file expected
CS0116: Line 96: A namespace cannot directly contain members such as fields
or methods
CS1022: Line 100: Type or namespace definition, or end-of-file expected
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
 

Attachments

Last edited:

Candy Apple

Well-Known Member
Nov 14, 2016
269
25
45
Do yourself a huge favor and less headaches :) you can open the script in this and it will show you errors in red https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=16
I did get this but I have no idea how it works :( I tried reading it but was a bit much
Post automatically merged:

I did get this but I have no idea how it works :( I tried reading it but was a bit much
I put it in there but I don't see anything red and there are 2 diff ones. debuggable and developer one. Also I hit debug in the window and nothing happens.
 
Last edited:

GoldDraco13

Silver Donator
Aug 1, 2014
182
157
47
Canada
mycy4.com
Donate
Donate money to this user
Beginner error message help info

Your error

Errors:
+ Quests/Ancient White Tiger Quest/VirtuesBox.cs:
CS1022: Line 94: Type or namespace definition, or end-of-file expected

An error message always gives full path of error but the most important part it the first line after the error, in purple it tells you the file it came from, the next in orange is the line number (Extremely important, in note pad you can turn on status bar,) which on the bottom right of note pad tells you line number, use this to find the line in question and then the error message in green, most errors are syntax error, basically spelling errors in c#, in your case you forgot to close a line of code with a ;

the standard syntax for c#

Methods always have a opening { and closing } and within the method, we can have lines of code that perform value changes call values etc etc and these lines need to be ended with a ;

public void ThisMethod()
{

string lineofcode = "this is a line of code";

}

I hope this helps, the error you have is a simple mistake we all make, the hard part without VS is to understand where it is and how to fix it. I spent my learning years in note pad, it did make life harder but I learnt a lot prior to using VS, which I highly advise getting, but don't jump into working on this project learning VS, go watch some youtube videos that teach from hello world in VS environment!

This is a great video, even though He uses a older version of VS, you'll have no problem using new versions after you watch this.

 
  • Like
Reactions: Candy Apple

Candy Apple

Well-Known Member
Nov 14, 2016
269
25
45
Beginner error message help info

Your error

Errors:
+ Quests/Ancient White Tiger Quest/VirtuesBox.cs:
CS1022: Line 94: Type or namespace definition, or end-of-file expected

An error message always gives full path of error but the most important part it the first line after the error, in purple it tells you the file it came from, the next in orange is the line number (Extremely important, in note pad you can turn on status bar,) which on the bottom right of note pad tells you line number, use this to find the line in question and then the error message in green, most errors are syntax error, basically spelling errors in c#, in your case you forgot to close a line of code with a ;

the standard syntax for c#

Methods always have a opening { and closing } and within the method, we can have lines of code that perform value changes call values etc etc and these lines need to be ended with a ;

public void ThisMethod()
{

string lineofcode = "this is a line of code";

}

I hope this helps, the error you have is a simple mistake we all make, the hard part without VS is to understand where it is and how to fix it. I spent my learning years in note pad, it did make life harder but I learnt a lot prior to using VS, which I highly advise getting, but don't jump into working on this project learning VS, go watch some youtube videos that teach from hello world in VS environment!

This is a great video, even though He uses a older version of VS, you'll have no problem using new versions after you watch this.

I don't understand really because all I did was use the same script from the other quest I made that works fine and I got no errors on that. All I did was change names of items and name of the .cs and nothing looks Diff side by side in notepad this is why im a bit confused.
Post automatically merged:

Try this one, not on my computer, cant test if it compiles
Nope this script don't like me at all and it is no diff than my other working ones, That's whats so strange.


--------------------------------------------------------------------------------
ServUO - [http://www.servuo.com] Version 0.5, Build 6437.20990
Publish 54
Core: Optimizing for 4 64-bit processors
RandomImpl: CSPRandom (Software)
Core: Loading config...
Scripts: Compiling C# scripts...Failed with: 1 errors, 0 warnings
Errors:
+ Quests/Ancient White Tiger Quest/VirtuesBoxFixed.cs:
CS1518: Line 56: Expected class, delegate, enum, interface, or struct
CS1518: Line 58: Expected class, delegate, enum, interface, or struct
CS1518: Line 64: Expected class, delegate, enum, interface, or struct
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
 
Last edited:

GoldDraco13

Silver Donator
Aug 1, 2014
182
157
47
Canada
mycy4.com
Donate
Donate money to this user
You were missing 3 closing brackets in your OnDoubleClick method

Code:
using System;
using Server;
using Server.Gumps;
using Server.Network;
using System.Collections;
using Server.Multis;
using Server.Mobiles;

namespace Server.Items
{
    public class VirtuesBox : Item
    {
        [Constructable]
        public VirtuesBox() : this(null) {}

        [Constructable]
        public VirtuesBox(string name) : base(0x0E76)
        {
            Name = "VirtuesBox";
            LootType = LootType.Blessed;
            Hue = 288;
        }

        public override void OnDoubleClick(Mobile m)
        {
            Item a = m.Backpack.FindItemByType(typeof (Compassion));
            if (a != null)
            {
                Item b = m.Backpack.FindItemByType(typeof (Honesty1));
                if (b != null)
                {
                    Item c = m.Backpack.FindItemByType(typeof (Honor));
                    if (c != null)
                    {
                        Item d = m.Backpack.FindItemByType(typeof (Humility));
                        if (d != null)
                        {
                            Item e = m.Backpack.FindItemByType(typeof (Justice));
                            if (e != null)
                            {
                                Item f = m.Backpack.FindItemByType(typeof (Sacrifice));
                                if (f != null)
                                {
                                    Item g = m.Backpack.FindItemByType(typeof (Spirituality));
                                    if (g != null)
                                    {
                                        Item h = m.Backpack.FindItemByType(typeof (Valor));
                                        if (h != null)
                                        {

                                        m.AddToBackpack(new FullVirtuesBox());
                                        a.Delete();
                                        b.Delete();
                                        c.Delete();
                                        d.Delete();
                                        e.Delete();
                                        f.Delete();
                                        g.Delete();
                                        h.Delete();
                                        m.SendMessage("You fill the box with the vitrues!");
                                        this.Delete();

                                        }
                                       else
                                       {
                                       m.SendMessage("You are missing one or more virtues");
                                       }
                                    }
                                 }
                            }
                        }  
                    }
                }
            }

            else
            {
                m.SendMessage("You are missing one or more pet supplies.  They must be in stacks of 10!");
            }
        }

        public VirtuesBox(Serial serial) : base(serial) {}

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write((int) 0);
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();
        }
    }
}
 
Last edited:

Candy Apple

Well-Known Member
Nov 14, 2016
269
25
45
You were missing 3 closing brackets in your OnDoubleClick method

Code:
using System;
using Server;
using Server.Gumps;
using Server.Network;
using System.Collections;
using Server.Multis;
using Server.Mobiles;

namespace Server.Items
{
    public class VirtuesBox : Item
    {
        [Constructable]
        public VirtuesBox() : this(null) {}

        [Constructable]
        public VirtuesBox(string name) : base(0x0E76)
        {
            Name = "VirtuesBox";
            LootType = LootType.Blessed;
            Hue = 288;
        }

        public override void OnDoubleClick(Mobile m)
        {
            Item a = m.Backpack.FindItemByType(typeof (Compassion));
            if (a != null)
            {
                Item b = m.Backpack.FindItemByType(typeof (Honesty1));
                if (b != null)
                {
                    Item c = m.Backpack.FindItemByType(typeof (Honor));
                    if (c != null)
                    {
                        Item d = m.Backpack.FindItemByType(typeof (Humility));
                        if (d != null)
                        {
                            Item e = m.Backpack.FindItemByType(typeof (Justice));
                            if (e != null)
                            {
                                Item f = m.Backpack.FindItemByType(typeof (Sacrifice));
                                if (f != null)
                                {
                                    Item g = m.Backpack.FindItemByType(typeof (Spirituality));
                                    if (g != null)
                                    {
                                        Item h = m.Backpack.FindItemByType(typeof (Valor));
                                        if (h != null)
                                        {

                                        m.AddToBackpack(new FullVirtuesBox());
                                        a.Delete();
                                        b.Delete();
                                        c.Delete();
                                        d.Delete();
                                        e.Delete();
                                        f.Delete();
                                        g.Delete();
                                        h.Delete();
                                        m.SendMessage("You fill the box with the vitrues!");
                                        this.Delete();

                                        }
                                       else
                                       {
                                       m.SendMessage("You are missing one or more virtues");
                                       }
                                    }
                                 }
                            }
                        }
                    }
                }
            }

            else
            {
                m.SendMessage("You are missing one or more pet supplies.  They must be in stacks of 10!");
            }
        }

        public VirtuesBox(Serial serial) : base(serial) {}

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write((int) 0);
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();
        }
    }
}
wow guess I was looking to hard. Im going to save and keep this to remind me how simple and easy something can be looked over
using System;
using Server;
using Server.Gumps;
using Server.Network;
using System.Collections;
using Server.Multis;
using Server.Mobiles;

namespace Server.Items
{
public class VirtuesBox : Item
{
[Constructable]
public VirtuesBox() : this(null) {}

[Constructable]
public VirtuesBox(string name) : base(0x0E76)
{
Name = "VirtuesBox";
LootType = LootType.Blessed;
Hue = 288;
}

public override void OnDoubleClick(Mobile m)
{
Item a = m.Backpack.FindItemByType(typeof (Compassion));
if (a != null)
{
Item b = m.Backpack.FindItemByType(typeof (Honesty1));
if (b != null)
{
Item c = m.Backpack.FindItemByType(typeof (Honor));
if (c != null)
{
Item d = m.Backpack.FindItemByType(typeof (Humility));
if (d != null)
{
Item e = m.Backpack.FindItemByType(typeof (Justice));
if (e != null)
{
Item f = m.Backpack.FindItemByType(typeof (Sacrifice));
if (f != null)
{
Item g = m.Backpack.FindItemByType(typeof (Spirituality));
if (g != null)
{
Item h = m.Backpack.FindItemByType(typeof (Valor));
if (h != null)
{

m.AddToBackpack(new FullVirtuesBox());
a.Delete();
b.Delete();
c.Delete();
d.Delete();
e.Delete();
f.Delete();
g.Delete();
h.Delete();
m.SendMessage("You fill the box with the vitrues!");
this.Delete();

}
else
{
m.SendMessage("You are missing one or more virtues");
}
}
}
}
}
}
}
}

else
{
m.SendMessage("You are missing one or more pet supplies. They must be in stacks of 10!");
}
}

public VirtuesBox(Serial serial) : base(serial) {}

public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int) 0);
}

public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
}
 
  • Like
Reactions: GoldDraco13

Candy Apple

Well-Known Member
Nov 14, 2016
269
25
45
Ok Like I was saying look at both these and tell me what's diff because when I look at them I see nothing. All I did was change the names that's all. If you find where I missed something please hightlight it so I can see it because like I said side my side their the same.. Thanks again and sorry to be a bother I just don't understand why one works and the other don't and they are the same script?



--------------------------------------------------------------------------------

ServUO - [http://www.servuo.com] Version 0.5, Build 6437.20990
Publish 54
Core: Optimizing for 4 64-bit processors
RandomImpl: CSPRandom (Software)
Core: Loading config...
Scripts: Compiling C# scripts...Failed with: 1 errors, 0 warnings
Errors:
+ Quests/1My Quest/Handy the Artist/HandysSupplyBox.cs:
CS0116: Line 133: A namespace cannot directly contain members such as fields
or methods
CS1022: Line 141: Type or namespace definition, or end-of-file expected
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
 

Attachments

sahisahi

Well-Known Member
Jan 13, 2016
785
72
This one compiles.

Inside hanysupplybox, you had :


C#:
 public VirtuesBox(Serial serial) : base(serial)
        {
           
        }
instead of

C#:
 public HandySupplyBox (Serial serial) : base(serial)
        {
           
        }
and few wrong brackets
 

Attachments

Candy Apple

Well-Known Member
Nov 14, 2016
269
25
45
This one compiles.

Inside hanysupplybox, you had :


C#:
 public VirtuesBox(Serial serial) : base(serial)
        {
          
        }
instead of

C#:
 public HandySupplyBox (Serial serial) : base(serial)
        {
          
        }
and few wrong brackets
Could you show me the wrong brackets please and I see the space now Gezz Scripting is a mess LOL
Post automatically merged:

Could you show me the wrong brackets please and I see the space now Gezz Scripting is a mess LOL
OK this is what I got with the one you gave me..

--------------------------------------------------------------------------------

ServUO - [http://www.servuo.com] Version 0.5, Build 6437.20990
Publish 54
Core: Optimizing for 4 64-bit processors
RandomImpl: CSPRandom (Software)
Core: Loading config...
Scripts: Compiling C# scripts...Failed with: 1 errors, 0 warnings
Errors:
+ Quests/1My Quest/Handy the Artist/HandysSupplyBox.cs:
CS0116: Line 133: A namespace cannot directly contain members such as fields
or methods
CS1022: Line 141: Type or namespace definition, or end-of-file expected
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
 

Candy Apple

Well-Known Member
Nov 14, 2016
269
25
45
Seems to be yes and could you show me where the brackets were wrong? I know C# is picky im finding out.. Because side by side they look the same to me. Maybe I need glasses lol It works and yes I do see the { } that are in diff locations now, but still funny some work and some don't. Thanks for you help in this.
 
Last edited:

GoldDraco13

Silver Donator
Aug 1, 2014
182
157
47
Canada
mycy4.com
Donate
Donate money to this user
Just do a count, so if there are 25 { then there has to be 25 }



One additional tip for beginners to be able to understand the code, is to know the difference between a method and a line of code.

Method
Method always has the following format but it can look different depending on how someone writes it.
Code:
public void Method(Mobile m, string s)
{
          //Lines of code here
}
can look like this for example
Code:
public void Method(Mobile m, string s){//Lines of code here}
and there are other formats I've seen, specially when using Lambda Expressions and such!

Line of code
Lines of code always end with a ;

Using the example above, we'll add a few lines of code
Code:
public void Method(Mobile m, string s)
{
          string message = s;
          m.SendMessage(message);
}
or like above it can be written
Code:
public void Method(Mobile m, string s){string message = s; m.SendMessage(message);}
I hope this helps, it is the basics imo and a good starting point to understand c#, though understand this just scratches the surface of everything we could talk about when it comes to c#
 
  • Like
Reactions: Candy Apple