Thread: [Delta] Local Client

Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1 [Delta] Local Client 
    Registered Member
    Join Date
    Jun 2010
    Posts
    28
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Description: I use custom classes and i wanted to send messages to the player from the custom class and not only Client.java. I literally spend a few hours on trying to figure out how to do this (don't laugh its my first time with delta). The solution is simple; had to create a new variable inside PlayerHandler.java and then i could access the client (socket) from within my custom classes.

    Step 1:
    Open PlayerHandler.java and search for
    Code:
    client newClient = new client(s, slot);
    below add:
    Code:
    localClient = newClient;
    Step 2: Still in PlayerHandler.java add this with your variables:
    Code:
    public static client localClient;
    Step 3:
    Create a class that you will be using, example:
    Code:
    public class example {
        client c = PlayerHandler.localClient; 
        
        public static void sendText() {
            c.sM("some text");
        }
    }
    Step 4: Open client.java and go to line #11618.
    Step 5: Now you can simply call the sendText method by adding:
    Code:
    example.sendText();
    I hope that this was usefull ^_^
    Reply With Quote  
     

  2. #2  
    Super Donator


    Join Date
    Mar 2009
    Age
    25
    Posts
    1,393
    Thanks given
    316
    Thanks received
    408
    Rep Power
    608
    Constructors.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jun 2010
    Posts
    28
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Uh not really, re-initiating client would require a new socket slot.
    if that is not your point, i'm already using constructors in my own classes.
    Last edited by BinaryX; 06-26-2010 at 08:51 PM. Reason: I ment socket slot lol.
    Reply With Quote  
     

  4. #4  
    Super Donator


    Join Date
    Mar 2009
    Age
    25
    Posts
    1,393
    Thanks given
    316
    Thanks received
    408
    Rep Power
    608
    Why would you need a new socket for a Player instance?
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Jun 2010
    Posts
    28
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    I'm not sure, i could have misunderstood the code i seen in the player handler.

    Code:
    client newClient = new client(s, slot);
    Doesn't this represent a new connected client thus creating a new socket slot for it?
    Reply With Quote  
     

  6. #6  
    Respected Member


    kLeptO's Avatar
    Join Date
    Dec 2006
    Age
    25
    Posts
    2,955
    Thanks given
    1,183
    Thanks received
    754
    Discord
    View profile
    Rep Power
    3084
    Quote Originally Posted by BinaryX View Post
    I'm not sure, i could have misunderstood the code i seen in the player handler.

    Code:
    client newClient = new client(s, slot);
    Doesn't this represent a new connected client thus creating a new socket slot for it?
    Yes, wL does.

    Code:
    public Client(Socket s, int _playerId)
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Jun 2010
    Posts
    28
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Yep, so the only way to use client in custom classes is via my method, correct?
    Reply With Quote  
     

  8. #8  
    Banned

    Join Date
    May 2008
    Posts
    2,327
    Thanks given
    55
    Thanks received
    67
    Rep Power
    0
    better way imo would be this

    Code:
    public class EXTENDEDCLASS {
    
    public final client c;
    
    public EXTENDEDCLASS(client c) {
    this.c = c;
    }
    
    public void SUPERAWESOME() {
    c.sM("lol i am teh fkn beast yu noeh?!");
    }
    
    }
    ^.^

    edit: AMG HAXORZ 2K POESTZ!
    Reply With Quote  
     

  9. #9  
    Super Donator


    Join Date
    Mar 2009
    Age
    25
    Posts
    1,393
    Thanks given
    316
    Thanks received
    408
    Rep Power
    608
    Quote Originally Posted by »kLeptŘ« View Post
    Yes, wL does.

    Code:
    public Client(Socket s, int _playerId)
    No, it's the socket specified when the connection was made. Then later on they save the socket ip to the connectedfrom file.
    Reply With Quote  
     

  10. #10  
    Donator

    tj007razor's Avatar
    Join Date
    Feb 2007
    Posts
    895
    Thanks given
    2
    Thanks received
    9
    Rep Power
    210
    Sorry dude, but this is actually incredibly disappointing to read.

    First of all, how does someone saying "constructors" mean re-instantiating? It's called pointers. Read what silab posted.

    Second of all,
    Code:
    localClient
    wat?

    I shouldn't even need to explain why that is incredibly stupid.

    [Only registered and activated users can see links. ]

    [Only registered and activated users can see links. ] | [Only registered and activated users can see links. ] | [Only registered and activated users can see links. ]
    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
  •