Search Unity

error CS1525: Unexpected symbol `void'

Discussion in 'Scripting' started by Fusia_, Jul 29, 2018.

  1. Fusia_

    Fusia_

    Joined:
    Apr 23, 2017
    Posts:
    16
    I started learning C# recently and other threads / videos don't seem to help me to understand my issue.

    I'm making a music rhythm game for my computer science Alevel coursework next year and they suggested that we started early.

    The section of code I'm writing here involves destroying a note once the corresponding key has been hit in time with the music.

    Here's the code:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class SongControl : MonoBehaviour
    6. {
    7.  
    8.     public Transform Left;
    9.     public Transform Right;
    10.     public Transform Up;
    11.     public Transform Down;
    12.  
    13.     public float songlength = 0;
    14.  
    15.     public KeyCode keyLeft;
    16.     public KeyCode keyRight;
    17.     public KeyCode keyUp;
    18.     public KeyCode keyDown;
    19.  
    20.     public static string destroyBleft = "n";
    21.     public static string destroyGright = "n";
    22.     public static string destroyRup = "n";
    23.     public static string destroyOdown = "n";
    24.  
    25.     void FixedUpdate () {
    26.         songlength += Time.deltaTime;
    27.  
    28.         if ((songlength>=.1) && (songlength<=.125))
    29.         {
    30.             Instantiate(Left.position, Left.rotation);
    31.         }
    32.    
    33.     }
    34. }
    35.  
    36. void OnTriggerStay2D(Collider2D other)
    37. {
    38.  
    39.         if ((Input.GetKeyLeft(KeyLeft)) && (other.gameobject.name == "BlueLeft(Clone)"))
    40.         {
    41.             destroyLeft = "y";
    42.         }
    43.  
    44.         if ((Input.GetKeyRight(KeyRight)) && (other.gameobject.name == "GreenRight(Clone)"))
    45.         {
    46.             destroyLeft = "y";
    47.         }
    48.  
    49.         if ((Input.GetKeyUp(KeyUp)) && (other.gameobject.name == "RedUp(Clone)"))
    50.         {
    51.             destroyLeft = "y";
    52.         }
    53.  
    54.         if ((Input.GetKeyDown(KeyDown)) && (other.gameobject.name == "OrangeDown(Clone)"))
    55.         {
    56.             destroyLeft = "y";
    57.         }
    58.  
    59.     }
    60.  
    61. }
     
    Last edited: Jul 30, 2018
  2. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    Please use code tags when you want to add code to your posts.

    You should also include a little more code, so that we see what else does exist, especially which scopes.
    That error says 'void' isn't expected. In this particular case, the method appears to be defined within a scope that cannot contain the method. Based on the indentation, it seems you've put the method outside of the type's definition (it ends before the method starts) and you also seem to have one curly bracket at the end that should be removed.
     
  3. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    I would expect that to be the closing curly for the class definition. However, as you said, we need to see the full code. I suspect a bracket prior to this code is missing.
     
  4. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    Usually, when they suggested to start early in a course / lecture, I don't expect students to start head-diving into Unity without knowing how to understand and fix compiler errors.

    I would think Unity courses to be a sophomore or junior undergraduate course level, because the students need to learn about compiler errors somewhere in a computer science freshman course level. But that's just my conjecture based on my personal experience at an university.

    May I ask how are your skills in terms of proficiency in C# ?
     
    Last edited: Jul 30, 2018
  5. Prastiwar

    Prastiwar

    Joined:
    Jul 29, 2017
    Posts:
    125
  6. Fusia_

    Fusia_

    Joined:
    Apr 23, 2017
    Posts:
    16
    I basically have no skills in C# but will be learning from the start of September when I start year 13, We were originally going to use MonkeyX, However Unity was stated in the paperwork as an alternative to which a majority of us have chosen to use.

    I'm in the Sixth Form so it may be fairly different to how a University would approach such coursework.
     
  7. Fusia_

    Fusia_

    Joined:
    Apr 23, 2017
    Posts:
    16
    Sorry, I'm pretty new to coding in C# & Unity, I looked at the code tags link you linked and have now added the code to this post.
     
  8. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    On line 34 you close the class definition. (Closing curly '}', this means that you try to define a method outside of the class, which you cannot do in C#) just remove that it it should work. Simply put, you have an extra bracket. (Not even Unity specific, just general programming and simple debugging there)

    EDIT: Also good luck with your A Levels :D I start Computer Science at University soon.
     
    Fusia_ likes this.
  9. Fusia_

    Fusia_

    Joined:
    Apr 23, 2017
    Posts:
    16
    Thanks! At least I know how to fix that now, now I need to sort out the new errors about names not existing in their current context, But that's progress & I should be able to sort this out now.

    Have fun at Uni :D
     
    TaleOf4Gamers likes this.
  10. dryslukd

    dryslukd

    Joined:
    Mar 28, 2020
    Posts:
    2
    For a long time I can't understand what the matter is, it seems like everything is fine everywhere, or maybe I'm blind

    Error while compiling: SkyMenu.cs(550,16): error CS1525: Unexpected symbol `void', expecting `class', `delegate', `enum', `interface', `partial', or `struct'

    If it doesn't bother you, please help me


    Code (CSharp):
    1. using Oxide.Core.Plugins;
    2. using Oxide.Game.Rust.Cui;
    3. using System;
    4. using System.Collections;
    5. using System.Collections.Generic;
    6. using System.Linq;
    7. using System.Globalization;
    8. using UnityEngine;
    9. using Color = UnityEngine.Color;
    10. using Random = UnityEngine.Random;
    11.  
    12. namespace Oxide.Plugins
    13. {
    14.     [Info("SkyMenu", "JoyRax", "0.0.1")]
    15.     [Description("Menu game info")]
    16.     class SkyMenu : RustPlugin
    17.     {
    18.         #region Vars
    19.         [PluginReference] private Plugin ImageLibrary, NTeleportation;
    20.         private string MainLayer = "ui_main";
    21.  
    22.         #endregion
    23.  
    24.         #region Configuration
    25.  
    26.         private class PluginConfig
    27.         {
    28.             public CuiStandardElementSetting _CuiStandardElementSetting;
    29.             public CuiServerNameSetting _CuiServerNameSetting;
    30.             public CuiAvatarSetting _CuiAvatarSetting;
    31.             public List<CuiUButtonSetting> _CuiUButtonSetting;
    32.         }
    33.  
    34.         private class Anchor
    35.         {
    36.             public string Min;
    37.             public string Max;
    38.         }
    39.  
    40.         private class CuiStandardElementSetting
    41.         {
    42.             public string BackgroundColor;
    43.             public Anchor Anchor;
    44.             public bool CursorEnabled;
    45.             public string Layer;
    46.         }
    47.  
    48.         private class CuiServerNameSetting
    49.         {
    50.             public string NameServer;
    51.             public string BackgroundColor;
    52.             public string TextColor;
    53.             public Anchor Anchor;
    54.             public string ELParent;
    55.             public string ELName;
    56.             public string Font;
    57.             public int FontSize;
    58.         }
    59.  
    60.         private class CuiAvatarSetting
    61.         {
    62.             public string BackgroundColor;
    63.             public string TextColor;
    64.             public Anchor Anchor;
    65.             public string ELParent;
    66.             public string ELName;
    67.             public string ELNameImage;
    68.             public string ELNameText;
    69.             public string Font;
    70.             public int FontSize;
    71.         }
    72.  
    73.         private class CuiStandardButtonSetting
    74.         {
    75.             public string BackgroundColor;
    76.             public string SmallBackgroundColor;
    77.             public string TextColor;
    78.             public string ELParent;
    79.             public string ELName;
    80.             public string ELSmallName;
    81.             public string Font;
    82.             public int FontSize;
    83.             public int FontSizeSmall;
    84.         }
    85.  
    86.         private class CuiUButtonSetting : CuiStandardButtonSetting
    87.         {
    88.             public Anchor Anchor;
    89.             public string SmallText;
    90.             public string Text;
    91.             public string Command;
    92.         }
    93.  
    94.         private PluginConfig _config;
    95.  
    96.         protected override void LoadDefaultConfig()
    97.         {
    98.             Config.WriteObject(GetDefaultConfig(), true);
    99.         }
    100.  
    101.         private PluginConfig GetDefaultConfig()
    102.         {
    103.             return new PluginConfig
    104.             {
    105.                 _CuiStandardElementSetting = new CuiStandardElementSetting
    106.                 {
    107.                     BackgroundColor = "0 0 0 0.5",
    108.                     Anchor = new Anchor
    109.                     {
    110.                         Min = "0 0",
    111.                         Max = "1 1"
    112.                     },
    113.                     CursorEnabled = true,
    114.                     Layer = MainLayer
    115.                 },
    116.                 _CuiServerNameSetting = new CuiServerNameSetting
    117.                 {
    118.                     NameServer = "POISON RUST",
    119.                     BackgroundColor = "0 0 0 0.9",
    120.                     TextColor = "255 255 255 0.5",
    121.                     Anchor = new Anchor
    122.                     {
    123.                         Min = "0 0.944",
    124.                         Max = "1 1"
    125.                     },
    126.                     ELParent = MainLayer,
    127.                     ELName = MainLayer + ".PanelNameServer",
    128.                     Font = "robotocondensed-bold.ttf",
    129.                     FontSize = 22;
    130.                 }
    131.                 _CuiAvatarSetting = new CuiAvatarSetting
    132.                 {
    133.                     BackgroundColor = "0 0 0 0.9",
    134.                     TextColor = "255 255 255 0.5",
    135.                     Anchor = new Anchor
    136.                     {
    137.                         Min = "0.25 0.542",
    138.                         Max = "0.352 0.764"
    139.                     },
    140.                     ELParent = MainLayer,
    141.                     ELName = MainLayer = ".Avatar",
    142.                     ELNameImage = MainLayer = ".AvatarImage",
    143.                     ELNameText = MainLayer = ".AvatarText",
    144.                     Font = "robotocondensed-bold.ttf",
    145.                     FontSize = 20
    146.                 }
    147.  
    148.                 _CuiUButtonSetting = new List<CuiUButtonSetting>()
    149.                 {
    150.                     new CuiUButtonSetting
    151.                     {
    152.                         BackgroundColor = "0 0 0 0.9",
    153.                         SmallBackgroundColor = "255 255 255 0.05",
    154.                         TextColor = "255 255 255 0.5",
    155.                         ELParent = MainLayer,
    156.                         ELName = MainLayer + ".StandardButton",
    157.                         ELSmallName = MainLayer + ".StandardButtonSmallText",
    158.                         Font = "robotocondensed-bold.ttf",
    159.                         FontSize = 20,
    160.                         FontSizeSmall = 12,
    161.                         Anchor = new Anchor
    162.                         {
    163.                             Min = "0.25 0.465",
    164.                             Max = "0.352 0.535"
    165.                         },
    166.                         SmallText = "OPEN",
    167.                         Text = "STATISTICS",
    168.                         Command = "chat.say /test"
    169.                     },
    170.                     new CuiUButtonSetting
    171.                     {
    172.                         BackgroundColor = "0 0 0 0.9",
    173.                         SmallBackgroundColor = "255 255 255 0.05",
    174.                         TextColor = "255 255 255 0.5",
    175.                         ELParent = MainLayer,
    176.                         ELName = MainLayer + ".StandardButton",
    177.                         ELSmallName = MainLayer + ".StandardButtonSmallText",
    178.                         Font = "robotocondensed-bold.ttf",
    179.                         FontSize = 20,
    180.                         FontSizeSmall = 12,
    181.                         Anchor = new Anchor
    182.                         {
    183.                             Min = "0.25 0.389",
    184.                             Max = "0.352 0.458"
    185.                         },
    186.                         SmallText = "ACCEPT",
    187.                         Text = "TELEPORT",
    188.                         Command = "chat.say /test"
    189.                     },
    190.                     new CuiUButtonSetting
    191.                     {
    192.                         BackgroundColor = "0 0 0 0.9",
    193.                         SmallBackgroundColor = "255 255 255 0.05",
    194.                         TextColor = "255 255 255 0.5",
    195.                         ELParent = MainLayer,
    196.                         ELName = MainLayer + ".StandardButton",
    197.                         ELSmallName = MainLayer + ".StandardButtonSmallText",
    198.                         Font = "robotocondensed-bold.ttf",
    199.                         FontSize = 20,
    200.                         FontSizeSmall = 12,
    201.                         Anchor = new Anchor
    202.                         {
    203.                             Min = "0.25 0.313",
    204.                             Max = "0.352 0.382"
    205.                         },
    206.                         SmallText = "ACCEPT",
    207.                         Text = "TRADE",
    208.                         Command = "chat.say /test"
    209.                     },
    210.                     new CuiUButtonSetting
    211.                     {
    212.                         BackgroundColor = "0 0 0 0.9",
    213.                         SmallBackgroundColor = "255 255 255 0.05",
    214.                         TextColor = "255 255 255 0.5",
    215.                         ELParent = MainLayer,
    216.                         ELName = MainLayer + ".StandardButton",
    217.                         ELSmallName = MainLayer + ".StandardButtonSmallText",
    218.                         Font = "robotocondensed-bold.ttf",
    219.                         FontSize = 20,
    220.                         FontSizeSmall = 12,
    221.                         Anchor = new Anchor
    222.                         {
    223.                             Min = "0.25 0.236",
    224.                             Max = "0.352 0.306"
    225.                         },
    226.                         SmallText = "OPEN",
    227.                         Text = "WIPE BLOCK",
    228.                         Command = "chat.say /test"
    229.                     },
    230.                     new CuiUButtonSetting
    231.                     {
    232.                         BackgroundColor = "0 0 0 0.9",
    233.                         SmallBackgroundColor = "255 255 255 0.05",
    234.                         TextColor = "255 255 255 0.5",
    235.                         ELParent = MainLayer,
    236.                         ELName = MainLayer + ".StandardButton",
    237.                         ELSmallName = MainLayer + ".StandardButtonSmallText",
    238.                         Font = "robotocondensed-bold.ttf",
    239.                         FontSize = 20,
    240.                         FontSizeSmall = 12,
    241.                         Anchor = new Anchor
    242.                         {
    243.                             Min = "0.355 0.694",
    244.                             Max = "0.457 0.764"
    245.                         },
    246.                         SmallText = "OPEN",
    247.                         Text = "KITS",
    248.                         Command = "chat.say /test"
    249.                     },
    250.                     new CuiUButtonSetting
    251.                     {
    252.                         BackgroundColor = "0 0 0 0.9",
    253.                         SmallBackgroundColor = "255 255 255 0.05",
    254.                         TextColor = "255 255 255 0.5",
    255.                         ELParent = MainLayer,
    256.                         ELName = MainLayer + ".StandardButton",
    257.                         ELSmallName = MainLayer + ".StandardButtonSmallText",
    258.                         Font = "robotocondensed-bold.ttf",
    259.                         FontSize = 20,
    260.                         FontSizeSmall = 12,
    261.                         Anchor = new Anchor
    262.                         {
    263.                             Min = "0.355 0.618",
    264.                             Max = "0.457 0.688"
    265.                         },
    266.                         SmallText = "OPEN",
    267.                         Text = "CASES",
    268.                         Command = "chat.say /test"
    269.                     },
    270.                     new CuiUButtonSetting
    271.                     {
    272.                         BackgroundColor = "0 0 0 0.9",
    273.                         SmallBackgroundColor = "255 255 255 0.05",
    274.                         TextColor = "255 255 255 0.5",
    275.                         ELParent = MainLayer,
    276.                         ELName = MainLayer + ".StandardButton",
    277.                         ELSmallName = MainLayer + ".StandardButtonSmallText",
    278.                         Font = "robotocondensed-bold.ttf",
    279.                         FontSize = 20,
    280.                         FontSizeSmall = 12,
    281.                         Anchor = new Anchor
    282.                         {
    283.                             Min = "0.355 0.542",
    284.                             Max = "0.457 0.611"
    285.                         },
    286.                         SmallText = "SEND",
    287.                         Text = "TICKET",
    288.                         Command = "chat.say /test"
    289.                     },
    290.                     new CuiUButtonSetting
    291.                     {
    292.                         BackgroundColor = "0 0 0 0.9",
    293.                         SmallBackgroundColor = "255 255 255 0.05",
    294.                         TextColor = "255 255 255 0.5",
    295.                         ELParent = MainLayer,
    296.                         ELName = MainLayer + ".StandardButton",
    297.                         ELSmallName = MainLayer + ".StandardButtonSmallText",
    298.                         Font = "robotocondensed-bold.ttf",
    299.                         FontSize = 20,
    300.                         FontSizeSmall = 12,
    301.                         Anchor = new Anchor
    302.                         {
    303.                             Min = "0.355 0.465",
    304.                             Max = "0.457 0.535"
    305.                         },
    306.                         SmallText = "OPEN",
    307.                         Text = "STORE",
    308.                         Command = "chat.say /test"
    309.                     },
    310.                     new CuiUButtonSetting
    311.                     {
    312.                         BackgroundColor = "0 0 0 0.9",
    313.                         SmallBackgroundColor = "255 255 255 0.05",
    314.                         TextColor = "255 255 255 0.5",
    315.                         ELParent = MainLayer,
    316.                         ELName = MainLayer + ".StandardButton",
    317.                         ELSmallName = MainLayer + ".StandardButtonSmallText",
    318.                         Font = "robotocondensed-bold.ttf",
    319.                         FontSize = 20,
    320.                         FontSizeSmall = 12,
    321.                         Anchor = new Anchor
    322.                         {
    323.                             Min = "0.355 0.389",
    324.                             Max = "0.457 0.458"
    325.                         },
    326.                         SmallText = "OPEN",
    327.                         Text = "INFO",
    328.                         Command = "chat.say /test"
    329.                     },
    330.                     new CuiUButtonSetting
    331.                     {
    332.                         BackgroundColor = "0 0 0 0.9",
    333.                         SmallBackgroundColor = "255 255 255 0.05",
    334.                         TextColor = "255 255 255 0.5",
    335.                         ELParent = MainLayer,
    336.                         ELName = MainLayer + ".StandardButton",
    337.                         ELSmallName = MainLayer + ".StandardButtonSmallText",
    338.                         Font = "robotocondensed-bold.ttf",
    339.                         FontSize = 20,
    340.                         FontSizeSmall = 12,
    341.                         Anchor = new Anchor
    342.                         {
    343.                             Min = "0.355 0.313",
    344.                             Max = "0.457 0.382"
    345.                         },
    346.                         SmallText = "OPEN",
    347.                         Text = "VK GROUP",
    348.                         Command = "chat.say /test"
    349.                     },
    350.                     new CuiUButtonSetting
    351.                     {
    352.                         BackgroundColor = "0 0 0 0.9",
    353.                         SmallBackgroundColor = "255 255 255 0.05",
    354.                         TextColor = "255 255 255 0.5",
    355.                         ELParent = MainLayer,
    356.                         ELName = MainLayer + ".StandardButton",
    357.                         ELSmallName = MainLayer + ".StandardButtonSmallText",
    358.                         Font = "robotocondensed-bold.ttf",
    359.                         FontSize = 20,
    360.                         FontSizeSmall = 12,
    361.                         Anchor = new Anchor
    362.                         {
    363.                             Min = "0.355 0.236",
    364.                             Max = "0.457 0.306"
    365.                         },
    366.                         SmallText = "OPEN",
    367.                         Text = "DISCORD",
    368.                         Command = "chat.say /test"
    369.                     }
    370.                 };
    371.             };
    372.         }
    373.  
    374.         private void SaveConfig()
    375.         {
    376.             Config.WriteObject(_config, true);
    377.         }
    378.  
    379.         #endregion
    380.  
    381.         #region Init
    382.  
    383.         void OnServerInitialized(bool serverInitialized)
    384.         {
    385.             _config = Config.ReadObject<PluginConfig>();
    386.         }
    387.  
    388.         #endregion
    389.  
    390.         #region CuiRustCustomHelper
    391.  
    392.         private static class CuiRustCustomHelper
    393.         {
    394.             public static CuiElementContainer GettingStandardElement(CuiStandardElementSetting _setting)
    395.             {
    396.                 var container = new CuiElementContainer();
    397.  
    398.                 container.Add(new CuiPanel
    399.                 {
    400.                     Image = { Color = "0 0 0 0" },
    401.                     RectTransform = { AnchorMin = _setting.Anchor.Min, AnchorMax = _setting.Anchor.Max },
    402.                     CursorEnabled = _setting.CursorEnabled,
    403.                 }, "Overlay", _setting.Layer);
    404.  
    405.                 container.Add(new CuiElement
    406.                 {
    407.                     Parent = LayerMain,
    408.                     Components =
    409.                     {
    410.                         new CuiRawImageComponent { Color = _setting.BackgroundColor, FadeIn = 0.5f, Sprite = "assets/content/ui/ui.background.tiletex.psd", Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat" },
    411.                         new CuiRectTransformComponent{ AnchorMin = "0 0", AnchorMax = "1 1" }
    412.                     }
    413.                 });
    414.  
    415.                 return container;
    416.             }
    417.  
    418.             public static CuiElementContainer GettingServerNameElement(CuiServerNameSetting _setting)
    419.             {
    420.                 var container = new CuiElementContainer();
    421.  
    422.                 container.Add(new CuiElement
    423.                 {
    424.                     Parent = _setting.ELParent,
    425.                     Name = _setting.ELName,
    426.                     Components =
    427.                     {
    428.                         new CuiImageComponent { FadeIn = 0.25f, Color = _setting.BackgroundColor} ,
    429.                         new CuiRectTransformComponent { AnchorMin = _setting.Anchor.Min, AnchorMax = _setting.Anchor.Max }
    430.                     }
    431.                 });
    432.                 container.Add(new CuiElement
    433.                 {
    434.                     Parent = _setting.ELName,
    435.                     Components = {
    436.                         new CuiTextComponent() { Color = _setting.TextColor, FadeIn = 1f, Text = _setting.NameServer, FontSize = _setting.FontSize, Align = TextAnchor.MiddleCenter, Font = _setting.Font },
    437.                         new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1" },
    438.                     }
    439.                 });
    440.  
    441.                 return container;
    442.             }
    443.  
    444.             public static CuiElementContainer GettingAvatarElement(BasePlayer player, CuiAvatarSetting _setting)
    445.             {
    446.                 var container = new CuiElementContainer();
    447.  
    448.                 container.Add(new CuiElement
    449.                 {
    450.                     Parent = _setting.ELParent,
    451.                     Name = _setting.ELName,
    452.                     Components =
    453.                     {
    454.                         new CuiImageComponent {FadeIn = 0.25f, Color = _setting.BackgroundColor},
    455.                         new CuiRectTransformComponent { AnchorMin = _setting.Anchor.Min, AnchorMax = _setting.Anchor.Max }
    456.                     }
    457.                 });
    458.                 container.Add(new CuiElement
    459.                 {
    460.                     Parent = _setting.ELName,
    461.                     Name = _setting.ELNameImage,
    462.                     Components =
    463.                     {
    464.                         new CuiImageComponent {FadeIn = 0.25f, Color = "0 0 0 0"},
    465.                         new CuiRectTransformComponent {AnchorMin = "0 0.188", AnchorMax = "1 1"}
    466.                     }
    467.                 });
    468.                 container.Add(new CuiElement
    469.                 {
    470.                     Parent = _setting.ELNameImage,
    471.                     Components =
    472.                     {
    473.                         new CuiRawImageComponent { Png = (string) ImageLibrary.Call("GetImage", player.UserIDString) },
    474.                         new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0" }
    475.                     }
    476.                 });
    477.                 container.Add(new CuiElement
    478.                 {
    479.                     Parent = _setting.ELName,
    480.                     Name = _setting.ELNameText,
    481.                     Components =
    482.                     {
    483.                         new CuiImageComponent {FadeIn = 0.25f, Color = "0 0 0 0"},
    484.                         new CuiRectTransformComponent {AnchorMin = "0 0", AnchorMax = "1 0.188"}
    485.                     }
    486.                 });
    487.                 container.Add(new CuiElement
    488.                 {
    489.                     Parent = _setting.ELNameText,
    490.                     Components = {
    491.                         new CuiTextComponent() { Color = _setting.TextColor, FadeIn = 1f, Text = "<b>"+player.displayName.ToUpper()+"</b>", FontSize = _setting.FontSize, Align = TextAnchor.MiddleCenter, Font = _setting.Font },
    492.                         new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1" },
    493.                     }
    494.                 });
    495.  
    496.                 return container;
    497.             }
    498.  
    499.             public static CuiElementContainer GettingButtonElement(BasePlayer player, List<CuiUButtonSetting> _setting)
    500.             {
    501.                 var container = new CuiElementContainer();
    502.  
    503.                 foreach (var _settingItem in _setting)
    504.                 {
    505.                     container.Add(new CuiElement
    506.                     {
    507.                         Parent = _settingItem.ELParent,
    508.                         Name = _settingItem.ELName,
    509.                         Components = {
    510.                             new CuiImageComponent {FadeIn = 0.25f, Color = _settingItem.BackgroundColor},
    511.                             new CuiRectTransformComponent {AnchorMin = _settingItem.Anchor.Min, AnchorMax = _settingItem.Anchor.Max}
    512.                         }
    513.                     });
    514.                     container.Add(new CuiButton
    515.                     {
    516.                         RectTransform = { AnchorMin = "0 0", AnchorMax = "1 0.7" },
    517.                         Button = { Command = _settingItem.Command, Close = _settingItem.ELParent, Color = "0 0 0 0" },
    518.                         Text = { Color = _settingItem.TextColor, Text = _settingItem.Text, FontSize = _settingItem.FontSize, Align = TextAnchor.MiddleCenter, Font = _settingItem.Font }
    519.                     }, _settingItem.ELName);
    520.                     container.Add(new CuiElement
    521.                     {
    522.                         Parent = _settingItem.ELName,
    523.                         Name = _settingItem.ELSmallName,
    524.                         Components = {
    525.                             new CuiImageComponent {FadeIn = 0.25f, Color = _settingItem.SmallBackgroundColor},
    526.                             new CuiRectTransformComponent {AnchorMin = "0 0.7", AnchorMax = "1 1"}
    527.                         }
    528.                     });
    529.                     container.Add(new CuiElement
    530.                     {
    531.                         Parent = _settingItem.ELSmallName,
    532.                         Components = {
    533.                             new CuiTextComponent() {Color = _settingItem.TextColor, FadeIn = 1f, Text = _settingItem.SmallText, FontSize = _settingItem.FontSize, Align = TextAnchor.MiddleCenter, Font = _settingItem.Font},
    534.                             new CuiRectTransformComponent {AnchorMin = "0 0", AnchorMax = "1 1"}
    535.                         }
    536.                     });
    537.                 }
    538.  
    539.                 return container;
    540.             }
    541.         }
    542.  
    543.         #endregion
    544.  
    545.         #region UI
    546.  
    547.         private void CustomDrawCUI(BasePlayer player)
    548.         {
    549.             CuiHelper.AddUi(player, GettingStandardElement(_config._CuiStandardElementSetting)); // Add Main Layer
    550.             CuiHelper.AddUi(player, GettingServerNameElement(_config._CuiServerNameSetting)); // Add Panel NameServer
    551.             CuiHelper.AddUi(player, GettingAvatarElement(player, _config._CuiAvatarSetting)); // Add Avatar Panel
    552.             CuiHelper.AddUi(player, GettingButtonElement(player, _config._CuiUButtonSetting)); // Add Button Panel
    553.         }
    554.  
    555.         private void CustomDestroyCUI(BasePlayer player)
    556.         {
    557.             CuiHelper.DestroyUi(player, MainLayer);
    558.         }
    559.  
    560.         #endregion
    561.  
    562.         #region Hook
    563.  
    564.         [ChatCommand("menu")]
    565.         private void ChatOpenMenu(BasePlayer player)
    566.         {
    567.             CustomDrawCUI(player);
    568.         }
    569.  
    570.         [ChatCommand("menu.close")]
    571.         private void ChatCloseMenu(BasePlayer player)
    572.         {
    573.             CustomDestroyCUI(player);
    574.         }
    575.  
    576.         [ConsoleCommand("skymenu.open")]
    577.         private void CmdOpenMenu(BasePlayer player)
    578.         {
    579.             CustomDrawCUI(player);
    580.         }
    581.  
    582.         [ConsoleCommand("skymenu.close")]
    583.         private void CmdCloseMenu(BasePlayer player)
    584.         {
    585.             CustomDestroyCUI(player);
    586.         }
    587.  
    588.         #endregion
    589.     }
    590. }
     
  11. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    So at some point, prior to line 550, you most likely just have an extra } or something else in the syntax that is causing curly brackets to mismatch. That's 549 lines on which to find a single } that's not supposed to be there, which reveals the more fundamental problem: This script is just too darn big. It tries to nest too many things as if the number of statements it runs is a finite resource.

    I copied and pasted this into Visual Studio, which means all the indenting got redone to match the syntax. The one area where things really start to look funky begins around line 130, where VS finds a } that it thinks matches up with line 102, probably because of the semicolon on line 129. The script is such a massively overwritten pile of initializers that I'm not willing to go any further in figuring out what it's supposed to be, but I am pretty sure that that semicolon shouldn't be there, though that isn't the only fix needed.
     
    dryslukd likes this.
  12. dryslukd

    dryslukd

    Joined:
    Mar 28, 2020
    Posts:
    2

    Thank you for your help, the file is overloaded with a large bunch of methods because this is a plugin for the Rust game, and I don't compile it, it is done by the modification kernel, already on the server, waking up this morning I started looking at the code, and found both your errors and those what you did not find, the most important thing is that I found an extra ';' on line 370, a couple of commas were also missing in the GetDefaultConfig function, and the truth on line 129 was an extra ';'. And it's true, when the file is heavily overloaded, it's hard to keep everything under control, but I've seen files with up to 20,000 lines and these are top plugins for the Rust game