Results 1 to 7 of 7

Thread: Differing Clientside and Serverside

  1. #1
    El Bacon Hombre Police Commissioner
    Join Date
    Jun 2013
    Location
    United States
    Posts
    247

    Differing Clientside and Serverside

    Hi,

    I've seen a few guides fail to fully explain this and coders screw up therein because of it.

    The basis is exactly what the two titles say: One set of data is for the client and the other is for the server. In a script, if you don't declare //#CLIENTSIDE anywhere, the compiler will think all of the data is purely serverside and the data will only be compiled and executed through the server.

    A client is anything that connects to the server, iPhones, iPads, etc. Then the server... Well, it's the server! It's what is the center of everything! You can think of it as sort of a "master client" if you wish, and I've shown a network of basic clients connecting with a server below.
    1298051453202.jpg

    Now that you can identify each, what does any of this have to do with scripting?! Well, I'm glad you asked.
    When you script something in GS2, you make two sets of instructions- one for the players to carry out on their computers and one for the server to carry out on the server. For this reason, when you create a serverside string, say for example this.name = "BboyEatsbacon; it becomes identified on the server, but the clients never see it. It's kind of like telling people to go into two different rooms then you give them a piece of paper with something different a person. The people will obviously be very confused if you demand that they tell you what the other person had written on their piece of paper because they never saw it!

    Whenever people tell me, "is this going to be serverside or clientside?" I simply tell them to think, "Well, is the server doing it or is the player themselves doing it?" For example, showing a gui on the server would be useless simply because the server isn't seeing the gui, the players are! Also, when you want to echo(); something, you have to think- "Do I want this to show up for my client or do I want the server to print the string to RC?"




    The bottom line to all of it is that two different datasets are being sent out- one is being compiled into bytecode and sent to the server whilst the other is compiled into bytecode and sent to the individual clients.




    Now, why is it that you have to add a weapon to a player before they can execute clientside code? Well, I'm glad you asked. Since the server is very polite, it knows that it should only be talking to the people it has numbers for. It won't send certain data to clients to execute because it hasn't been told to send it to those certain clients first!
    Last edited by BboyEatsbacon; 09-10-2013 at 08:22 PM.
    [email protected]
    *Stefan: You steal my cookies?

  2. #2
    Nice, now I know.

  3. #3
    El Bacon Hombre Police Commissioner
    Join Date
    Jun 2013
    Location
    United States
    Posts
    247
    If you guys have any further questions on the topic, don't hesitate to message me.
    [email protected]
    *Stefan: You steal my cookies?

  4. #4

  5. #5
    Banned
    Join Date
    Jun 2013
    Posts
    24
    thanks for clearing that up

  6. #6
    Street Boss John's Avatar
    Join Date
    Jun 2013
    Location
    Lebanon
    Posts
    825
    You should also tell them that some stuff are being sent to serverside from clientside in background without any manual coding.
    (like player.x, player.y, attr[] etc...)

    Nice explanation.
    -Johnaudi

  7. #7
    Soldato Tyler Rexus's Avatar
    Join Date
    Aug 2015
    Location
    Philippines
    Posts
    15
    Is this applicable on Gonstruct??

Posting Permissions

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