Rock-Mod
Current source RockSandbox compatibility: ABI 42 / protocol 44 / CEF IPC 2.
Server peds now delegate physical NPC creation, native readers/commands,
metadata and destruction. Iterators query native membership and convert RP
coordinates. See the server NPC contract
for supported models, queued state and remaining graphical/content qualification.
Client peds delegate the shared authored/runtime/preview pool and frozen native
metadata reads. isClientMutable is false for remote actors, allowing RP server
notifications to accept native model/transform replication without issuing a
forbidden local mutation. Direct remote mutation still throws.
Server player model delegates the published native model hash and
setModel(name) delegates authoritative assignment without caching or
rewriting arguments. Freemode aliases retain exact identity with the accepted
temporary Streetwear geometry. See native model ownership.
Protocol 31 adds native weapon ownership and finite reserves. Rebuild server,
addon and clients together. Later sections retain the
compatibility values of their original validation runs.
Server player.collisionWithPlayers and setCollisionWithPlayers(enabled)
delegate directly to native code. Other server adapters throw for these APIs.
See the native contract. Earlier
validation sections retain the versions of their original runs.
Rock-Mod is a versatile and powerful framework designed for cross-platform mod development for Grand Theft Auto (GTA) servers. VIMP is the primary and recommended multiplayer platform; RageMP, AltV, and Mock are also supported. RockSandbox wraps native server events, player/world state, queued commands, cylinder colshapes, blips and ground markers; its other game APIs and client remain throwing stubs.
Installation
To get started, simply install the package:
npm install rock-mod
To build this checkout locally, install dependencies and build:
npm ci
npm run build
@rock-sandbox/types is installed from npm. The SDK imports its named types
from /server without installing global RockSandbox declarations. The package
is a dependency because the SDK's generated declarations refer to its types.
Usage
On the server-side, initialize Rock-Mod with the appropriate multiplayer type:
const rockMod = await RockMod.create({
multiplayer: "VIMP", // recommended; also supports "RageMP", "AltV", and "Mock"
});
Multiplayer Types
Rock-Mod recognizes five multiplayer types:
- VIMP - Primary and recommended platform for developing mods for VIMP servers
- RageMP - For developing mods for RageMP servers
- AltV - For developing mods for AltV servers
- Mock - For testing and development without multiplayer dependencies
- RockSandbox - Native server events, player/world state, cylinder colshapes, blips and ground markers; other game operations remain stubs
RockSandbox scaffold
Select RockSandbox on the server:
import { RockMod } from "rock-mod";
const rockMod = await RockMod.create({ multiplayer: "RockSandbox" });
On the client, import RockMod from rock-mod/client and use the same option.
Initialization requires no game runtime and creates explicit platform managers.
Structural components such as net.events, net.rpc, net.dataHandler (client only)
and entity manager iterators are accessible.
On the server, net.events.onInternal, offInternal and emitInternal delegate
to the native rockSandbox.on, off and emit API. Rock-mod has no separate
event registry or fallback implementation. These methods require the embedded
Rock Sandbox runtime; creation of RockMod itself still works without a host.
After updating the native API, rebuild the server bundle in rock-sandbox:
python3 scripts/nodejs.py build
Delivery is synchronous, preserves argument references and registration order,
and propagates synchronous handler exceptions. Duplicate subscriptions are
independent; removal affects the last matching registration. Handler changes
during dispatch take effect on the next dispatch, including a nested one.
An event without listeners is valid.
The first SDK subscription to rm::playerConnected, rm::playerQuit, rm::playerDisconnected or
rm::playerDeath installs all three native bridges once for that host API object. Each bridge only
applies the existing player wrapper and emits the corresponding SDK event in
the native registry. User handlers keep their original identity for offInternal;
there is no polling or additional handler registry.
The host records admission and removal in processing order, including both
transitions between snapshot publications. Queries, native events, and SDK events
share the same player identity through the wrapper. Late subscriptions receive
future transitions; use players.iterator.all() for existing players.
Event properties read the latest published state. Even rm::playerConnected
may receive an already absent player: isExists is false and name/position
throw. In rm::playerDisconnected lookup returns null while ID and type remain
readable. Host-event handler exceptions stop the server with a diagnostic; local
emitInternal exceptions propagate synchronously to the caller.
rm::playerDeath(player, reason, killer) now forwards native deaths from
setHealth(0) and combat. Reasons are RockSandbox native codes: 0 for scripted
health zero, 1 pistol, 2 MP5, 3 shotgun. They are not GTA weapon hashes.
The killer is null for scripted deaths and the actual wrapped shooter for combat,
even if already disconnected when delivered. Both supplied handles preserve
identity; the bridge never looks them up again or computes gameplay data.
Native playerDeath additionally supplies a fresh frozen historical context with
exact bigint life and tick. SDK keeps its existing three-argument signature.
Getters read the latest published state: an old death may arrive after respawn or
removal. Native FIFO preserves every actual death and its order before subsequent
disconnects, including multiple deaths between publications. Repeated assignments
to dead players, protected/nonlethal damage, spawns, moves and policy changes add
no deaths. Late subscriptions do not replay delivered history. Host-handler errors
stop the server, while local custom emit errors still propagate to the caller.
There is no polling, filtering, extra handler registry or SDK game state.
Entity lifecycle events and full gamemod gameplay persistence remain a later
stage. Offline --ticks produces no player events, and shutdown synthesizes no
disconnects. Client events now delegate to the native transport (see below). Native SDK RPC helpers and unsupported game operations still throw an Error identifying the platform, side, class and member:
import { WeatherTypeEnum } from "rock-mod/shared";
rockMod.world.setWeather(WeatherTypeEnum.RAIN);
// Error: [RockSandbox:server] RockSandboxWorld.setWeather: expected clear, cloudy or overcast as a primitive string
The server player manager delegates to native rockSandbox.players. It supports
findByID/getByID, exact findByName/getByName (the smallest ID wins for
identical names), and iterator.all(). Lookups and iteration return the same
wrapper for each connected native player. find* returns null when absent;
get* throws. Iterator membership is captured when all() is called.
player.socialClub directly returns native player.profileId, formatted as
rock-sandbox:profile:<UUID v4>. This temporary unverified local profile ID
survives reconnects/restarts while the native client's profile-id file is kept.
Deleting or copying that file changes or shares the identity. It provides no
proof of account ownership and must not enable production remembered-session
authorization. Validation, file persistence and admission belong to RockSandbox;
the SDK only forwards the getter and its errors. Social Club search remains a
stub. Rebuild the server/addon with ABI 24 and clients with game protocol 24.
Players expose id, type, isExists, name, and position. After disconnect,
id and type remain available, isExists is false, and name/position
throw the native disconnected-player error. Position is a fresh Vector3D in
Z-up coordinates: engine (x, y, z) becomes (x, -z, y). This is a rotation,
not a reflection. Positions already returned remain unchanged. Unsupported mutations, Social Club lookup, dimension/range iterator filters and other managers still
throw their existing stub errors.
player.kick(reason?) delegates directly to the native player. It queues removal
on the server thread and returns undefined; state changes appear on the next
published snapshot, followed by rm::playerQuit and rm::playerDisconnected. Repeated requests keep
the first reason, and absent players are ignored. No SDK queue or gameplay state
is added.
Omitted, undefined or empty reasons use Kicked by server; other text is
preserved exactly, up to 1024 UTF-8 bytes. Native validation, a full command
queue or an unavailable runtime can throw synchronously. Validation also runs
for absent players. Catching a queue-full error lets the server continue.
Pending commands are discarded during shutdown. Reasons use the reliable
control channel with a one-second delivery interval; a lost connection can
prevent delivery. Server and clients must use game protocol 24.
player.setPosition(position) rotates SDK Z-up (x, y, z) into engine
(x, z, -y) and delegates to the native handle. Native validation and errors
propagate unchanged. It copies coordinates into the same bounded FIFO as kick;
repeated moves remain separate commands. Reads change after the next successful
host publication, including passes without a physics tick. Numeric coordinates
must remain finite and strictly below 1,000,000 in magnitude after f32
conversion. Invalid arguments, a full queue or a closed runtime throw
synchronously; a valid request for an absent player is ignored.
The native operation clears velocity, movement, ladder state and old controls,
preserving ID, wrapper identity, health, weapon, ammunition and life. A seated
player is detached without moving the car or other occupants; a driver stops
applying previous car commands. Dead players keep disabled physics and their
death deadline, with automatic respawn anchored at the new point. No extra
lifecycle events are emitted. Clients correct on the next regular simulation
snapshot; simulation pauses delay correction until resumption. Later physics,
terrain loading and world-bound recovery still apply. Other entity types retain
their existing setPosition() stubs. Other unsupported mutations remain stubs.
player.health and player.isDead directly read the native published state.
There is no SDK calculation or cached life state. Both throw after removal or
runtime shutdown, like native position.
player.spawn(position) rotates SDK (x, y, z) into engine (x, z, -y) and
calls native spawn. It copies coordinates into the same bounded FIFO and uses
the same validation/errors as movement, without coalescing repeated calls.
Publication is deferred until a successful host pass, including zero-tick passes.
Each execution begins a new life, even for a live player, with 100 health,
selected weapon and ammunition preserved, weapon holstered, old combat timers
reset and two seconds of simulation-tick protection. It enables the existing
body at the exact point and clears movement, velocity, ladder, old controls and
the previous death anchor. It detaches only this player, preserving car pose,
velocity and other occupants, and stops former driver commands.
IDs and handle/wrapper identities remain stable. Old inputs/actions are excluded
by life/generation; there are no additional lifecycle events. Clients correct on
the next regular simulation snapshot. Automatic respawn stays at three seconds
with its existing default loadout/ammunition reset when enabled; delay
configuration is future work.
Gamemod lifecycle integration remains a separate stage. Other entities and
existing platforms keep their behavior. Protocol is 20.
player.setHealth(value) delegates directly to the native handle, with no SDK
validation, clamping, queue or cached state. Native accepts only integer numbers
0..100 without coercion, throwing synchronously for invalid arguments, a full
queue or a closed runtime. Arguments are validated even for absent players;
valid absent-player calls are ignored. It returns undefined and uses the shared
1024-command FIFO without coalescing. Reads retain the previous published state
until a successful host pass, including zero-tick passes; clients update on the
next regular snapshot with the existing equal-tick and pause rules.
Life is checked at execution: dead-player assignments never revive or extend the
death wait. spawn(point); setHealth(50) works even when the published player is
dead; setHealth(0); setHealth(50) leaves a live player dead. Positive health
preserves movement/velocity, controls, ladder, seat, life/generation, weapon/ammo
and combat timers. Assignments bypass protection while preserving its deadline;
regular damage still respects it.
The first zero starts death with disabled physics, zero movement/velocity and
cleared controls, aim and ladder. RockSandbox records the death anchor and
three-second simulation-tick respawn deadline, increments generation once and
preserves life, loadout and command numbering. A dead occupant keeps their seat
and follows the car; both server and Rust prediction reject dead driver controls.
The car and other occupants are untouched. Automatic respawn retains free-space
checks, which can delay revival inside a car; manual spawn still unseats the
player. A transition to death emits playerDeath; no hit event is synthesized.
Pending commands are discarded on stop.
player.autoRespawn and player.setAutoRespawn(enabled) directly delegate to the
native published getter and queued command, without SDK checks, timers or cached
state. Native accepts only primitive booleans, defaults each connection to true,
and validates even for absent players. Invalid/missing arguments, a full queue or
a closed runtime throw synchronously; valid absent-player calls do nothing. The
command returns undefined and uses the shared 1024-command FIFO without merging
repeated changes. Reads retain the previous mode until successful publication,
including zero-tick passes, and throw after removal or runtime shutdown.
Turning automatic respawn off leaves dead players waiting for manual spawn() or
re-enabling. Enabling preserves the original death anchor and three-second
simulation-tick deadline; if overdue, the engine retries on the next physics tick
using existing free-space checks. A zero-tick pass does not start a life. Manual
spawn works in either mode; policy persists through deaths and manual/automatic
lives. Other admissions do not reset it; a reconnect gets true.
Changing policy alone preserves health, life/generation, physics/movement,
controls, ladder/seat, combat state/loadout and death anchor/deadline, without new
events. The native engine owns the policy outside the wire snapshot and client
prediction. Protocol is 20. The server IPlayer interface exposes both
members; RageMP, VIMP, AltV and Mock explicitly throw for these new operations.
Delay configuration and gamemod lifecycle integration remain later stages.
Player queries require the server and addon rebuilt together with ABI 24.
ABI 24 also requires the Node-thread interrupt shutdown and actual V8 termination
guard; rebuild the complete Sandbox bundle. Dimensions add public getters/setters and extend game protocol 24. Closed-host errors and
local exception identity are preserved.