Thread: ): .. I can't seem to get methods working right.. (static and non)

Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1 ): .. I can't seem to get methods working right.. (static and non) 
    Registered Member Dezzan's Avatar
    Join Date
    Oct 2009
    Age
    27
    Posts
    409
    Thanks given
    2
    Thanks received
    6
    Rep Power
    30
    Base: Devolution 2.7

    Problem with timers is... When I put a timer countdown in process, in the playerHandler class, I make it call a method in a different class for the reaction when the timer hits zero. Since its in another class, I need to make that method static? right?...

    But if that's static, it can't use the other non-static methods in that class, which includes multiple methods.. and those methods are widely used..

    So if you understand what I'm saying, then please help.

    I know I'm doing something wrong, maybe I shouldn't make something static?

    Anyway.. that's all the detail I'll go into now.. Please help
    Reply With Quote  
     

  2. #2  
    Registered Member Dezzan's Avatar
    Join Date
    Oct 2009
    Age
    27
    Posts
    409
    Thanks given
    2
    Thanks received
    6
    Rep Power
    30
    Heres an example if you still don't understand:

    This is what I get:

    Code:
    .\server\players\PlayerHandler.java:370: non-static method timerZero() cannot be
     referenced from a static context
                            client.timerZero();
                                  ^
    Note: .\server\server.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    1 error
    Press any key to continue . . .
    So I make that method static... then I get this:

    Code:
    .\server\players\client.java:11346: non-static method getPlayersInBank() cannot
    be referenced from a static context
                    getPlayersInBank();
                    ^
    Note: .\server\server.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    1 error
    Press any key to continue . . .
    And its just a chain reaction.. Idk what I'm supposed to do
    Reply With Quote  
     

  3. #3  
    Registered Member 'Andrew's Avatar
    Join Date
    Nov 2009
    Posts
    43
    Thanks given
    0
    Thanks received
    5
    Rep Power
    13
    You fix it.
    Reply With Quote  
     

  4. #4  
    Banned

    Join Date
    Jan 2009
    Age
    28
    Posts
    2,662
    Thanks given
    66
    Thanks received
    207
    Rep Power
    0
    because your doing

    client.

    you'd have to have that method static

    so open up the client.java or what ever it is your getting that method from and make it

    public static void



    but are u sure theres nothing in the current file ur in that allows u to use the client.java without using the world client?

    like c.timerZone()?

    or players[i].timerZone() ?
    Reply With Quote  
     

  5. #5  
    Registered Member Dezzan's Avatar
    Join Date
    Oct 2009
    Age
    27
    Posts
    409
    Thanks given
    2
    Thanks received
    6
    Rep Power
    30
    Quote Originally Posted by digistr View Post
    because your doing

    client.

    you'd have to have that method static

    so open up the client.java or what ever it is your getting that method from and make it

    public static void



    but are u sure theres nothing in the current file ur in that allows u to use the client.java without using the world client?

    like c.timerZone()?

    or players[i].timerZone() ?
    Erm.. My 2nd post.. It says that when I make that other method static, It then wants me to make all the other methods static, which will create a domino effect....


    Soo.. Idk what to do.
    Reply With Quote  
     

  6. #6  
    Mister Fucking Popular

    HankAaron's Avatar
    Join Date
    Nov 2006
    Age
    29
    Posts
    342
    Thanks given
    24
    Thanks received
    31
    Discord
    View profile
    Rep Power
    289
    First.. I'd download Notepad++ and set the language to Java and see if you missed any brackets or methods.

    That would probably help..
    Reply With Quote  
     

  7. #7  
    Registered Member Dezzan's Avatar
    Join Date
    Oct 2009
    Age
    27
    Posts
    409
    Thanks given
    2
    Thanks received
    6
    Rep Power
    30
    Quote Originally Posted by Mastafu0 View Post
    First.. I'd download Notepad++ and set the language to Java and see if you missed any brackets or methods.

    That would probably help..
    ... Erm I didn't miss a bracket or something..

    And I've had Notepadd++ forever.
    Reply With Quote  
     

  8. #8  
    Registered Member
    Purely chill's Avatar
    Join Date
    May 2009
    Posts
    838
    Thanks given
    91
    Thanks received
    11
    Rep Power
    315
    Did you make sure static was all lowercase?
    Spoiler for Signature:
    [Only registered and activated users can see links. ] The 64-bit one has too many glitches, get the 32-bit one.
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  9. #9  
    Registered Member Dezzan's Avatar
    Join Date
    Oct 2009
    Age
    27
    Posts
    409
    Thanks given
    2
    Thanks received
    6
    Rep Power
    30
    Quote Originally Posted by Purely chill View Post
    Did you make sure static was all lowercase?
    Yes.


    That's not the problem.. I can't seem to get a method chain in the Client class to work being called from the PlayerHandler class without making every single method static. Which isn't right.

    And I can't do that either with moving all the voids into PlayerHandler.

    And I can't seem to call it from Client because the timer is in PlayerHandler.

    Maybe I can move the Timer out of PlayerHandler? But I don't know how to make it count down by the second or half second without it being in process.. Which is in PlayerHandler.

    There are processes in Client, but those are Player processes, which won't work a timer correctly, at least not the one I'm trying to make.



    Btw...... My goal here is to create a TEST waiting room. I'm just trying to understand how waiting rooms work.
    Reply With Quote  
     

  10. #10  
    Mister Fucking Popular

    HankAaron's Avatar
    Join Date
    Nov 2006
    Age
    29
    Posts
    342
    Thanks given
    24
    Thanks received
    31
    Discord
    View profile
    Rep Power
    289
    Switch sources. Devolution sucks.
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •