Jump to content

Serverside v Clientside


Th3Angel

Recommended Posts

Good evening everyone. I'm fairly new to scripting and I've been reading the tutorials on the wiki and official lua documentation. What I'm mainly confused about is clientside scripts and how they run. Serverside scripts don't get downloaded to the client while clientside scripts do. Clientside scripts are neccessary for functions such as GUI creation and things only possible on the client's side. So do the clientside scripts run per every user? And when that user quits does the clientside script stop getting executed? Or does it run as a whole like the serverside scripts do and only run once and stay running? If anyone can tell me the answer to my question, I'd greatly appreciate it!

Link to comment

Client side script run on each player's computer server side script run only one tim on the server.

bk client side script run on each computer= they run different i mean the values are difrent's on server side script is the same for al player's .

Client side script stop's when the player leave the server (it's stop on player's computer that just leave )

Link to comment

Ah, so what I thought was correct. So for clientside scripts, I wouldn't need to store any values in a table for every player, right? Like, whenever someone enters a vehicle, I set the variable 'isInVehicle' to 1 for that player. If there were two players, one in a vehicle and one on foot, then the variable for the player that is in a vehicle would be 1 and for the player that is on foot it would be 0?

Edited by Guest
Link to comment

Oh, ok! Thanks for your help!

Also, I'm a little puzzled as in how things get executed outside of events and functions. I know that things get executed by the order you script it. If I declare a global variable 'root' outside of all functions and just at the top of a script and set it to the return value of getRootElement, then how will the execution of getRootElement go? Does it just get executed once? Or is it executed multiple times? I'm guessing that it is executed once.

Link to comment

It's executed once when the script is loaded (when the resource is started).

There's already a global variable called root that you should use - so you don't need to do what you're talking about in your example.

Link to comment

Ahhhh, thanks for your reply! I greatly appreciate it.

Edit: Also, one quick question. How exactly are strings treated? For example, are '' (no text) and ' ' (one or more amount of spaces) treated the same? If not, what would be the best way to detect this? I was thinking about checking the return value of string.find(string, "%a+") for nil, but wasn't sure if it was the most efficient way to do it.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...