Search Unity

Help me im having errors

Discussion in 'Scripting' started by CookieMonster Games, Sep 30, 2014.

  1. CookieMonster Games

    CookieMonster Games

    Joined:
    Sep 30, 2014
    Posts:
    15
    Please help me i was making a game then in the middle of my PlayerShooting script as i saved it i got some errors in my networkmanager script wich was working great before that and i got some for player shooting too please help me here are the errors. Assets/NetworkManager.cs(26,18): error CS1547: Keyword void' cannot be used in this contextAssets/NetworkManager.cs(26,20): error CS1525: Unexpected symbol (', expecting )', ,', ;', [', or='Assets/Scripts/PlayerShooting.cs(11,20): error CS1519: Unexpected symbol void' in class, struct, or interface member declaration

    here are my scripts and

    Thanks for your help
     
  2. Cpt Chuckles

    Cpt Chuckles

    Joined:
    Dec 31, 2012
    Posts:
    86
    there are no scripts in your post

    copy and paste the scripts into pastebin and then give us the links to them
    www.pastie.org
     
  3. CookieMonster Games

    CookieMonster Games

    Joined:
    Sep 30, 2014
    Posts:
    15
  4. toreau

    toreau

    Joined:
    Feb 8, 2014
    Posts:
    204
    You don't end your Connect() method with a curly bracket.
     
  5. CookieMonster Games

    CookieMonster Games

    Joined:
    Sep 30, 2014
    Posts:
    15
    yeah i tried ending it with a { but it gave me more errors
     
    Last edited: Sep 30, 2014
  6. CookieMonster Games

    CookieMonster Games

    Joined:
    Sep 30, 2014
    Posts:
    15
    also be aware that im doing this off a youtube video and for taht guy it works fine
     
  7. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    Add it again and post the other errors. That curly bracket is neccessary.

    Also, in your shooting script, you miss a semicolon in line 7.
     
  8. CookieMonster Games

    CookieMonster Games

    Joined:
    Sep 30, 2014
    Posts:
    15
    1/3 errors fixed thanks to suddoha
     
  9. CookieMonster Games

    CookieMonster Games

    Joined:
    Sep 30, 2014
    Posts:
    15
    with the curly bracket i get tons of namespace errors and a parsing error it also sais that the bracket is an unexpected symbol and the remaining 2 errors say something about the OnGUI
     
  10. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    Post the error messages please.
     
  11. ZO5KmUG6R

    ZO5KmUG6R

    Joined:
    Jul 15, 2010
    Posts:
    490
    You need to use a closing one to end it
    }

    Not an opening one


    C# works in "blocks" of code

    Block descriptor
    {
    //block content
    }

    A function would be

    void Function1(){

    }

    and so on
     
  12. CookieMonster Games

    CookieMonster Games

    Joined:
    Sep 30, 2014
    Posts:
    15
    Now i get these
    Assets/NetworkManager.cs(27,27): error CS1525: Unexpected symbol `(', expecting `)', `,', `;', `[',
    or `='
    Assets/NetworkManager.cs(64,1): error CS8025: Parsing error
    Assets/NetworkManager.cs(27,26): error CS1547: Keyword `void' cannot be used in this context
     
    Last edited: Oct 1, 2014
  13. CookieMonster Games

    CookieMonster Games

    Joined:
    Sep 30, 2014
    Posts:
    15
    These errors have got me days behind of my project
     
  14. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    Have you used the closing bracket as @aaro4130 suggested? ( i didn't recognize you wrote an opening bracket, of course it needs to be a closing one).
    The other code seems fine.
     
  15. CookieMonster Games

    CookieMonster Games

    Joined:
    Sep 30, 2014
    Posts:
    15
    I made a closed bracket on my void connect and it fixed some errrors and then i tried doing it to the OnGUI and it gave me more so i removed it
     
  16. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    The number of errors isn't a problem. Programming languages are extremely rigid in their structure, and expect the code to work in predefined blocks, called parsing. When you get a parsing error, it means you are missing a structure mark like a semicolon, and this throws everything else out.

    So disregard everything except the first error. Unexpected symbol '(', expecting ')'. You probably have an open bracket somewhere that you haven't closed, or a missing semicolon. That's what all these errors are.

    Loading PlayerShooting into MonoDevelop, the 'void' for Update() is underlined as an error. Look just above it and there's a missing semicolon for 'float cooldown = 0'. You may have other necessary symbols missing.

    Some friendly advice - it sounds like you're biting of more than you can chew at the moment. This is a rather basic programming skill that's learnt in the earliest days of learning to code. If this is a significant problem for you to solve, you should ask yourself if you're really ready to tackle a significant game project with a deadline, as you're going to have a helluva job solving the real bugs (I had one the last couple of days where a script was behaving differently on some objects than others, which turned out to be Script Execution Order. It was only years of coding experience, a year of using Unity, and a fairly decent grasp of the engine that led me to identify the problem after 48 hours of stress and hair-pulling!). Programming requires precision and understanding and patience. I say this to prepare you for what's coming. Unless your game is incredibly simple, you're going to have delays the likes of which you can't imagine coming up due to bugs that aren't as readily solved as a parsing error.

    The best advice would be not to start a project that can be set back days by bugs, but a project that'll take however long it does that you use to learn the skills necessary to start a full project.
     
    toreau likes this.
  17. CookieMonster Games

    CookieMonster Games

    Joined:
    Sep 30, 2014
    Posts:
    15
    Ok so this is my first project in unity i wont lie ive been watching tons of youtube guides and i know how parsing works but what i dont understand is why did it do this before i had my networkmanager working great and i could play with other people but when i started my playershooting it all got screwed
     
  18. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    It's unlikely anyone can answer that. The syntax errors show the file was messed up somehow. That's not anything Unity should be doing and I very highly doubt that's the problem here, so I'd point the finger at maybe a weird Mono error (corrupted save of file), which I've never experienced myself, or the good old favourite 'user error' which I've experienced lots of. Maybe you had the file open twice and did partial edits in one and finished them off in another copy? That's a problem introduced with the MonoDevelop 'update'.

    At this point, you don't need to fear that playershooting has somehow broken something. A script isn't going to do that. I've just come from a miserable few days where Unity had corrupted my gameobjects and I couldn't make sense of what I was seeing other than these corruptions were bleeding into the core of the game and the whole thing was ruined. Thanks to the community, a simple prefab editor let me clear up the corruption (just some left over deleted components) which meant I knew that wasn't the cause of my issues, and then some more slog lead me to the script execution order. For all my worst fears (not unfounded, because other languages and experiences over two decades have been horrible in the extreme!), the solutions were simple and workable and my project remains intact.

    Fix the errors as they come and trust there's something fairly sensible causing them. Don't start worrying that weird, unpredictable things are happening because the probability of that is extremely low.

    Also, make backups! Make sure you can always go back a day's work and build from when things were working. ;)
     
  19. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Something I do quite often when adding big new chunks of code is to rename a class from MyClass1 to MyClass2 to MyClass3, etc.. I save it as a new file so if I completely bung something up I can go back to what I had before pretty easily. When the old ones are too old to ever want to go back to, I delete them.
     
  20. CookieMonster Games

    CookieMonster Games

    Joined:
    Sep 30, 2014
    Posts:
    15
    Well heres how it happened i was bout 70% into my shooting script and i had to add some things to the playermanager added them everything worked fine then i come back to my shooting script and i had to go fast so i kinda saved in a rush could that be the cause of the errors did i save it badly or something?
     
  21. CookieMonster Games

    CookieMonster Games

    Joined:
    Sep 30, 2014
    Posts:
    15
    Oh and yes i have a build on my pc with the good network manager script but idk how to run it in unity can anyone tell me ?
     
  22. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    You're saying you still have the old, good network manager script somewhere? If so, just copy it over the bad one to overwrite it. I'd save the bad one somewhere else too in case you need it.
     
  23. CookieMonster Games

    CookieMonster Games

    Joined:
    Sep 30, 2014
    Posts:
    15
    Well idk how thats the problem

    i have a old build of my game but idk how to access it
     
  24. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    You do know how to copy and paste files through Windows Explorer?
     
  25. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    You can't extract old scripts out of an actual build of the game. Don't you have backups of scripts anywhere?
     
  26. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    If you don't, you can always rewrite the script. It's a bind, but you know you can write a working a script because you did it before, unless it was hugely complicated. I guess that's not the case though as you'd notice in the broken file.

    Have the suggested parsing fixes not worked? What are the errors once you've fixed the parsing faults? The should help determine what's wrong with the script and what needs be patched, if anything.
     
  27. CookieMonster Games

    CookieMonster Games

    Joined:
    Sep 30, 2014
    Posts:
    15
    Well the network manager is the most complicated script ive done it took me a whole day to make it along with the spawn spots and stuff so i wouldnt like to repeat it cause it would waste so much time
     
  28. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    Sure, but if that's your only option...

    If you have a backup of the project, use the project. If not, fix the faulty script. As the others say, you can't extract a script from a build.
     
  29. CookieMonster Games

    CookieMonster Games

    Joined:
    Sep 30, 2014
    Posts:
    15
    Whatever it was hopeless anyways -.-
     
  30. ZO5KmUG6R

    ZO5KmUG6R

    Joined:
    Jul 15, 2010
    Posts:
    490
    If you learned basic scripting, you wouldn't be giving up right now.
     
  31. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    You're being unreasonable. CookieMonster has lost an entire day over the loss of the one script. With a project set back 24 hours, it'd take a miracle to recover. If people giving their free time and advice can't fix it with a single convenient suggestion and rescue his/her projcet, it's obviously an impossible problem. The only sensible thing to do is give up and go do something easier than game development.
     
  32. ZO5KmUG6R

    ZO5KmUG6R

    Joined:
    Jul 15, 2010
    Posts:
    490
    When several compiler errors pop up, it's usually because of 1 letter missing in the script. I'm being serious on that
     
  33. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    I was being sarcastic. ;)