Project structure
The server keeps its scripting in the script folder beside nativemp-server.exe:
nativemp-server.exeserver.ininode\ Node.js, shipped with the serverscript\ runtime.ts starts your gamemode and talks to the server dispatcher.ts orders callbacks per connection and keeps control traffic responsive execution.mjs preserves session/cancellation context across asynchronous work sdk.ts the SDK that "nativemp" imports resolve to gamemodes\ freeroam.ts the default gamemode template.ts a starting point for your own seat-denial.ts an example of vetoing vehicle entry package.json marks the .ts files as ES modules tsconfig.json lets your editor find "nativemp" and check typesYour gamemode can live in any folder: import ... from "nativemp" always resolves to the server’s sdk.ts. When you
move a gamemode elsewhere, copy package.json and tsconfig.json with it, and point paths in tsconfig.json at
sdk.ts.
See async handlers for await in handlers, the order they run in, and players who leave
while one waits.
TypeScript without a build step
Section titled “TypeScript without a build step”Node.js runs .ts files as they are: it strips the types and runs what’s left. There is nothing to compile, and it
also means Node never type-checks. Your editor is the check.
Node can only strip syntax that is nothing but types. These don’t work, and the tsconfig.json flags them
(erasableSyntaxOnly):
enum: use a union of strings, or an objectas constnamespace- constructor parameter properties (
constructor(private name: string))
Errors
Section titled “Errors”A gamemode that throws prints its stack, with the file and line, in the server console.