Rocket Networking Docs🚀
  • About this Documentation
  • Basics of Rocket Networking
    • Room based multiplayer (Auto State Sharing)
      • Clients and clientId
      • Entities
      • Smart Entities
    • Single Message Sharing
    • Persistent Objects on the Server
    • Easy Matchmaking
    • Discord Server Integration
    • Database for your Account
    • Server Side Scripting
    • Global Multiplayer(Cross play)
  • Rocket Networking Code
    • Connecting and Disconnecting
      • ConnectToServer()
      • callback_ConnectToServer()
      • DisconnectFromServer()
      • callback_DisconnectFromServer()
    • Rooms
      • ChangeRoom( new_room_name )
      • callback_ChangeRoom()
      • LeaveRoom()
      • callback_LeaveRoom()
      • ShowAllClientsInRoom(room_name ) and callback_ShowAllClientsInRoom()
      • ShowAllRooms() and callback_ShowAllRooms()
    • Private Messaging
      • SendEventToClient
      • callback_ReceivedEvent
      • SendMessageToClient
      • callback_ReceivedMessage
    • Persistent Objects
      • CreatePersistentObject(roomId , persistentObjectStruct)
      • callback_CreatedPersistentObject()
      • EditPersistentObject(persistentObjectId , new_persistentObjectStruct)
      • DestroyPersistentObject(persistentObjectId)
      • ShowPersistentObjectsInRoom(room_name)
      • callback_ShowAllPersistentObjectsInRoom(array_of_persistent_objects)
    • Database Functions
      • SetSimpleData()
      • callback_SetSimpleData()
      • ReadSimpleData()
      • callback_ReadSimpleData()
      • AddToSimpleData()
      • callback_AddToSimpleData()
      • DeleteSimpleData()
    • Discord Integration
      • SendDiscordMessage()
      • callback_DiscordMessageReceived()
    • AI Functions
      • CallSimpleAI
      • callback_CallSimpleAI
      • CallGeneralAI
      • callback_CallGeneralAI
  • KickPlayer(client_id)
  • ViewServerActivity()
    • callback_ViewServerActivity()
  • oBrain - ping and pseudoHost
  • Admin Callbacks
  • API
    • Database
    • AI
  • Server Side Scripting
    • Basics
    • Understand the heirarchy on the server
    • Create a Persistent Object from Server
    • Important Scripts
      • "step" Script format
      • "client_sent_event" Script format
      • "game_server_created" Script format
    • Send Event to a Client from Server
    • Database Functions on Server
    • AI Functions on the Server
Powered by GitBook
On this page
  1. Basics of Rocket Networking

Server Side Scripting

PreviousDatabase for your AccountNextGlobal Multiplayer(Cross play)

Last updated 1 year ago

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

  1. 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.

  2. 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.

There is heirarchy on the server that is maintained.

  1. Game - every one of your RNet games has a "Game" instance attached to it

    1. Rooms - Inside a Game Instance there is a rooms array which holds instances of the Room Object, each one representing a different room

      1. Client - Inside every Room Instance there is a clients array which holds instances of the Client Object, each one representing an active connection

        1. 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

      2. 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.

To know more about server side scripts, go to the section!

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