Jump to content

Client-Server Synchronization


Maris

Recommended Posts

All I want is to send unique number to all clients, so it will be the same for all users.

 

For example, on the server:

textureNumber = ZombRand(10);

 

How can I send this value to client, so all users will see the same texture?

Link to comment
Share on other sites

There are two ways to do this:

  1.  Using LuaNet
  2. Using the (basic) sendServerCommand and sendClientCommand

 

What you should use depends on the functionality you want. With LuaNet you can do more advanced stuff like sending packages to certain players.

The initial setup is more complicated though.

 

As an example you can look at my CoxisServerMessage mod. Pretty much all my mods use LuaNet.

 

With number 2 you have a rather easy setup, but lose some functionality.

To use it you have the commands "sendClientCommand" and "sendServerCommand". To catch the packages there are the events "OnServerCommand" and "OnClientCommand".

"OnServerCommand" and "sendClientCommand" is used on the client, "OnClientCommand" and "sendServerCommand" on the server.

 

Personally I would suggest the LuaNet approach, because if you need some of the advanced functionality down the line or for another mod you are set.

 

Link to comment
Share on other sites

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
×
×
  • Create New...