server.detached
Runs work that belongs to the whole server rather than to one player. Normally, timers and promises a handler starts
stop when the player whose event or command it was leaves (see async handlers).
Inside server.detached they run on until your gamemode stops, so a round an admin started goes on when the admin
leaves.
Signature
Section titled “Signature”server.detached<T>(callback: () => T): TParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
callback |
() => T |
The work. It runs at once. |
Returns
Section titled “Returns”What callback returns, unchanged; a promise is not awaited for you, and its errors are yours to catch.
Example
Section titled “Example”import { chat, commands, server } from "nativemp";
commands.register("startround", () => server.detached(() => { const timer = setInterval(() => chat.sendServerMessage("Round tick"), 1000); setTimeout(() => clearInterval(timer), 60_000);}));Related
Section titled “Related”- Async handlers: when work stops, and why
HandlerContext: the handler’ssignal