RedM/Fivem ped spawning and management library with TypeScript support
npm install pma-locals``bash
`
npm install pma-locals
or
pnpm add pma-locals
`
Quick Start
typescript
`
import { registerPed, processSpawning, cleanupPeds } from "pma-locals";
import { Vector3, Delay } from "@nativewrappers/redm";
// Register a ped with animation
registerPed(
0x12345678, // model hash
new Vector3(-297.74, 791.1, 118.4), // spawn coords
180.0, // heading
50.0, // spawn distance (optional, default: 100.0)
true, // disable collisions
{
dict: "amb_wander@world_human_smoke@male@male_a@idle_a",
anim: "idle_a",
}, // optional animation
undefined // optional prop data
);
// In your game loop
setTick(async () => {
const playerPed = Game.PlayerPed;
await processSpawning(playerPed.Position);
await Delay(500);
});
// Cleanup on resource stop
on("onResourceStop", (resourceName: string) => {
if (resourceName === GetCurrentResourceName()) {
cleanupPeds();
}
});
modelName
API Reference
$3
Register a ped to spawn when players are within range.
Parameters:
- (number): Model hash
coords
- (Vector3): Spawn coordinates
heading
- (number): Ped heading direction (0-360)
spawnDistance?
- (number): Distance threshold (default: 100.0)
collisions?
- (boolean): Optional collision handler
animation?
- (Animation): Optional animation config
dict
- (string): Animation dictionary
anim
- (string): Animation name
propData?
- (Props): Optional prop attachment
model
- (string): Prop model hash
boneId
- (number): Bone to attach to
offset
- (number[]): Position offset [x, y, z]
rotation
- (number[]): Rotation [x, y, z]
`
$3
Process ped spawning/despawning based on player position. Call this regularly in your game loop (e.g., every 500ms).
$3
Delete all spawned peds. Use this when your resource stops to clean up entities.
TypeScript Support
Full type definitions are included. Import types as needed:
typescript
`
import type { PedConfig, Animation, Props } from "pma-locals";
PedConfig
Exported Types:
- - Complete ped configuration
Animation
- - Animation data structure
Props
- - Prop attachment configuration
`
Development
bash
``
Install dependencies
pnpm install
Build package (creates dist/ with .js and .d.ts files)
pnpm build:package
RedM development mode (watch)
pnpm watch
Publish to npm
npm version patch
pnpm publish
Built with:
- tsup - TypeScript bundler
- esbuild - Fast JavaScript bundler
- @nativewrappers/redm - RedM type definitions