Basics
Last updated
Last updated
UPDATE: You can now use the no code server side code visualiser!! This can help you generate scripts fast.
Welcome to the most advanced and most powerful concept in Rocket Networking!
Normally you make games using RNet for state sharing and sending messages to other clients, but sometimes, especially when you are making MMOs, it's important to know how to use the Server itself as logical authority and implement server side logic. In these cases, we say Server is King👑
So this way you can write scripts in Javascript on the server directly from your dash and deploy it to your server.
Scripts on the server are like Object's events in Gamemaker
If you make a script called "step", it behaves like a step event on the server ticking every frame. Don't worry about how to use it, we'll get to that later.
If you make a script called "client_sent_event", it can do stuff every time a client sends an event message to the server, and the server can send commands too.
Other Scripts will come soon. You can name any scripts on your dahsboard but as of now RNet will only scout for the script names we have defined above.
Not only that, but scripts have a format you need to follow. For example "client_sent_server" must have a switch(eventName) like structure so you can classify what the client wants and accordingly write code.
Game - every one of your RNet games has a "Game" instance attached to it
Rooms - Inside a Game Instance there is a rooms array which holds instances of the Room Object, each one representing a different room
Client - Inside every Room Instance there is a clients array which holds instances of the Client Object, each one representing an active connection
Entity - A client can have many Entities it owns right? The Client object has an entities property on it which is an array that holds instances of Entity
Persistent Objects - Inside every Room instance there is also a persistentObjects array which holds Instances of the PersistentObject Object, each one representing a persistent object in this room.
Normal RNet Multiplayer Client A and B are in a room. Both of them are using global.sharedProperties to share their x,y so they can see each other move in realtime.
RNet with Server Side Scripting
Client A is sharing which keys it is pressing (out of WASD) in global.sharedProperties. According to that the server calculates its x,y based on some basic formula and sends that to A and B both.
A receives this data in global.sharedPropertiesFromServer, B receives it in oOtherPlayer's sharedPropertiesFromServer