📄️ Resources
Everything a JC4MP server runs is a resource: a folder of Lua scripts (and any files they need, such as webview pages and images) that can be started, stopped and restarted on its own. A gamemode, a chat, an admin menu and a login system are all separate resources. This page explains how resources are laid out, how they start and stop, how their files reach the players, and the parts of the Resources API available on both sides; starting, stopping and restarting resources from scripts is on Resources (server).
📄️ Net
The Net table sends script events between the server and its clients. A script registers a handler for an event name with Net.AddEvent, and the other side triggers it with Net.Send (client to server, see Net (client)) or one of the Net.SendTo... / Net.Broadcast functions (server to clients, see Net (server)). This is how the client and server halves of a resource talk to each other. For events that stay on one side, use Event.Add / Event.Fire (see Events).
📄️ Sandbox
This page lists what a script's Lua environment contains on each side: the Lua version, the standard libraries that are available, the changes made to some standard functions, and the limits scripts run under. Client scripts run code the server sent on the players' computers, so they get a restricted environment; server scripts are chosen by the server owner and get more.
📄️ Events
Events are how your scripts react to things happening in the game and on the server: a player joining, a key being pressed, a vehicle exploding, a frame being drawn. You register a handler (a Lua function) for an event by name, and every time that event fires your handler is called with the event's arguments. You can also fire your own custom events to let scripts and resources talk to each other on the same side.
📄️ Timer
The Timer table runs a function later, once or repeatedly: delays, countdowns, periodic saves, cooldowns. Timers belong to the resource that created them and are removed when it stops.
📄️ Hash
Hash computes the game's 32-bit hash of a string. Just Cause 4 identifies many things by the hash of their name instead of the name itself: character acts, input actions, weapons, effect parameters, bones and more. The hash values scripts receive and the hash-based enums are these hashes, so Hash lets you compare them with a name you know, or build one the API has no enum value for.
📄️ JSON
The JSON table converts between Lua values and JSON text. Use it to store tables in a database column or a file, to talk to web APIs with Net.Fetch, or to pass structured data to a webview page.
📄️ Math types
JC4MP gives scripts a small set of math types: vec2, vec3, vec4, quat, mat4 and AABB. Positions, velocities and sizes are vec3 (in meters), rotations are quat, and screen positions are usually vec2. These are the types the rest of the API takes and returns, and the vector and quaternion types can also be sent over the network with Net and written by JSON.Stringify.
📄️ World
The World table is the entry point to everything that exists in the game world. This page explains how networked objects work and documents the lookup functions that work the same on both sides.
📄️ Weather
The Weather table controls the weather that players see. On the server it syncs the world's tornado and cloud settings to every player; on the client it strikes local lightning. Sandstorms are networked objects instead, spawned with World.SpawnSandstorm (see Sandstorm).
🗃️ Objects
9 items
🗃️ Enums
10 items