Client, Shared, Init , Server? What do I use?

I’ve been studying lua for a few hours now, but I can’t find more information about ‘instances’, I see server.lua files, client.lua, shared.lua and even init.lua files.
What files do I need to use? What’s the difference? I just can’t find a decent resource, it’s all: “OH LOL JUST PASTE THIS AND U MAKE GAMEMODE”, I hope someone can enlighten me!

Thanks in advance,

Nick

There is client side and server side.

Serverside code is code ran by the server, clientside code is ran by the client.

Clientside code can always be changed/edited so dont rely on it.

To put it simply: The server is the ‘core’ realm of the game, stuff you do there affects the entire game and all the players. Every player has their own client realm. If you make a change to a player clientside, it will only affect them.

An example: If you create an effect say, an explosion serverside, all players will be able to see it. If you create the effect clientside, only the client the code is running on can see it. All Derma menus are clientside for this reason, the menu should only be shown for that client.

As the two are separate ‘realms’, you cannot just set a variable clientside and expect the server to be able read it. There are various means of communication between server and clients, the most common being Console Commands (concommands) and User Messages.

[editline]11th July 2011[/editline]
And Shared means it runs the code on both client and server.

cl_init, sh_init and init.lua. They do what they say, initialize on client, server, and shared.

cl_init is clientside

SHared is shared

init is server

Serverside runs thing that are only needed for the server. Ex: PLayers connected, players play time, tables, variable and technical crap.

Clientside runs things only needed for the client EX:The HUD, viewmodels, some animations, player specific variables (such as health, armor). etc.

Shared is where the two come together. Shared can run both types of code, along with special shared code that can only be executed here. ex: World models, interactive entities, some animations, player to world interactions. etc.

Thanks a lot guys, I couldn’t have hoped for more! These answers were perfect :wink:

What library is biggest the server side or the client sides? :stuck_out_tongue:

King penis less you have no penis shut up.