Want to improve the docs? Take a look at scripting-api-data!
Found a bug? jc3mp/bugs is a good place to let us know.
Make sure you installed the server and client before proceeding.
Right now, the Server supports Node.js v7.0.0. Client packages can use vanilla JavaScript (via the v8 Engine). User Interfaces can be created using Chromium Embedded Framework.
/client-packages/
/packages/
config.json
Server(.exe)
client-packages/
: in this directory, you can put client-only packages. See the Package Structure below for more information.packages/
: server packages. they can include a client_package
inside (see below).config.json
: the main configuration file for the ServerServer(.exe)
: the server binaryBoth the Server and Client make use of Packages. Simply put, a Package is an isolated module of your gamemode. This makes it easy to use third-party modules (like a chat, for example) to be added to your server, requiring you to only drop the package in.
If you are new to the whole JavaScript eco-system, we recommend just modifying the freeroam
package at first (it ships with the Server download).
You can find a bare package ready to use here: https://gitlab.nanos.io/jc3mp-packages/bare-minimum.
Each Package has to follow the structure below:
package.json
main.js
package.json
: your Package configuration file. This file should be npm conform. See the package.json documentation for more detailed information.main.js
: while you can use a different entry point, the default start file for a package is always main.js
. this is where you write your own script.for easier management of client and server packages, you can embed a Client Package into your Server Package. Just create a folder
inside your Server Package named client_package
with the structure mentioned above.
Make Sure that the name
property in your package.json
(server and clientside) match up! Otherwise the client package will not work.
The server does currently not hot-reload packages. This means that you have to restart either the Server or the Package when you modify it.
When you modify your client package, you must reload it, otherwise new connections to the server will fail.
You can restart a package using the restart_package
command in the server console.
Example
restart_package chat
This will restart the Package named chat
. Check the following output for errors.
By becoming the newest member of our growing forums, we and hundreds of other players will always keep you up to date on everything JC3:MP related.