Javascript/Typescript wrapper for the FiveM natives.
Functionality of this wrapper is based on the FiveM C# wrapper - link. It's a feature-rich set of helper classes, objects, and functions to help you develop your project faster.
- One dependency @citizenfx/client
- Abstracts common used FiveM practices
- Entity management through class objects (i.e.
VehicleandPedentities) - UI elements such as
scaleformsand loadingprompts - Audio, Blips, Cameras and more...
In other words, whatever the FiveM C# wrapper can do, this package can as well.
Note: Not all features are currently available. They will be added as development continues as well as additional language specific features.
import * as Cfx from 'fivem-js';
RegisterCommand(
'adder',
async (source: number, args: string[]) => {
const vehicle = await Cfx.World.CreateVehicle(new Cfx.Model('adder'), new Cfx.Vector3(1, 2, 3), 4);
Cfx.Game.PlayerPed.SetIntoVehicle(vehicle, Cfx.VehicleSeat.Driver);
},
false,
);You can also individually import classes.
import { World } from 'fivem-js/lib/World';/// <reference path="node_modules/fivem-js/lib/index.d.ts"/>
/// <reference path="node_modules/@citizenfx/client/natives_universal.d.ts"/>
const Cfx = require('fivem-js');
RegisterCommand(
'adder',
async (source, args) => {
const vehicle = await Cfx.World.CreateVehicle(new Cfx.Model('adder'), new Cfx.Vector3(1, 2, 3), 4);
Cfx.Game.PlayerPed.SetIntoVehicle(vehicle, Cfx.VehicleSeat.Driver);
},
false,
);You are more than welcome to contribute to this project by submitting a pull request and creating issues.
