Skip to main content

FiveM

Overview

The FiveM adapter connects OpenCore with the FiveM runtime family. It implements all framework contracts using FiveM's native APIs.

pnpm add @open-core/fivem-adapter

NPM | GitHub

For adapter maintenance, run opencore adapter check inside the adapter repository to verify contract coverage against the framework baseline.


Server Contracts

Core Implementations

ContractDescription
FiveMPlatformContextPlatform info, game profile (GTA5), capabilities
FiveMPlayerServerPlayer operations: drop, getPed, getName, getPing, getEndpoint, dimension
FiveMVehicleServerVehicle creation, deletion, retrieval
FiveMPedServerPed spawning and deletion
FiveMNpcLifecycleServerNPC lifecycle management
FiveMVehicleLifecycleServerVehicle spawn/despawn with model preloading
FiveMPlayerLifecycleServerPlayer spawn, teleport, respawn actions
FiveMPlayerAppearanceLifecycleServerPed appearance changes
FiveMPlayerStateSyncServerHealth, armor, state synchronization
FiveMPedAppearanceServerAdapterServer-side ped appearance
FiveMEngineEventsResource start/stop, server events
FiveMExportsExport registration and invocation
FiveMTickServer tick/interval handling
FiveMHasherModel hash computation
FiveMResourceInfoCurrent resource metadata
FiveMPlayerInfoPlayer identifiers and info

Client Contracts

Core Implementations

ContractDescription
FiveMRuntimeBridgeTick, commands, NUI callbacks via CFX globals
FiveMLocalPlayerBridgeLocal player position, heading, health
FiveMClientSpawnBridgePlayer spawn with model loading
FiveMPedAppearanceClientAdapterClient ped appearance (clothing, props, tattoos)
FiveMClientBlipBridgeMap blip creation and management
FiveMClientMarkerBridge3D marker rendering
FiveMClientNotificationBridgeNotifications, help text, subtitles
FiveMClientWebViewBridgeNUI communication with focus/cursor control
FiveMClientHasherModel hash utilities

FiveM-Specific Features

NUI Integration

The FiveM adapter provides full NUI (Native UI) support:

import { WebView, SetNuiFocus } from '@open-core/framework/client'

// Create NUI page
WebView.create('nui://my-ui/index.html', {
visible: true,
focused: true,
cursor: true,
})

// Send data to NUI
WebView.send('updateData', { items: myItems })

// Focus control
SetNuiFocus(true, false) // cursor=true, input=false

State Bags

FiveM's state bag system is used for reactive state synchronization:

// Server sets state
SetEntityHeading(playerPed, heading)
SetAuthValue(source, 'rank', 'admin')

// Client observes state changes
AddStateBagChangeHandler('rank', null, (bagName, key, value) => {
console.log(`Player ${bagName} rank: ${value}`)
})

Transport Protocol

Uses FiveM events for RPC and events:

  • __oc:rpc:req:* — RPC requests
  • __oc:rpc:res:* — RPC responses
  • __oc:events:* — Event broadcasting

Exports

FiveM has native resource exports, so getResource() remains the normal path for direct resource access.

OpenCore also exposes an optional explicit remote export helper layer for consistency with other adapters and for teams that prefer an async-only calling style:

import { IExports } from '@open-core/framework/contracts/server'

interface DatabaseExports {
pingDatabase(): Promise<{ success: boolean }>
}

class ExampleService {
constructor(private readonly exportsService: IExports) {}

async pingDatabase() {
const database = await this.exportsService.waitForRemoteResource<DatabaseExports>('database', {
exportName: 'pingDatabase',
})

return database.pingDatabase()
}
}

Use guidance:

  • getResource() for direct/local-style access
  • getRemoteResource() / waitForRemoteResource() when you want the optional async helper layer

Manual loading screen shutdown

FiveM supports loadscreen_manual_shutdown 'yes' for flows where the world should remain hidden until the client has prepared its scene.

OpenCore supports this in the spawn lifecycle through skipLoadingScreenShutdown.

Server-side:

player.spawn(position, 'mp_m_freemode_01', {
skipLoadingScreenShutdown: true,
})

Client-side:

await spawnService.spawn(position, 'mp_m_freemode_01', 0, {
skipLoadingScreenShutdown: true,
})

ShutdownLoadingScreenNui()

Use this when you need to:

  • spawn at a neutral staging position
  • load models or animation dictionaries
  • configure cinematic cameras
  • reveal the world only after the scene is ready

When skipLoadingScreenShutdown is set, OpenCore does not call ShutdownLoadingScreen() or ShutdownLoadingScreenNui() for that spawn. Your resource owns the shutdown timing.


Configuration

FiveM Manifest

The CLI generates fxmanifest.lua with FiveM-specific data:

fx_version 'cerulean'
game 'gta5'

author 'Your Name'
description 'OpenCore Server'
version '1.0.0'

server_scripts {
'server.js'
}

client_scripts {
'client.js'
}

dependencies {
'opencore-core'
}

OpenCore Config

import { defineConfig } from '@open-core/cli'
import { FiveMServerAdapter } from '@open-core/fivem-adapter/server'
import { FiveMClientAdapter } from '@open-core/fivem-adapter/client'

export default defineConfig({
name: 'my-server',
destination: '/path/to/fxserver/resources',
adapter: {
server: FiveMServerAdapter(),
client: FiveMClientAdapter(),
},
core: {
path: './core',
resourceName: 'core',
},
})

Platform Capabilities

CapabilityValue
Max Players1024
Game ProfileGTA5
Default Spawn Modelmp_m_freemode_01
Default Vehicle Typeautomobile
Server Vehicle CreationSupported
State BagsFull support
NUI/Native UIFull support
Ped Appearance (Server)Supported
WebView Focus ControlSupported

Client Setup

import { Client } from '@open-core/framework/client'
import { FiveMClientAdapter } from '@open-core/fivem-adapter/client'

Client.init({
mode: 'CORE',
adapter: FiveMClientAdapter(),
})

The adapter automatically:

  • Registers NUI callback handlers
  • Sets up WebView message routing
  • Configures local player bridges
  • Initializes spawn and appearance services