1. Hi!

    I keep getting the following error:
    GUIAnnouncements.cs(217,21): error CS1525: Unexpected symbol `System'
    For the plugin I am working on: GUIAnnouncements

    I have read through it over and over and I can't seem to find what is causing this error. My feeling is it might be something to do with the addition of the if statements at the end of the GUI region.

    Any help is greatly appreciated.
     
  2. Wulf

    Wulf Community Admin

    Could you post it here please?
     
  3. Yes of course, I just thought it would be better to put it on pastebin.
     

    Attached Files:

  4. Wulf

    Wulf Community Admin

    I didn't notice the PasteBin actually, attachments work best for me.

    Also, why are you using System.Timers.Timer? You should be using Oxide's timer library.
     
  5. Because that is the one that I knew of and I wasn't aware of Oxide's timer library.
     
  6. Wulf

    Wulf Community Admin

    Oxide API for Rust ;)

    I'd recommend using it instead. Might solve your issue too.
     
  7. While it might solve my issue I am very much interested in knowing what is causing it as well.
     
  8. Wulf

    Wulf Community Admin

    Well, the error lines up with your use of the System.Timer, so I'd assume something with that, but I don't have my IDE in front of me to tip me off. :p
     
  9. The interesting thing is that it works perfectly fine until I added in the if statements at the end of the GUI region:

    Code:
                if(!welcomeMsg)
                {
                    foreach (BasePlayer player in BasePlayer.activePlayerList)
                    {
                        CuiHelper.AddUi(player, elements);
                        active = true;
                    }
                    globalTimer.Start();
                    return;
                }
                if(welcomeMsg)
                {
                    for (BasePlayer player)
                    {
                        CuiHelper.AddUi(player, elements);
                        welcomeMsgActive = true;
                        welcomeMsg = false;
                        welcomeMsgTimer.Start();
                        return;
                    }
                }
    Which used to just be:

    Code:
                foreach (BasePlayer player in BasePlayer.activePlayerList)
                {
                    CuiHelper.AddUi(player, elements);
                    active = true;
                }
                timer.Start();
     
  10. Did the code before work as expected?
    Before your timer was called "timer", which is actually the timer library provided by Oxide, meaning it's possible you were calling .Start() in the timer library, which doesn't actually exist.
    The timer library might have shadowed your timer variable.
    So when changing the code, you also changed the name, and it didn't refer to the library anymore.
    Access to System.Timers.Timer might be blocked.
    You should definetly use Oxide's timer library, the reason is explained here: Running a plugin in new thread? | Oxide
    The timer callback has to execute on the main thread of the game server.
     
  11. It did work before as expected. I suppose with that said then I might as well change it to use the timer library properly instead.
    [DOUBLEPOST=1463251658,1463165538][/DOUBLEPOST]Ok, so I have switched it over to using Oxide's timer library, however that issue is persistent but in a different location now.

    I am getting the error:
    [Oxide] 19:43 [Error] GUIAnnouncements.cs(251,10): error CS1525: Unexpected symbol `bool'

    I have attached the file to this post. Help again is appreciated.
     

    Attached Files:

  12. Line 232 is incomplete.
     
  13. What did I miss?
     
  14. for (BasePlayer player) is invalid syntax.
     
  15. Hmm. Ok. What is the correct way to target a specific player?
     
  16. Using a foreach, like you did right above.
     
  17. What would I put after "in" though?
     
  18. BasePlayer.activePlayerList, like you did above?
    Atleast assuming you want to destroy that UI element on all active players.
     
  19. No I don't, just destroy it on a single player. That's what was confusing me about your suggestion :p
    [DOUBLEPOST=1463427344,1463259708][/DOUBLEPOST]
    Are you able to help me with targeting a specific player to send an announcement just to them when they join saying something like "Welcome?"
     
  20. Wulf

    Wulf Community Admin

    Code:
    PrintToChat(player, "Welcome?");