Jump to content
Sign in to follow this  

Client-Server Synchronization

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?

Share this post

Link to post
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.


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...