FreeScript
opencore
by newcore-network · version 2026.11.12 · updated 3 days ago
No reviews yet
- Downloads
- 0
- Reviews
- 0
- Size
- 598 KB
- Code check
- Checked
- Licence
- MPL-2.0
- Released
- Nov 2026
Secure, event-driven TypeScript Framework & Runtime engine (FiveM and RageMP)
OpenCore Framework - Stable v1
OpenCore is a TypeScript multiplayer runtime framework targeting CitizenFX runtimes (Cfx/RageMP) via adapters.
It is not a gamemode or RP framework. It provides:
Discord Community | Docs | OpenCore CLI
Installation
This framework uses TypeScript decorators. Ensure your project has decorators enabled.
Imports and entry points
The package exposes subpath entry points:
OpenCore follows a Ports & Adapters (Hexagonal) architecture.
Cfx game profiles
OpenCore treats CitizenFX (
Each instance runs in exactly one mode configured via
Initialize the server runtime:
Some features require providers (depending on your mode and configuration). Configure them before calling
Controllers and decorators
OpenCore uses a decorator + processor pattern.
Decorators store metadata with
Commands
Network events
Security decorators
Guidance:
Use library wrappers to emit domain events and
It does not listen to
Client usage follows the same pattern with
…
OpenCore is a TypeScript multiplayer runtime framework targeting CitizenFX runtimes (Cfx/RageMP) via adapters.
It is not a gamemode or RP framework. It provides:
- A stable execution model (server and client)
- Dependency Injection and metadata-driven wiring
- An event/command system
- Security primitives (validation, access control, rate limiting)
Discord Community | Docs | OpenCore CLI
Installation
pnpm add @open-core/framework reflect-metadata tsyringe zod uuidThis framework uses TypeScript decorators. Ensure your project has decorators enabled.
Imports and entry points
The package exposes subpath entry points:
@open-core/framework(root)@open-core/framework/server@open-core/framework/client
OpenCore follows a Ports & Adapters (Hexagonal) architecture.
- Kernel (
src/kernel): engine-agnostic infrastructure (DI, logger, metadata scanning) - Runtime (
src/runtime): multiplayer execution model (controllers, processors, security, lifecycle) - Adapters (
src/adapters): platform integration (Cfx, Node testing)
Cfx game profiles
OpenCore treats CitizenFX (
cfx) as the platform and supports game profiles (gta5 and rdr3).
- Shared runtime APIs (events, exports, transport, DI) are registered through the Cfx adapter.
- Game-specific behavior is controlled through platform capabilities/config (
gameProfile,defaultSpawnModel, etc.). - Optional RedM-specific enhancements can be layered as external libraries without changing core runtime contracts.
Each instance runs in exactly one mode configured via
Server.init():
CORE: authoritative runtime. Typically provides identity/auth/players via exports.RESOURCE: a normal Cfx resource using CORE as provider for some features.STANDALONE: a self-contained runtime (useful for tooling, simulations, or small servers).
Initialize the server runtime:
import { Server } from '@open-core/framework/server'
await Server.init({
mode: 'CORE'
})Some features require providers (depending on your mode and configuration). Configure them before calling
init():
import { Server } from '@open-core/framework/server'
Server.setPrincipalProvider(MyPrincipalProvider)
Server.setSecurityHandler(MySecurityHandler)
Server.setPersistenceProvider(MyPlayerPersistence)
Server.setNetEventSecurityObserver(MyNetEventSecurityObserver)Controllers and decorators
OpenCore uses a decorator + processor pattern.
Decorators store metadata with
Reflect.defineMetadata(). During bootstrap, the MetadataScanner reads metadata and processors register handlers.Commands
import { Controller, Command, Guard, Throttle, Player } from '@open-core/framework/server'
import { z } from 'zod'
const TransferSchema = z.tuple([z.coerce.number().int().positive(), z.coerce.number().min(1)])
@Controller()
export class BankController {
@Command({
command: 'transfer',
usage: '/transfer ',
schema: TransferSchema,
})
@Guard({ rank: 1 })
@Throttle(1, 2000)
async transfer(player: Player, args: z.infer) {
const [targetId, amount] = args
player.emit('chat:message', `transfer -> ${targetId} (${amount})`)
}
}Network events
@OnNet() handlers always receive Player as the first parameter.
import { Controller, OnNet, Player } from '@open-core/framework/server'
import { z } from 'zod'
const PayloadSchema = z.object({ action: z.string(), amount: z.number().int().positive() })
@Controller()
export class ExampleNetController {
@OnNet('bank:action', { schema: PayloadSchema })
async onBankAction(player: Player, payload: z.infer) {
player.emit('chat:message', `action=${payload.action} amount=${payload.amount}`)
}
}Security decorators
@Guard({ rank })or@Guard({ permission })@Throttle(limit, windowMs)@RequiresState({ missing: [...] })
@Export() defines a public resource API. Adapters may expose both direct/local access through getResource() and an optional explicit async helper layer through getRemoteResource() / waitForRemoteResource().
import { Controller, Export } from '@open-core/framework/server'
import { IExports } from '@open-core/framework/contracts/server'
@Controller()
export class DatabaseController {
@Export('pingDatabase')
async pingDatabase() {
return { success: true }
}
}
interface DatabaseExports {
pingDatabase(): Promise
}
class ExampleConsumer {
constructor(private readonly exportsService: IExports) {}
async ping() {
const database = await this.exportsService.waitForRemoteResource('database', {
exportName: 'pingDatabase',
})
return database.pingDatabase()
}
}Guidance:
getResource()is for local/synchronous resolution used by framework internals.waitForRemoteResource()/getRemoteResource()are optional adapter utilities for explicit async resource-to-resource calls.
Use library wrappers to emit domain events and
@OnLibraryEvent() to observe them.@OnLibraryEvent() listens to events emitted through library.emit(...) only.It does not listen to
emitExternal, emitNetExternal, or emitServer.
import { Server } from '@open-core/framework/server'
const characters = Server.createServerLibrary('characters')
@Controller()
export class CharacterListeners {
@OnLibraryEvent('characters', 'session:created')
onSessionCreated(payload: { sessionId: string; playerId: number }) {
// optional listener for library domain events
}
}
characters.emit('session:created', { sessionId: 's-1', playerId: 10 })Client usage follows the same pattern with
Client.createClientLibrary(...) and…